004 debug

This commit is contained in:
msyu
2025-08-18 14:26:20 +03:00
parent 8938dd29a6
commit 9593f02013
4 changed files with 168 additions and 232 deletions
+4 -4
View File
@@ -14,16 +14,16 @@
<cfset this.mappings = structNew() /> <cfset this.mappings = structNew() />
<cfset this.mappings["/mod"] = getDirectoryFromPath(getCurrentTemplatePath()) & "mod/" /> <cfset this.mappings["/mod"] = getDirectoryFromPath(getCurrentTemplatePath()) & "mod/" />
<cfset this.customTagPaths = expandPath(getDirectoryFromPath(getCurrentTemplatePath())&'mod')/> <cfset this.customTagPaths = expandPath(getDirectoryFromPath(getCurrentTemplatePath())&'mod')/>
<cfset this.datasource = "dwh"/> <cfset this.datasource = "dwh"/>
<cfset this.defaultdatasource = this.datasource/> <cfset this.defaultdatasource = this.datasource/>
<cfset request.DS = "#this.datasource#"> <cfset request.DS = "#this.datasource#">
<!--- кажется, нужно инициализировать датасорцы в псевдоконструкторе - onRequest не получается --->
<cfset this.datasources["#this.datasource#"]=getDS("#this.datasource#","ds_#this.datasource#")/> <cfset this.datasources["#this.datasource#"]=getDS("#this.datasource#","ds_#this.datasource#")/>
<cfset this.datasources["billing-vc"]=getDS("billing-vc","ds_billing_vc")/> <cfset this.datasources["billing-vc"]=getDS("billing-vc","ds_billing_vc")/>
<cfset this.datasources["billing-s3"]=getDS("billing-s3","ds_billing_s3")/> <cfset this.datasources["billing-s3"]=getDS("billing-s3","ds_billing_s3")/>
<!--- но датасорцы таинственно прочухались с прошлым пушем, без переноса инициализации в псевдоконструктор --->
@@ -99,7 +99,7 @@
<cfset request.RECORDS_PER_PAGE=500/> <cfset request.RECORDS_PER_PAGE=500/>
<cfset request.APP_VERSION="0.00.001"/> <cfset request.APP_VERSION="0.00.004"/>
<cfset request.STAND=getStand()/> <cfset request.STAND=getStand()/>
<cflock scope="application" type="readonly" timeout=3> <cflock scope="application" type="readonly" timeout=3>
+155
View File
@@ -0,0 +1,155 @@
<cfsilent>
<cfimport prefix="m" taglib="lib"/>
<cfimport prefix="c" taglib="lib/controls"/>
<cfimport prefix="d" taglib="lib/data"/>
<cfimport prefix="layout" taglib="layout"/>
</cfsilent><m:silent silent="No">
<cffunction name="plain2HtmClean">
<cfargument name="s" type="string"/>
<cfreturn request.plain2htm(request.cleanHtm(s))/>
</cffunction>
<cffunction name="cleanInput">
<cfargument name="s" type="string"/>
<cfreturn htmlEditFormat(s)/>
</cffunction>
<m:prepare_detail entity="additional_agreement" accessObject="" key="additional_agreement_uid" pageInfoOut="pageInfo"/>
<d:bean readonly=true table="elma.additional_agreements" datasource="#request.DS#" output="d" status="status">
<d:param field="__id" type="uuid" key/>
<d:param field="__name" type="varchar" size="255" preprocessor=#cleanInput# forNull=""/>
<d:param field="company_uid" type="uuid"/>
<d:param field="date_of_aggrement" type="timestamp"/>
<d:param field="date_end_aggrement" type="timestamp"/>
</d:bean>
<m:dispatch_detail
usePRG="No"<!---*** --->
pageInfo=#pageInfo#
id="#d.__id#"
status=#pageInfo.status#
trackOut="tr"
idAttributesOut="id"
/>
<!--- decoration --->
<cfquery name="qDecoration" datasource="#request.DS#">
select
__name as contragent
from elma.companies k
where k.__id=<cfqueryparam cfsqltype="cf_sql_other" value=#d.company_uid#/>
</cfquery>
</m:silent><!---
------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------
---><layout:page section="header" pageInfo=#pageInfo#>
<layout:attribute name="title">
<cfoutput>
Дополнительное соглашение
<cfif len(d.__id)>
<b>#d.__name#</b>
[#d.__id#]
</cfif>
</cfoutput>
</layout:attribute>
</layout:page>
<!--- <cfif status.errorState GT 0>
<cfoutput><div class="err">#status.errorMessage#</div></cfoutput>
</cfif>
--->
<cfoutput>
<input type="hidden" name="__id" value="#d.__id#"/>
<input type="hidden" name="track" value="#tr.self#"/>
<input type="hidden" name="pass" value=""/><!--- pass marker to prevent save on submit --->
<div class="detail">
<div class="tr">
<div class="th">__id</div>
<div class="td">#d.__id#</div>
</div>
<div class="tr">
<div class="th">Номер договора</div>
<div class="td">#d.__name#</div>
</div>
<div class="tr">
<div class="th">Контрагент</div>
<div class="td">#qDecoration.contragent# [#d.company_uid#]</div>
</div>
<div class="tr">
<div class="th">Дата договора</div>
<div class="td">#d.date_of_aggrement#</div>
</div>
<div class="tr">
<div class="th">Дата окончания договора</div>
<div class="td">#d.date_end_aggrement#</div>
</div>
</div>
</cfoutput>
<!---
<layout:page section="extension" closeForm="Yes"/>
<cfif d.contragent_id GT 0>
<cfquery name="qContract">
select
d.contract_id
,d.contract
,d.dt_contract
,(select count(*) from specification s where s.contract_id=d.contract_id) as spec_cnt
from contract d
where d.contragent_id=<cfqueryparam cfsqltype="cf_sql_integer" value="#d.contragent_id#"/>
order by 1
</cfquery>
<cfoutput>
<h4>Договоры (#qContract.recordCount#)</h4>
</cfoutput>
<table class="worktable">
<thead>
<tr>
<th><c:link_add canWrite=#pageInfo.writePermitted()# entity="contract" id="#contragent_id#" extra="contragent_id=#d.contragent_id#" fwx=#tr.fwx#/></th>
<th>Номер договора</th>
<th>Дата договора</th>
<th>Спецификаций</th>
<th></th>
</tr>
</thead>
<cfoutput query="qContract">
<tr>
<td>
<c:link_view_edit canWrite=#pageInfo.writePermitted()# entity="contract" id=#contract_id# fwx=#tr.fwx#/>
</td>
<td>#contract#</td>
<td class="c">
#dateFormat(dt_contract,'YYYY-MM-DD')#
</td>
<td class="c">
<cfif spec_cnt GT 0>#spec_cnt#</cfif>
</td>
<td class="c">
<c:link_del canWrite=#pageInfo.writePermitted()# entity="contract" id=#contract_id# fwx=#tr.fwx#/>
</td>
</tr>
</cfoutput>
</table>
</cfif> --->
<layout:page section="footer"/>
+2 -2
View File
@@ -30,7 +30,7 @@
<c:menu_item acl="" page="usr_ls.cfm" label="Пользователи"/> <c:menu_item acl="" page="usr_ls.cfm" label="Пользователи"/>
---> --->
<li class="menu-title">"Пользователь"</li> <!--- <li class="menu-title">Пользователь</li>
<cfif request.usrAuthenticated()> <cfif request.usrAuthenticated()>
<cfquery name="qUsr" datasource="#request.DS#"> <cfquery name="qUsr" datasource="#request.DS#">
@@ -46,7 +46,7 @@
<c:menu_item acl="" page="saml/login.cfm" queryString="target_page=#URLEncodedFormat(ATTRIBUTES.thisUrl)#" label="Вход через WebSSO"/> <c:menu_item acl="" page="saml/login.cfm" queryString="target_page=#URLEncodedFormat(ATTRIBUTES.thisUrl)#" label="Вход через WebSSO"/>
<c:menu_item acl="" page="login.cfm" queryString="#ATTRIBUTES.fwx#" label="Вход"/> <c:menu_item acl="" page="login.cfm" queryString="#ATTRIBUTES.fwx#" label="Вход"/>
<c:menu_item acl="" page="logout.cfm" queryString="target_page=#URLEncodedFormat(ATTRIBUTES.thisUrl)#" label="Выход"/> <c:menu_item acl="" page="logout.cfm" queryString="target_page=#URLEncodedFormat(ATTRIBUTES.thisUrl)#" label="Выход"/>
</cfif> </cfif> --->
</ul> </ul>
+7 -226
View File
@@ -120,8 +120,8 @@ HOT_FREE_LIMIT 1 10 1 100
<cfquery name="qS3Vol" datasource="billing-s3"> <cfquery name="qS3Vol" datasource="billing-s3">
select /* *** ниже дублирование кода агрегации - round ceil etc, обратить внимание при правке */ select /* *** ниже дублирование кода агрегации - round ceil etc, обратить внимание при правке */
(sum(bucket_stat.usage_rgw_main_size_actual)/<cfqueryparam cfsqltype="cf_sql_integer" value=#hours#/>) as vol_B (sum(bucket_stat.usage_rgw_main_size_actual)/<cfqueryparam cfsqltype="cf_sql_integer" value=#hours#/>) as vol_B
,round(sum(bucket_stat.usage_rgw_main_size_actual)/<cfqueryparam cfsqltype="cf_sql_integer" value=#hours#/>/1024/1024/1024) as vol_GB ,ceil(sum(bucket_stat.usage_rgw_main_size_actual)/<cfqueryparam cfsqltype="cf_sql_integer" value=#hours#/>/1024/1024/1024) as vol_GB
,greatest(round(sum(bucket_stat.usage_rgw_main_size_actual)/<cfqueryparam cfsqltype="cf_sql_integer" value=#hours#/> ,greatest(ceil(sum(bucket_stat.usage_rgw_main_size_actual)/<cfqueryparam cfsqltype="cf_sql_integer" value=#hours#/>
/1024/1024/1024)- /1024/1024/1024)-
case when bucket_stat.placement_id = 1 then 1 else 0 end, 0) as vol_GB_free_tier_subtracted /*считается не в точности так, как в функции*/ case when bucket_stat.placement_id = 1 then 1 else 0 end, 0) as vol_GB_free_tier_subtracted /*считается не в точности так, как в функции*/
,case ,case
@@ -307,16 +307,16 @@ S3 операции и трафик: <b>#dateFormat(qS3OpsTrfAge.dt_load,'YYYY-M
<thead> <thead>
<td width="1%"></td> <td width="1%"></td>
<td width="3%">WZ</td> <td width="3%">WZ</td>
<td width="5%">Артикул</td> <td width="5%">Артикул</td>
<td width="3%">Цена без НДС проверить</td>
<td width="3%">Кол-во (метрика)</td> <td width="3%">Кол-во (метрика)</td>
<td width="3%">Ед.изм.</td> <td width="3%">Ед.изм.</td>
<td width="3%">Цена с НДС</td>
<td width="3%">Ст-ть</td> <td width="3%">Ст-ть</td>
<td width="3%">&nbsp;&nbsp;&nbsp;</td> <td width="3%">&nbsp;&nbsp;&nbsp;</td>
<td width="6%">Дата НОУ</td> <td width="6%">Дата НОУ</td>
<td width="6%">Дата оконч.</td> <td width="6%">Дата оконч.</td>
<td width="3%">Ключ строки</td> <td width="3%">Ключ строки</td>
<td width="3%">GPL без НДС проверить</td> <td width="3%">GPL с НДС</td>
<td width="3%">Скидка%</td> <td width="3%">Скидка%</td>
<td width="3%">Сырая метрика</td> <td width="3%">Сырая метрика</td>
<td width="3%">Приведен&shy;ная метрика</td> <td width="3%">Приведен&shy;ная метрика</td>
@@ -335,10 +335,10 @@ S3 операции и трафик: <b>#dateFormat(qS3OpsTrfAge.dt_load,'YYYY-M
<tr> <tr>
<td>#currentRow#</a></td> <td>#currentRow#</a></td>
<td><a href="contragent.cfm?__id=#contragent_uid#&#tr.fwx#">#wz#</a></td> <td><a href="contragent.cfm?__id=#contragent_uid#&#tr.fwx#">#wz#</a></td>
<td>#code#</td> <td>#code#</td>
<td class="r">#discounted_price#</td>
<td class="r">#chargeable_metric#</td> <td class="r">#chargeable_metric#</td>
<td>#ed_izm#</td> <td>#ed_izm#</td>
<td class="r">#discounted_price#</td>
<td class="r">#charge#</td> <td class="r">#charge#</td>
<td></td> <td></td>
<td class="r">#dateFormat(dt_from,'YYYY-MM-DD')#</td> <td class="r">#dateFormat(dt_from,'YYYY-MM-DD')#</td>
@@ -370,224 +370,5 @@ S3 операции и трафик: <b>#dateFormat(qS3OpsTrfAge.dt_load,'YYYY-M
<layout:page section="footer"/> <layout:page section="footer"/>
<!---
--->
<!--- --,m.*
--,s.price*(100-s.discount)/100 as discounted_price
-- --->
<!--- В одном месте user_id int в другом owner varchar --->
<!---
задача (вызванная сыростью базы биллинга)
смапить код параметра с VDC (1:n)
iaas.ngc.i31.ram-m
iaas.ngc.a28.ram-m
cl01:
7 хостов Lenovo ThinkSystem SR650 -[7X06CTO1WW]-
2 процессора Xeon(R) Gold 6226R 16 ядер 32 потока каждый 2.9 ГГц
1.25тб озу в каждом.
В 4 из 7 есть по 4 GPU NVIDIA A16 16GB в каждом.
cl01-vsan:
16 хостов Lenovo ThinkSystem SR650 -[7X06CTO1WW]-
2 процессора Xeon(R) Gold 6226R 16 ядер 32 потока каждый 2.9 ГГц
1.25тб озу в каждом.
В 9 из 16 есть по 4 GPU NVIDIA A16 16GB в каждом.
cl02:
10 Huawei 2488H V5
4 процессора Xeon(R) Gold 6254 18 ядер 36 потоков каждый. 3.1 ГГц
2тб озу в каждом.
5 Huawei Atlas 800 (Model 3010)
2 процессора Xeon(R) Gold 6254 18 ядер 36 потоков каждый. 3.1 ГГц
1.5тб озу в каждом.
cl04-vsan:
10 Apex AR320-12
2 процессора AMD EPYC 7543 32 ядра 64 потока каждый. 2.8 ГГц
2тб озу в каждом.
18 Apex AR320-12-E7543
2 процессора AMD EPYC 7543 32 ядра 64 потока каждый. 2.8 ГГц
2тб озу в каждом.
cl05-1c:
1 Asus RS720A-E12-RS24U
2 процессора AMD EPYC 9274F 24 ядра 48 потоков каждый. 4.05 ГГц
1тб озу.
7 ручная сборка
MB Asus ProArt B650-Creator
Процессор AMD Ryzen 9 7950X 16 ядер 32 потока каждый. 4.5 ГГц
192гб озу каждый.
1 ручная сборка
процессор AMD Ryzen Threadripper PRO 5995WX 64 ядра 128 потоков каждый. 2.7 ГГц
512гб озу.
cl06-vsan:
15 R320
2 процессора Xeon(R) Gold 6342 24 ядра 48 потоков каждый. 2.8 ГГц
1тб озу каждый.
Xeon(R) Gold 6226R 2.9 ГГц
Xeon(R) Gold 6254 3.1 ГГц
AMD EPYC 7543 2.8 ГГц
AMD EPYC 9274F 4.05 ГГц
AMD Ryzen 9 7950X 4.5 ГГц
AMD Ryzen Threadripper PRO 5995WX 2.7 ГГц
Xeon(R) Gold 6342 2.8 ГГц --->
<!--- 2025-08-15 20:47:44 *** Операции S3 считаются не так, как написано в тарифе. Например, считается list. В тарифе вообще не описан минимальный лимит --->
<!--- BEGIN
RETURN QUERY
(
select
billing_per_user_fix_pl.placement as placement,
(CASE
WHEN ( billing_per_user_fix_pl.placement = 'HOT'
) THEN greatest(ceil(sum(size)/1024/1024/1024)-1,0)
WHEN ( not billing_per_user_fix_pl.placement = 'HOT'
) THEN ceil(sum(size)/1024/1024/1024)
END) AS size_GB,
(CASE
WHEN ( billing_per_user_fix_pl.placement = 'HOT'
) THEN greatest(ceil(sum(get)/10000)-10,0)
WHEN ( not billing_per_user_fix_pl.placement = 'HOT'
) THEN ceil(sum(get)/10000)
END) AS get_10k,
(CASE
WHEN ( billing_per_user_fix_pl.placement = 'HOT'
) THEN greatest(ceil(sum(put)/10000)-1,0)
WHEN ( not billing_per_user_fix_pl.placement = 'HOT'
) THEN ceil(sum(put)/10000)
END) AS put_10k,
(CASE
WHEN ( billing_per_user_fix_pl.placement = 'HOT'
) then greatest(ceil(sum(bytes_sent)/1024/1024/1024)-100,0)
WHEN ( not billing_per_user_fix_pl.placement = 'HOT'
) THEN ceil(sum(bytes_sent)/1024/1024/1024)
END) AS bytes_sent_GB
from s3billing.billing_per_user_fix_pl(_ds,_df,_user)
group by billing_per_user_fix_pl.placement
UNION all
select
'HOT_FREE_LIMIT' as placement,
'1' AS size_GB,
'10' AS get_10k,
'1' AS put_10k,
'100' AS bytes_sent_GB
);
END; --->
<!---
BEGIN
RETURN QUERY
SELECT
s3billing.bucket_info.name AS bucket_name,
(case
when ( s3billing.placement.name = 'default-placement') then 'HOT'
WHEN ( not s3billing.placement.name = 'default-placement' ) THEN s3billing.placement.name
end
) as placement,
coalesce(round(sum(usage_rgw_main_size_actual)/
(SELECT (DATE_PART('day',
((TO_TIMESTAMP(_df, 'YYYY-MM-DD HH24:MI:SS'))
-TO_TIMESTAMP(_ds, 'YYYY-MM-DD HH24:MI:SS'))
)*24+
DATE_PART('hour',
((TO_TIMESTAMP(_df, 'YYYY-MM-DD HH24:MI:SS'))
-TO_TIMESTAMP(_ds, 'YYYY-MM-DD HH24:MI:SS'))
)))
)::numeric,0) AS size
,coalesce(s2.get, 0) AS get
,coalesce(s2.put, 0) AS put
,coalesce(s2.bytes_sent, 0) as bytes_sent
FROM s3billing.bucket_stat
INNER JOIN s3billing.placement ON s3billing.bucket_stat.placement_id=s3billing.placement.id
INNER JOIN s3billing.bucket_info ON s3billing.bucket_stat.bucket_id=s3billing.bucket_info.id
LEFT JOIN (
SELECT
s1.bucket_id AS bucket_id
,s1.bucket_name AS bucket_name,
(case
when ( s1.placement = 'default-placement') then 'HOT'
WHEN ( not s1.placement = 'default-placement' ) THEN s1.placement
end
) as placement
,coalesce(sum(s1.get) ,0) AS get
,coalesce(sum(s1.put) ,0) AS put
,coalesce(sum(s1.bytes_sent), 0) AS bytes_sent
FROM (
SELECT
s3billing.bucket_info.id AS bucket_id
,s3billing.bucket_info.name AS bucket_name
,(case
when ( s3billing.placement.name = 'default-placement') then 'HOT'
WHEN ( not s3billing.placement.name = 'default-placement' ) THEN s3billing.placement.name
end
) as placement
,(CASE
WHEN ( s3billing.category.name LIKE 'get%'
OR s3billing.category.name LIKE 'head%'
OR s3billing.category.name LIKE 'options%'
) THEN coalesce(sum(ops), 0)
END) AS get
,(CASE
WHEN ( s3billing.category.name LIKE 'put%'
OR s3billing.category.name LIKE 'post%'
OR s3billing.category.name LIKE 'patch%'
OR s3billing.category.name LIKE 'list%'
) THEN coalesce(sum(ops), 0)
END) AS put
,coalesce(sum(usage_bucket_by_user.bytes_sent), 0) AS bytes_sent
FROM
s3billing.usage_bucket_by_user
INNER JOIN s3billing.bucket_info ON s3billing.usage_bucket_by_user.bucketid = s3billing.bucket_info.id
INNER JOIN s3billing.placement ON s3billing.bucket_info.placement_id = s3billing.placement.id
INNER JOIN s3billing.user_info ON s3billing.usage_bucket_by_user.user_id = s3billing.user_info.id
INNER JOIN s3billing.category ON s3billing.usage_bucket_by_user.category_id = s3billing.category.id
WHERE
s3billing.user_info.name=_user
AND s3billing.usage_bucket_by_user.time >=TO_TIMESTAMP(_ds, 'YYYY-MM-DD HH24:MI:SS')
AND s3billing.usage_bucket_by_user.time < TO_TIMESTAMP(_df, 'YYYY-MM-DD HH24:MI:SS')
GROUP BY
s3billing.bucket_info.name
,s3billing.placement.name
,s3billing.category.name
,s3billing.bucket_info.id
) AS s1
GROUP BY
s1.bucket_name
,s1.bucket_id
,s1.placement
ORDER BY
s1.placement
,s1.bucket_name
) AS s2 ON s2.bucket_id = s3billing.bucket_stat.bucket_id
WHERE owner=_user
AND timestamp_addition >= TO_TIMESTAMP(_ds, 'YYYY-MM-DD HH24:MI:SS')
AND timestamp_addition < TO_TIMESTAMP(_df, 'YYYY-MM-DD HH24:MI:SS')
GROUP BY
s3billing.bucket_info.name
,s3billing.placement.name
,s3billing.bucket_stat.bucket_id
,s2.get
,s2.put
,s2.bytes_sent
ORDER BY
s3billing.placement.name
,s3billing.bucket_info.name
;
END; --->
<!--- select * from s3billing.billing_per_user_fix_pl('2025-05-01 00:00:00','2025-06-01 00:00:00','1395'); ---> <!--- select * from s3billing.billing_per_user_fix_pl('2025-05-01 00:00:00','2025-06-01 00:00:00','1395'); --->