046 versioning fixes

This commit is contained in:
2026-04-28 13:28:26 +03:00
parent c9a229cc8e
commit 2a3cf0482f
9 changed files with 1149 additions and 304 deletions
+1 -1
View File
@@ -76,7 +76,7 @@
<!--- global settings ---> <!--- global settings --->
<cfset request.RECORDS_PER_PAGE=500/> <cfset request.RECORDS_PER_PAGE=500/>
<cfset request.APP_VERSION="0.00.045"/> <cfset request.APP_VERSION="0.00.046"/>
<cfset request.STAND=getStand()/> <cfset request.STAND=getStand()/>
<cflock scope="application" type="readonly" timeout=3> <cflock scope="application" type="readonly" timeout=3>
+116 -47
View File
@@ -111,60 +111,127 @@
<cfif len(d.__id)> <cfif len(d.__id)>
<cfquery name="qService"> <cfquery name="qService">
with with
status(status, status_id, probability_pc) as (VALUES status(status, status_id, probability_pc) as (VALUES
('Закрыта неуспешно',7,0),('Закрыта успешно',6,100),('Договор подписан',5,100),('Договор на подписании',15,90),('Договор на согласовании',12,70), ('Закрыта неуспешно',7,0),('Закрыта успешно',6,100),('Договор подписан',5,100),('Договор на подписании',15,90),('Договор на согласовании',12,70),
('Тестирование',8,50),('Отправлено ТКП',10,20),('Внутреннее согласование',37,10),('Проработка решения',4,10),('Сбор потребностей',1,0) ('Тестирование',8,50),('Отправлено ТКП',10,20),('Внутреннее согласование',37,10),('Проработка решения',4,10),('Сбор потребностей',1,0)
) )
select ,line_expanded
siv.__id AS (
,siv.__name SELECT siv.__id AS siv_uid
,siv.user_description
,siv.discount ,siv.discount
,siv.cnt ,siv.type AS line_pricing_model_id
,siv.hash AS line_key
,siv.is_actual AS siv_is_actual
,siv.version::NUMERIC AS line_version
,siv.modifier_code ,siv.modifier_code
,siv.abstractive_service_code ,siv.abstractive_service_code
,siv.is_actual ,siv.__index AS siv_index
,siv.type ,d.__index AS deal_index
,siv.hash ,d._companies
,siv.version ,a.index AS agreement_version
,siv.__index ,siv.date_nop::DATE AS dt_from
,siv.date_nop ,siv.date_end::DATE AS dt_to
,siv.date_end ,siv.is_easy AS is_simple
,siv.is_easy ,siv.cnt
,siv.params::text ,s.probability_pc
,a.__id::text as additional_agreement_uid ,a.__id AS additional_agreement_uid
,a.__name as additional_agreement ,a.contract_uid
,a.is_actual AS additional_agreement_is_actual
,a.deal_uid
,a.__name AS additional_agreement
,d.__name AS deal
,d.__status_status AS deal_status_id
,siv.user_description --
,siv.params
FROM elma.deals_services siv
JOIN elma.deals d ON (d.__id = ANY (siv.deal))
JOIN STATUS s ON (d.__status_status = s.status_id)
LEFT JOIN elma.additional_agreements a ON (a.__id = ANY (siv.additional_agreement))
WHERE siv.is_actual
AND siv."__deletedAt" IS NULL
AND d."__deletedAt" IS NULL
AND a."__deletedAt" IS NULL
AND s.probability_pc >= 50
--and a.is_actual *** возможно схема версионности противоречива
AND siv.type IN (2, 3)
AND d._companies = <cfqueryparam cfsqltype="cf_sql_other" value=#d.__id#/><!--- '019503f2-5774-7768-b5c9-566a71daedaa' --->
)
,component
AS (
SELECT cnt
,code
,__id
,price
,ed_izm
,discount
,name
FROM elma.service_parametrs
WHERE "__deletedAt" IS NULL
)
,stair
AS (
SELECT *
FROM (
SELECT *
,MIN(dt_from) OVER (
PARTITION BY line_key ORDER BY deal_index DESC
) running_min_dt
,COALESCE((
LEAD(dt_from) OVER (
PARTITION BY line_key ORDER BY dt_from
,deal_index
)
), (
SELECT CURRENT_TIMESTAMP + INTERVAL '1 day'
)) dt_next
FROM line_expanded
WHERE probability_pc > 0
) t
WHERE t.dt_from = t.running_min_dt
--AND ( t.dt_to > CURRENT_TIMESTAMP OR t.dt_to IS NULL )
)
SELECT d.siv_uid::text as siv_uid
,d.siv_index
,d.deal
,d.user_description
,d.discount
,d.cnt
,d.modifier_code
,d.abstractive_service_code
,d.additional_agreement_is_actual
,d.line_pricing_model_id
,d.line_key
,d.deal_index
,d.dt_from
,d.dt_to
,d.dt_next
,d.is_simple
,d.additional_agreement_uid::text as additional_agreement_uid
,d.additional_agreement
,d.deal_index
,d.deal_uid::text as deal_uid
,s.probability_pc
,s.status_id
,s.STATUS
,p.price ,p.price
,p.cnt as p_cnt ,p.cnt as p_cnt
,p.ed_izm ,p.ed_izm
,p.code ,p.code
,p.discount as p_discount ,p.discount as p_discount
,p.__id as p_uid ,p.__id::text as p_uid
,p.name ,p.name
,s.probability_pc FROM stair d
,s.status_id JOIN status s ON (d.deal_status_id = s.status_id)
,s.status LEFT JOIN LATERAL unnest(d.params) AS arr(param_id) ON TRUE
,d.__index as deal_index JOIN component p ON (p.__id = arr.param_id)
,d.__id as deal_uid WHERE d.dt_from <= CURRENT_TIMESTAMP AND (CURRENT_TIMESTAMP < d.dt_next)
from elma.deals_services siv
join elma.deals d on d.__id=ANY(siv.deal)
join status s on (d.__status_status=s.status_id)
join elma.service_parametrs p ON (p.__id = ANY (siv.params) AND p."__deletedAt" IS NULL)
left outer join elma.additional_agreements a on (a.__id=ANY(siv.additional_agreement))
where d._companies=<cfqueryparam cfsqltype="cf_sql_other" value="#d.__id#" null=#!isValid("guid",d.__id)#/>
AND siv.is_actual
--AND a.is_actual
--AND date_nop <= CURRENT_TIMESTAMP
AND COALESCE(date_end,CURRENT_TIMESTAMP) >= CURRENT_TIMESTAMP
AND s.probability_pc >=50
ORDER BY __index --, version::int
</cfquery> </cfquery>
<!--- <cfdump var=#qService#/> --->
<cfoutput> <cfoutput>
<h3>Услуги по данным CRM (версии строк спецификации, только актуальные на сегодня, сделки с вероятностью от 50% (начиная с тестирования) <!--- (#qService.recordCount#) ---></h3> <h3>Услуги по данным CRM (версии строк спецификации, только актуальные на сегодня, сделки с вероятностью от 50% (начиная с тестирования) <!--- (#qService.recordCount#) ---></h3>
</cfoutput> </cfoutput>
@@ -173,6 +240,7 @@
<table class="worktable"> <table class="worktable">
<thead> <thead>
<tr> <tr>
<th width="3%">__index</th> <th width="3%">__index</th>
<th width="5%">Код</th> <th width="5%">Код</th>
<th width="20%">Пользовательское наименование</th> <th width="20%">Пользовательское наименование</th>
@@ -184,13 +252,13 @@
<th width="5%">date_end</th> <th width="5%">date_end</th>
<th width="5%">Вер.%</th> <th width="5%">Вер.%</th>
<th width="10%">Дополнительное соглашение</th> <th width="10%">Дополнительное соглашение</th>
<th width="5%">Ключ строки</th>
</tr> </tr>
</thead> </thead>
<cfoutput query="qService" group="__index"> <cfoutput query="qService" group="siv_uid">
<tr<cfif NOT left(abstractive_service_code,4) EQ "iaas"> class="gray"</cfif>> <tr<cfif NOT left(abstractive_service_code,4) EQ "iaas"> class="gray"</cfif>>
<td class="c"><a href="deal_service.cfm?__id=#__id#&#tr.fwx#" title="__id">#__index#</a></td> <td class="c"><a href="deal_service.cfm?__id=#siv_uid#&#tr.fwx#">#siv_index#</a></td>
<!--- <td class="c">#__name#</td> --->
<td class="l">#abstractive_service_code#<cfif len(modifier_code)>.#modifier_code#</cfif></td> <td class="l">#abstractive_service_code#<cfif len(modifier_code)>.#modifier_code#</cfif></td>
<td class="l">#user_description#</td> <td class="l">#user_description#</td>
<td style="padding:0; vertical-align:bottom;"> <td style="padding:0; vertical-align:bottom;">
@@ -214,20 +282,19 @@
<td class="r">#nFmt(cost*cnt*(100-(isNumeric(discount)?discount:0))/100)#</td> <td class="r">#nFmt(cost*cnt*(100-(isNumeric(discount)?discount:0))/100)#</td>
<td class="c"> <td class="c">
<cfswitch expression=#type#> <cfswitch expression=#line_pricing_model_id#>
<cfcase value=1>install</cfcase> <cfcase value=1>install</cfcase>
<cfcase value=2>fix</cfcase> <cfcase value=2>fix</cfcase>
<cfcase value=3>payg</cfcase> <cfcase value=3>payg</cfcase>
</cfswitch> (#type#) </cfswitch> (#line_pricing_model_id#)
</td> </td>
<!--- <td class="c">#is_actual#</td> <!--- <td class="c">#is_actual#</td>
<td class="c">#hash#</td>
<td class="c">#version#</td>
<td class="c">#__index#</td> ---> <td class="c">#__index#</td> --->
<td class="c">#dateFormat(date_nop,'YYYY-MM-DD')#</td> <td class="c">#dateFormat(dt_from,'YYYY-MM-DD')#</td>
<td class="c<cfif isDate(date_end) AND date_end LT Now()> err</cfif>">#dateFormat(date_end,'YYYY-MM-DD')#</td> <td class="c<cfif isDate(dt_to) AND dt_to LT Now()> err</cfif>">#dateFormat(dt_to,'YYYY-MM-DD')#</td>
<td class="c">#probability_pc#</td> <td class="c">#probability_pc#</td>
<td class="c"><a href="additional_agreement.cfm?__id=#additional_agreement_uid#&#tr.fwx#">#additional_agreement#</a> (#status_id# #status#)</td> <td class="c"><a href="additional_agreement.cfm?__id=#additional_agreement_uid#&#tr.fwx#">#additional_agreement#</a> (#status_id# #status#)</td>
<td class="c">#line_key#</td>
</tr> </tr>
</cfoutput> </cfoutput>
</table> </table>
@@ -330,7 +397,7 @@
<thead> <thead>
<tr> <tr>
<th width="10%">Организация</th> <th width="10%">Организация</th>
<th width="10%">Статус организации</th> <!--- <th width="10%">Статус организации</th> --->
<th width="10%">VDC</th> <th width="10%">VDC</th>
<th width="10%">Кластер</th> <th width="10%">Кластер</th>
<th width="10%">Политика хранения</th> <th width="10%">Политика хранения</th>
@@ -410,4 +477,6 @@
<cfdump var=#qStorage#/> ---> <cfdump var=#qStorage#/> --->
</cfif><!--- len(d.__id) ---> </cfif><!--- len(d.__id) --->
<br/><br/>
добавить реестр GPU и VDC для поиска потеряшек
<layout:page section="footer"/> <layout:page section="footer"/>
+213 -202
View File
@@ -24,234 +24,246 @@ WITH
('Внутреннее согласование',37,10), ('Внутреннее согласование',37,10),
('Проработка решения',4,10) , ('Проработка решения',4,10) ,
('Сбор потребностей',1,0) ('Сбор потребностей',1,0)
), )
line_expanded as ,line
( AS (
SELECT SELECT siv.__id AS siv_uid
siv.__id as siv_uid , ,siv.discount
siv.discount , ,siv.type AS line_pricing_model_id
siv.type as line_pricing_model_id , ,siv.HASH AS line_key
siv.hash as line_key , ,siv.is_actual AS siv_is_actual
siv.is_actual as siv_is_actual , ,siv.version::NUMERIC AS line_version
siv.version::numeric as line_version , ,d.__index AS deal_index
d.__index as deal_index , ,d._companies
d._companies , ,a.INDEX AS agreement_version
a.index as agreement_version , ,siv.date_nop::DATE AS dt_from
siv.date_nop::date as dt_from , ,siv.date_end::DATE AS dt_to
siv.date_end::date as dt_to , ,siv.is_easy AS is_simple
siv.is_easy as is_simple , ,siv.cnt
siv.cnt , ,s.probability_pc
s.probability_pc , ,a.__id AS agreement_uid
a.__id as agreement_uid , ,a.contract_uid
a.contract_uid , ,a.is_actual AS agreement_is_actual
a.is_actual as agreement_is_actual , ,a.deal_uid
a.deal_uid , ,d.__name AS deal
d.__name as deal , ,d.__status_status AS deal_status_id
d.__status_status as deal_status_id , ,siv.user_description
siv.user_description , ,siv.params
unnest(siv.params) as param_id FROM elma.deals_services siv
FROM JOIN elma.deals d ON (d.__id = ANY (siv.deal))
elma.deals_services siv JOIN STATUS s ON (d.__status_status = s.status_id)
JOIN elma.deals d on (d.__id = ANY(siv.deal)) LEFT JOIN elma.additional_agreements a ON (a.__id = ANY (siv.additional_agreement))
JOIN status s on (d.__status_status=s.status_id) WHERE siv.is_actual
LEFT JOIN elma.additional_agreements a on (a.__id = ANY(siv.additional_agreement))
WHERE
siv.is_actual
AND siv."__deletedAt" IS NULL AND siv."__deletedAt" IS NULL
and d."__deletedAt" IS NULL AND d."__deletedAt" IS NULL
and a."__deletedAt" IS NULL AND a."__deletedAt" IS NULL
and s.probability_pc >= 50 AND s.probability_pc >= 50
--and a.is_actual --and a.is_actual
and siv.type IN (2,3) AND siv.type IN (2, 3)
), )
component as ,component
( AS (
SELECT SELECT
-- price*cnt*(100.0-COALESCE(discount,0))/100.0 as cost , -- price*cnt*(100.0-COALESCE(discount,0))/100.0 as cost ,
-- price , -- price ,
cnt , cnt
code , ,code
__id ,__id
FROM FROM elma.service_parametrs
elma.service_parametrs WHERE "__deletedAt" IS NULL
where )
"__deletedAt" IS NULL ,stair
), AS (
stair as SELECT *
( FROM (
select SELECT *
* ,MIN(dt_from) OVER (
FROM PARTITION BY line_key ORDER BY deal_index DESC
( ) running_min_dt
SELECT ,COALESCE((
*, LEAD(dt_from) OVER (
MIN(dt_from) OVER (PARTITION BY line_key ORDER BY deal_index desc) running_min_dt PARTITION BY line_key ORDER BY dt_from
FROM ,deal_index
line_expanded )
--line ), (
WHERE SELECT CURRENT_TIMESTAMP + INTERVAL '1 day'
probability_pc > 0 )) dt_next
FROM line
WHERE probability_pc > 0
) t ) t
WHERE WHERE t.dt_from = t.running_min_dt
t.dt_from = t.running_min_dt AND (
AND ( t.dt_to > CURRENT_TIMESTAMP OR t.dt_to IS NULL ) t.dt_to > CURRENT_TIMESTAMP
), OR t.dt_to IS NULL
alloc as )
( )
select ,line_expanded
c."WZ" as wz , AS (
round(sum(c."VM_RAM_Allocated")) as ram , SELECT line.*
round(sum(CASE WHEN "VM_is_ON" > 0 THEN c."VM_RAM_Allocated" ELSE 0 END)) as ram_on , ,unnest(line.params) AS param_id
round(sum(c."VM_vCPU_count")) as cpu , FROM line
round(sum(CASE WHEN "VM_is_ON" > 0 then c."VM_vCPU_count" ELSE 0 END)) as cpu_on )
from ,alloc
vmreports.compute c AS (
where SELECT c."WZ" AS wz
ts= (select max(ts) from vmreports.compute) ,round(sum(c."VM_RAM_Allocated")) AS ram
group by c."WZ" ,round(sum(CASE WHEN "VM_is_ON" > 0 THEN c."VM_RAM_Allocated" ELSE 0 END)) AS ram_on
), ,round(sum(c."VM_vCPU_count")) AS cpu
disk_alloc as ,round(sum(CASE WHEN "VM_is_ON" > 0 THEN c."VM_vCPU_count" ELSE 0 END)) AS cpu_on
( FROM vmreports.COMPUTE c
select WHERE ts = (
c."WZ" as wz , SELECT max(ts)
round(sum(c."Disk_Allocated")) as disk_alloc FROM vmreports.COMPUTE
from )
vmreports.storage c GROUP BY c."WZ"
where )
ts= (select max(ts) from vmreports.compute) ,disk_alloc
group by AS (
c."WZ" ), SELECT c."WZ" AS wz
sold_ram as ,round(sum(c."Disk_Allocated")) AS disk_alloc
( FROM vmreports.storage c
SELECT WHERE ts = (
z.id_klienta as WZ , SELECT max(ts)
z.__name as client , FROM vmreports.COMPUTE
z.__id as company_uid, )
round(sum(c.cnt*o.cnt)) as quantity , GROUP BY c."WZ"
count(*) as lines , )
STRING_AGG(distinct c.code,', ' order by c.code) as codes ,sold_ram
FROM AS (
stair o SELECT z.id_klienta AS WZ
JOIN elma.companies z on o._companies=z.__id ,z.__name AS client
LEFT JOIN component c on c.__id = o.param_id ,z.__id AS company_uid
,round(sum(c.cnt * o.cnt)) AS quantity
,count(*) AS lines
,STRING_AGG(DISTINCT c.code, ', ' ORDER BY c.code) AS codes
FROM stair o
JOIN elma.companies z ON o._companies = z.__id
--LEFT JOIN component c on (c.__id = ANY (o.params)) --LEFT JOIN component c on (c.__id = ANY (o.params))
LEFT JOIN line_expanded e ON o.siv_uid = e.siv_uid
LEFT JOIN component c ON c.__id = e.param_id
WHERE WHERE
--c.code SIMILAR TO 'iaas.(ngc|dcp).%.ram-_' --c.code SIMILAR TO 'iaas.(ngc|dcp).%.ram-_'
(c.code LIKE 'iaas.ngc.%.ram-_' OR c.code LIKE 'iaas.dcp.%.ram-_') (
c.code LIKE 'iaas.ngc.%.ram-_'
OR c.code LIKE 'iaas.dcp.%.ram-_'
)
AND c.cnt <> 0 AND c.cnt <> 0
AND o.cnt <> 0 AND o.cnt <> 0
GROUP BY GROUP BY z.id_klienta
z.id_klienta, ,z.__id
z.__id , ,z.__name
z.__name )
), ,sold_cpu
sold_cpu as AS (
( SELECT z.id_klienta AS WZ
SELECT ,z.__name AS client
z.id_klienta as WZ , ,z.__id AS company_uid
z.__name as client , ,round(sum(c.cnt * o.cnt)) AS quantity
z.__id as company_uid, ,count(*) AS lines
round(sum(c.cnt*o.cnt)) as quantity , ,STRING_AGG(DISTINCT c.code, ', ' ORDER BY c.code) AS codes
count(*) as lines , FROM stair o
STRING_AGG(distinct c.code,', ' order by c.code) as codes JOIN elma.companies z ON (o._companies = z.__id)
FROM --LEFT JOIN component c ON c.__id = o.param_id
stair o
JOIN
elma.companies z on (o._companies=z.__id)
LEFT JOIN component c on c.__id = o.param_id
--LEFT JOIN component c on (c.__id = ANY (o.params)) --LEFT JOIN component c on (c.__id = ANY (o.params))
LEFT JOIN line_expanded e ON o.siv_uid = e.siv_uid
LEFT JOIN component c ON c.__id = e.param_id
WHERE WHERE
--c.code SIMILAR TO 'iaas.(ngc|dcp).%.vcpu%-_' --c.code SIMILAR TO 'iaas.(ngc|dcp).%.vcpu%-_'
(c.code LIKE 'iaas.ngc.%.vcpu%-_' OR c.code LIKE 'iaas.dcp.%.vcpu%-_') (
c.code LIKE 'iaas.ngc.%.vcpu%-_'
OR c.code LIKE 'iaas.dcp.%.vcpu%-_'
)
AND c.cnt <> 0 AND c.cnt <> 0
AND o.cnt <> 0 AND o.cnt <> 0
GROUP BY GROUP BY z.id_klienta
z.id_klienta, ,z.__id
z.__id , ,z.__name
z.__name )
), ,sold_disk
sold_disk as AS (
( SELECT z.id_klienta AS WZ
SELECT ,z.__name AS client
z.id_klienta as WZ , ,z.__id AS company_uid
z.__name as client , ,round(sum(c.cnt * o.cnt)) AS quantity
z.__id as company_uid, ,count(*) AS lines
round(sum(c.cnt*o.cnt)) as quantity , ,STRING_AGG(DISTINCT c.code, ', ' ORDER BY c.code) AS codes
count(*) as lines , FROM stair o
STRING_AGG(distinct c.code,', ' order by c.code) as codes JOIN elma.companies z ON (o._companies = z.__id)
FROM --LEFT JOIN component c ON c.__id = o.param_id
stair o
JOIN elma.companies z on (o._companies=z.__id)
LEFT JOIN component c on c.__id = o.param_id
--LEFT JOIN component c on (c.__id = ANY (o.params)) --LEFT JOIN component c on (c.__id = ANY (o.params))
LEFT JOIN line_expanded e ON o.siv_uid = e.siv_uid
LEFT JOIN component c ON c.__id = e.param_id
WHERE WHERE
--c.code SIMILAR TO 'iaas.(ngc|dcp).%.(ssd|fstssd|sata)-_' --c.code SIMILAR TO 'iaas.(ngc|dcp).%.(ssd|fstssd|sata)-_'
(c.code LIKE 'iaas.ngc.%.ssd-_' OR c.code LIKE 'iaas.dcp.%.ssd-_' (
or c.code LIKE 'iaas.ngc.%.fstssd-_' OR c.code LIKE 'iaas.dcp.%.fstssd-_' c.code LIKE 'iaas.ngc.%.ssd-_'
or c.code LIKE 'iaas.ngc.%.sata-_' OR c.code LIKE 'iaas.dcp.%.sata-_' OR c.code LIKE 'iaas.dcp.%.ssd-_'
OR c.code LIKE 'iaas.ngc.%.fstssd-_'
OR c.code LIKE 'iaas.dcp.%.fstssd-_'
OR c.code LIKE 'iaas.ngc.%.sata-_'
OR c.code LIKE 'iaas.dcp.%.sata-_'
) )
AND c.cnt <> 0 AND c.cnt <> 0
AND o.cnt <> 0 AND o.cnt <> 0
GROUP BY GROUP BY z.id_klienta
z.id_klienta, ,z.__id
z.__id , ,z.__name
z.__name )
), ,sold_gpu
sold_gpu as AS (
( SELECT z.id_klienta AS WZ
SELECT ,z.__name AS client
z.id_klienta as WZ , ,z.__id AS company_uid
z.__name as client , ,round(sum(c.cnt * o.cnt)) AS quantity
z.__id as company_uid, ,count(*) AS lines
round(sum(c.cnt*o.cnt)) as quantity , ,STRING_AGG(DISTINCT c.code, ', ' ORDER BY c.code) AS codes
count(*) as lines , FROM stair o
STRING_AGG(distinct c.code,', ' order by c.code) as codes JOIN elma.companies z ON (o._companies = z.__id)
FROM --LEFT JOIN component c ON c.__id = o.param_id
stair o --LEFT JOIN component c on (c.__id = ANY (o.params))
JOIN LEFT JOIN line_expanded e ON o.siv_uid = e.siv_uid
elma.companies z on (o._companies=z.__id) LEFT JOIN component c ON c.__id = e.param_id
LEFT JOIN component c on c.__id = o.param_id
WHERE WHERE
--c.code SIMILAR TO 'iaas.(ngc|dcp).%.vcpu%-_' --c.code SIMILAR TO 'iaas.(ngc|dcp).%.vcpu%-_'
(c.code LIKE 'iaas.ngc.%.gpu%-_' OR c.code LIKE 'iaas.dcp.%.gpu%-_') (
c.code LIKE 'iaas.ngc.%.gpu%-_'
OR c.code LIKE 'iaas.dcp.%.gpu%-_'
)
AND c.cnt <> 0 AND c.cnt <> 0
AND o.cnt <> 0 AND o.cnt <> 0
GROUP BY GROUP BY z.id_klienta
z.id_klienta, ,z.__id
z.__id , ,z.__name
z.__name )
), ,gpu_alloc
gpu_alloc as AS (
( SELECT c."ClientID" AS wz
select ,
c."ClientID" as wz , -- json_agg("GPU") as gpu,
-- json_agg("GPU") as gpu, string_agg("GPU"::TEXT || ' ' || "OrgStatus", ', ') AS gpu
string_agg("GPU"::text||' '||"OrgStatus",', ') as gpu, ,count(*) AS gpu_alloc
count(*) as gpu_alloc FROM vmreports.vm_gpu c
from WHERE ts = (
vmreports.vm_gpu c SELECT max(ts)
where FROM vmreports.vm_gpu
ts= (select max(ts) from vmreports.vm_gpu) )
group by GROUP BY c."ClientID"
c."ClientID" ), )
deal_stat as ,deal_stat
( AS (
select SELECT STRING_AGG(DISTINCT deal_status_id::TEXT, ', ' ORDER BY deal_status_id::TEXT) AS status_ids
STRING_AGG(distinct deal_status_id::text,', ' order by deal_status_id::text) as status_ids, ,ARRAY_AGG(DISTINCT deal_status_id ORDER BY deal_status_id) AS ar_status_ids
ARRAY_AGG(distinct deal_status_id order by deal_status_id) as ar_status_ids, ,STRING_AGG(DISTINCT line_pricing_model_id::TEXT, ', ' ORDER BY line_pricing_model_id::TEXT) AS line_pricing_model_ids
STRING_AGG(distinct line_pricing_model_id::text,', ' order by line_pricing_model_id::text) as line_pricing_model_ids , ,ARRAY_AGG(DISTINCT line_pricing_model_id ORDER BY line_pricing_model_id) AS ar_line_pricing_model_id
ARRAY_AGG(distinct line_pricing_model_id order by line_pricing_model_id) as ar_line_pricing_model_id, ,z.id_klienta AS WZ
z.id_klienta as WZ FROM stair d
from --LEFT JOIN LATERAL unnest(d.params) AS arr(param_id) ON TRUE
line_expanded o --JOIN component p ON (p.__id = arr.param_id)
--line o JOIN elma.companies z ON (d._companies = z.__id)
join elma.companies z on (o._companies=z.__id) WHERE d.dt_from <= CURRENT_TIMESTAMP
GROUP BY AND (CURRENT_TIMESTAMP < d.dt_next)
z.id_klienta GROUP BY z.id_klienta
) )
select select
<d:field_set titleMapOut="titleMap" lengthOut="fieldCount"> <d:field_set titleMapOut="titleMap" lengthOut="fieldCount">
<d:field title="WZ Elma">r.wz as wz_sold</d:field> <d:field title="WZ Elma">r.wz as wz_sold</d:field>
@@ -368,7 +380,6 @@ S3 операции и трафик: <b>#dateFormat(qS3OpsTrfAge.dt_load,'YYYY-M
<th width="10%"><layout:column_head name="gpu"/></th> <th width="10%"><layout:column_head name="gpu"/></th>
<!--- <th width="3%"><layout:column_head name="disk_sold"/></th> ---> <!--- <th width="3%"><layout:column_head name="disk_sold"/></th> --->
</layout:grid_head> </layout:grid_head>
</thead> </thead>
+35 -15
View File
@@ -13,7 +13,8 @@
<m:filterparam filter=#filter# param="wz" ftype="string" compare="LIKE%" field="z.id_klienta" default=""/> <m:filterparam filter=#filter# param="wz" ftype="string" compare="LIKE%" field="z.id_klienta" default=""/>
<m:filterparam filter=#filter# param="code" ftype="string" expression="(r.codes like ? OR r.codes like ? OR d.codes like ?)" suffix="%" prefix="%" default=""/> <m:filterparam filter=#filter# param="code" ftype="string" expression="(r.codes like ? OR r.codes like ? OR d.codes like ?)" suffix="%" prefix="%" default=""/>
<!--- <m:filterparam filter=#filter# param="status_id" ftype="numeric" expression="ds.ar_status_ids = ?" suffix="" prefix="" default=""/> ---> <!--- <m:filterparam filter=#filter# param="status_id" ftype="numeric" expression="ds.ar_status_ids = ?" suffix="" prefix="" default=""/> --->
<m:filterparam filter=#filter# param="status_id" ftype="numeric" expression="(?=ANY(ds.ar_status_ids))" suffix="" prefix="" default=""/> <!--- <m:filterparam filter=#filter# param="status_id" ftype="numeric" expression="(?=ANY(ds.ar_status_ids))" suffix="" prefix="" default=""/> --->
<m:filterparam filter=#filter# param="status_id_list" ftype="integer" list="Yes" expression="(ds.ar_status_ids && ARRAY[?])" suffix="" prefix="" default=""/>
<m:filterparam filter=#filter# param="line_pricing_model_id" ftype="numeric" expression="(?=ANY(ds.ar_line_pricing_model_id))" suffix="" prefix="" default=""/> <m:filterparam filter=#filter# param="line_pricing_model_id" ftype="numeric" expression="(?=ANY(ds.ar_line_pricing_model_id))" suffix="" prefix="" default=""/>
</m:filter_settings> </m:filter_settings>
@@ -57,20 +58,39 @@ $(document).ready(function() {
<div class="tr"> <div class="tr">
<div class="th">Статус</div> <div class="th">Статус</div>
<div class="td"> <div class="td">
<select name="status_id">
<option></option>
<option value="1"<cfif status_id EQ 1> selected</cfif>>Сбор потребностей</option>
<option value="4"<cfif status_id EQ 4> selected</cfif>>Проработка решения</option> <!--- *** костыль --->
<option value="5"<cfif status_id EQ 5> selected</cfif>>Договор подписан</option> <cfquery name="qStatus">
<option value=6""<cfif status_id EQ 6> selected</cfif>>Закрыта успешно</option> SELECT * from (
<option value="7"<cfif status_id EQ 7> selected</cfif>>Закрыта неуспешно</option> VALUES
<option value="8"<cfif status_id EQ 8> selected</cfif>>Тестирование</option> --('Закрыта неуспешно',7,0) ,
<option value="10"<cfif status_id EQ 10> selected</cfif>>Отправлено ТКП</option> ('Закрыта успешно',6,100) ,
<option value="12"<cfif status_id EQ 12> selected</cfif>>Договор на согласовании</option> ('Договор подписан',5,100) ,
<option value="15"<cfif status_id EQ 15> selected</cfif>>Договор на подписании</option> ('Договор на подписании',15,90) ,
<option value="37"<cfif status_id EQ 37> selected</cfif>>Внутреннее согласование</option> ('Договор на согласовании',12,70),
</select> ('Тестирование',8,50)
<i>по вхождению в список</i> --('Отправлено ТКП',10,20) ,
--('Внутреннее согласование',37,10),
--('Проработка решения',4,10),
--('Сбор потребностей',1,0)
) as status (status, status_id, probability_pc)
ORDER BY probability_pc, status_id
</cfquery>
<c:combo
query=#qStatus#
combo="status_id_list"
id="status_id"
key="status_id"
displayf="##status## (##status_id##: ##probability_pc##%)"
selected=#status_id_list#
empty=""
multiple="multiple"
size="6"
/>
<i>для выбора нескольких значений используйте CTRL или SHIFT (для диапазона)</i>
</div> </div>
</div> </div>
+114
View File
@@ -0,0 +1,114 @@
with
status(status, status_id, probability_pc) as (VALUES
('Закрыта неуспешно',7,0),('Закрыта успешно',6,100),('Договор подписан',5,100),('Договор на подписании',15,90),('Договор на согласовании',12,70),
('Тестирование',8,50),('Отправлено ТКП',10,20),('Внутреннее согласование',37,10),('Проработка решения',4,10),('Сбор потребностей',1,0)
)
,line_expanded as
(
SELECT
siv.__id as siv_uid ,
siv.discount ,
siv.type as line_pricing_model_id ,
siv.hash as line_key ,
siv.is_actual as siv_is_actual ,
siv.version::numeric as line_version ,
siv.modifier_code ,
siv.abstractive_service_code ,
d.__index as deal_index ,
d._companies ,
a.index as agreement_version ,
siv.date_nop::date as dt_from ,
siv.date_end::date as dt_to ,
siv.is_easy as is_simple ,
siv.cnt ,
s.probability_pc ,
a.__id as additional_agreement_uid ,
a.__name as additional_agreement ,
a.contract_uid ,
a.is_actual as additional_agreement_is_actual ,
a.deal_uid ,
d.__name as deal ,
d.__status_status as deal_status_id ,
siv.user_description
--,unnest(siv.params) as param_id
FROM elma.deals_services siv
JOIN elma.deals d on (d.__id = ANY(siv.deal))
JOIN status s on (d.__status_status=s.status_id)
LEFT JOIN elma.additional_agreements a on (a.__id = ANY(siv.additional_agreement))
WHERE
siv.is_actual
AND siv."__deletedAt" IS NULL
and d."__deletedAt" IS NULL
and a."__deletedAt" IS NULL
and s.probability_pc >= 50
and siv.type IN (2,3)
),
component as
(
SELECT
cnt ,
code ,
__id,
price,
ed_izm,
discount,
name
FROM
elma.service_parametrs
where
"__deletedAt" IS NULL
),
stair as
(
select
*
FROM
(
SELECT
*,
MIN(dt_from) OVER (PARTITION BY line_key ORDER BY deal_index desc) running_min_dt
FROM
line_expanded
WHERE
probability_pc > 0
) t
WHERE
t.dt_from = t.running_min_dt
AND ( t.dt_to > CURRENT_TIMESTAMP OR t.dt_to IS NULL )
)
SELECT
d.siv_uid
,d.deal
,d.user_description
,d.discount
,d.cnt
,d.modifier_code
,d.abstractive_service_code
,d.siv_is_actual --
,d.line_pricing_model_id --
,d.line_key
,d.deal_index --
,d.dt_from --
,d.dt_to --
,d.is_simple --
--,d.params::text
,d.additional_agreement_uid
,d.additional_agreement
/*,p.price
,p.cnt as p_cnt
,p.ed_izm
,p.code
,p.discount as p_discount
,p.__id as p_uid
,p.name*/
,s.probability_pc
,s.status_id
,s.status
,d.deal_index
,d.deal_uid
FROM stair d
--left outer join component p on (d.param_id=p.__id)
JOIN status s on (d.deal_status_id=s.status_id)
where d._companies='019503f2-5774-7768-b5c9-566a71daedaa'
+455
View File
@@ -0,0 +1,455 @@
select * from
(
with
status(status, status_id, probability_pc) as
(
VALUES
('Закрыта неуспешно',7,0) ,
('Закрыта успешно',6,100) ,
('Договор подписан',5,100) ,
('Договор на подписании',15,90) ,
('Договор на согласовании',12,70),
('Тестирование',8,50) ,
('Отправлено ТКП',10,20) ,
('Внутреннее согласование',37,10),
('Проработка решения',4,10) ,
('Сбор потребностей',1,0)
),
line as
(
SELECT
siv.__id as siv_uid ,
siv.discount ,
siv.type as line_pricing_model_id ,
siv.hash as line_key ,
siv.is_actual as siv_is_actual ,
siv.version::numeric as line_version ,
d.__index as deal_index ,
d._companies ,
a.index as agreement_version ,
siv.date_nop::date as dt_from ,
siv.date_end::date as dt_to ,
siv.is_easy as is_simple ,
siv.cnt ,
s.probability_pc ,
a.__id as agreement_uid ,
a.contract_uid ,
a.is_actual as agreement_is_actual ,
a.deal_uid ,
d.__name as deal ,
d.__status_status as deal_status_id ,
siv.user_description ,
siv.params
FROM
elma.deals_services siv
JOIN elma.deals d on (d.__id = ANY(siv.deal))
JOIN status s on (d.__status_status=s.status_id)
LEFT JOIN elma.additional_agreements a on (a.__id = ANY(siv.additional_agreement))
WHERE
siv.is_actual
AND siv."__deletedAt" IS NULL
and d."__deletedAt" IS NULL
and a."__deletedAt" IS NULL
and a.is_actual
and siv.type IN (2,3)
),
component as
(
SELECT
price*cnt*(100.0-COALESCE(discount,0))/100.0 as cost ,
price ,
cnt ,
code ,
__id
FROM
elma.service_parametrs
where
"__deletedAt" IS NULL
),
stair as
(
select
*
FROM
(
SELECT
*,
MIN(dt_from) OVER (PARTITION BY line_key ORDER BY deal_index desc) running_min_dt
FROM
line
WHERE
probability_pc > 0
) t
WHERE
t.dt_from = t.running_min_dt
AND t.dt_to > CURRENT_TIMESTAMP
OR t.dt_to IS NULL
),
alloc as
(
select
c."WZ" as wz ,
round(sum(c."VM_RAM_Allocated")) as ram ,
round(sum(CASE WHEN "VM_is_ON" > 0 THEN c."VM_RAM_Allocated" ELSE 0 END)) as ram_on ,
round(sum(c."VM_vCPU_count")) as cpu ,
round(sum(CASE WHEN "VM_is_ON" > 0 then c."VM_vCPU_count" ELSE 0 END)) as cpu_on
from
vmreports.compute c
where
ts= (select max(ts) from vmreports.compute)
group by c."WZ"
),
disk_alloc as
(
select
c."WZ" as wz ,
round(sum(c."Disk_Allocated")) as disk_alloc
from
vmreports.storage c
where
ts= (select max(ts) from vmreports.compute)
group by
c."WZ"
),
sold_ram as
(
SELECT
z.id_klienta as WZ ,
z.__name as client ,
z.__id as company_uid,
round(sum(c.cnt*o.cnt)) as quantity ,
count(*) as lines ,
STRING_AGG(c.code,', ' order by c.code) as codes
FROM
stair o
JOIN elma.companies z on (o._companies=z.__id)
LEFT JOIN component c on (c.__id = ANY (o.params))
WHERE
c.code SIMILAR TO 'iaas.(ngc|dcp).%.ram-_'
AND c.cnt <> 0
AND o.cnt <> 0
GROUP BY
z.id_klienta,
z.__id ,
z.__name
),
sold_cpu as
(
SELECT
z.id_klienta as WZ ,
z.__name as client ,
z.__id as company_uid,
round(sum(c.cnt*o.cnt)) as quantity ,
count(*) as lines ,
STRING_AGG(c.code,', ' order by c.code) as codes
FROM
stair o
JOIN
elma.companies z on (o._companies=z.__id)
LEFT JOIN component c on (c.__id = ANY (o.params))
WHERE
c.code SIMILAR TO 'iaas.(ngc|dcp).%.vcpu%-_'
AND c.cnt <> 0
AND o.cnt <> 0
GROUP BY
z.id_klienta,
z.__id ,
z.__name
),
sold_disk as
(
SELECT
z.id_klienta as WZ ,
z.__name as client ,
z.__id as company_uid,
round(sum(c.cnt*o.cnt)) as quantity ,
count(*) as lines ,
STRING_AGG(c.code,', ' order by c.code) as codes
FROM
stair o
JOIN elma.companies z on (o._companies=z.__id)
LEFT JOIN component c on (c.__id = ANY (o.params))
WHERE
c.code SIMILAR TO 'iaas.(ngc|dcp).%.(ssd|fstssd|sata)-_'
AND c.cnt <> 0
AND o.cnt <> 0
GROUP BY
z.id_klienta,
z.__id ,
z.__name
),
deal_stat as
(
select
STRING_AGG(distinct deal_status_id::text,', ' order by deal_status_id::text) as status_ids ,
STRING_AGG(distinct line_pricing_model_id::text,', ' order by line_pricing_model_id::text) as line_pricing_model_ids ,
z.id_klienta as WZ
from
line o
join elma.companies z on (o._companies=z.__id)
GROUP BY
z.id_klienta
)
select
r.wz as wz_sold ,
r.client as client_sold ,
r.company_uid ,
a.wz as wz_alloc ,
ds.status_ids ,
ds.line_pricing_model_ids ,
r.codes as ram_codes ,
r.quantity as ram_sold ,
a.ram as ram_alloc ,
a.ram_on as ram_alloc_on ,
c.codes as cpu_codes ,
c.quantity as cpu_sold ,
a.cpu as cpu_alloc ,
a.cpu_on as cpu_alloc_on ,
d.codes as disk_codes ,
d.quantity as disk_sold ,
da.disk_alloc ,
z.__name as alloc_company,
z.__id as alloc_company_uid
from
sold_ram r
join deal_stat ds on (lower(r.wz)=lower(ds.wz))
join sold_cpu c on (lower(r.wz)=lower(c.wz))
left join sold_disk d on (lower(r.wz)=lower(d.wz))
full join alloc a on (lower(r.wz)=lower(a.wz))
left join disk_alloc da on (a.wz=da.wz)
left join elma.companies z on (lower(a.wz)=lower(z.id_klienta))
)
intersect all
select * from
(
WITH
status(status, status_id, probability_pc) as
(
VALUES
('Закрыта неуспешно',7,0) ,
('Закрыта успешно',6,100) ,
('Договор подписан',5,100) ,
('Договор на подписании',15,90) ,
('Договор на согласовании',12,70),
('Тестирование',8,50) ,
('Отправлено ТКП',10,20) ,
('Внутреннее согласование',37,10),
('Проработка решения',4,10) ,
('Сбор потребностей',1,0)
),
line_expanded as
(
SELECT
siv.__id as siv_uid ,
siv.discount ,
siv.type as line_pricing_model_id ,
siv.hash as line_key ,
siv.is_actual as siv_is_actual ,
siv.version::numeric as line_version ,
d.__index as deal_index ,
d._companies ,
a.index as agreement_version ,
siv.date_nop::date as dt_from ,
siv.date_end::date as dt_to ,
siv.is_easy as is_simple ,
siv.cnt ,
s.probability_pc ,
a.__id as agreement_uid ,
a.contract_uid ,
a.is_actual as agreement_is_actual ,
a.deal_uid ,
d.__name as deal ,
d.__status_status as deal_status_id ,
siv.user_description ,
unnest(siv.params) as param_id
FROM
elma.deals_services siv
JOIN elma.deals d on (d.__id = ANY(siv.deal))
JOIN status s on (d.__status_status=s.status_id)
LEFT JOIN elma.additional_agreements a on (a.__id = ANY(siv.additional_agreement))
WHERE
siv.is_actual
AND siv."__deletedAt" IS NULL
and d."__deletedAt" IS NULL
and a."__deletedAt" IS NULL
and a.is_actual
and siv.type IN (2,3)
),
component as
(
SELECT
price*cnt*(100.0-COALESCE(discount,0))/100.0 as cost ,
price ,
cnt ,
code ,
__id
FROM
elma.service_parametrs
where
"__deletedAt" IS NULL
),
stair as
(
select
*
FROM
(
SELECT
*,
MIN(dt_from) OVER (PARTITION BY line_key ORDER BY deal_index desc) running_min_dt
FROM
line_expanded
--line
WHERE
probability_pc > 0
) t
WHERE
t.dt_from = t.running_min_dt
AND t.dt_to > CURRENT_TIMESTAMP
OR t.dt_to IS NULL
),
alloc as
(
select
c."WZ" as wz ,
round(sum(c."VM_RAM_Allocated")) as ram ,
round(sum(CASE WHEN "VM_is_ON" > 0 THEN c."VM_RAM_Allocated" ELSE 0 END)) as ram_on ,
round(sum(c."VM_vCPU_count")) as cpu ,
round(sum(CASE WHEN "VM_is_ON" > 0 then c."VM_vCPU_count" ELSE 0 END)) as cpu_on
from
vmreports.compute c
where
ts= (select max(ts) from vmreports.compute)
group by c."WZ"
),
disk_alloc as
(
select
c."WZ" as wz ,
round(sum(c."Disk_Allocated")) as disk_alloc
from
vmreports.storage c
where
ts= (select max(ts) from vmreports.compute)
group by
c."WZ" ),
sold_ram as
(
SELECT
z.id_klienta as WZ ,
z.__name as client ,
z.__id as company_uid,
round(sum(c.cnt*o.cnt)) as quantity ,
count(*) as lines ,
STRING_AGG(c.code,', ' order by c.code) as codes
FROM
stair o
JOIN elma.companies z on o._companies=z.__id
LEFT JOIN component c on c.__id = o.param_id
--LEFT JOIN component c on (c.__id = ANY (o.params))
WHERE
--c.code SIMILAR TO 'iaas.(ngc|dcp).%.ram-_'
(c.code LIKE 'iaas.ngc.%.ram-_' OR c.code LIKE 'iaas.dcp.%.ram-_')
AND c.cnt <> 0
AND o.cnt <> 0
GROUP BY
z.id_klienta,
z.__id ,
z.__name
),
sold_cpu as
(
SELECT
z.id_klienta as WZ ,
z.__name as client ,
z.__id as company_uid,
round(sum(c.cnt*o.cnt)) as quantity ,
count(*) as lines ,
STRING_AGG(c.code,', ' order by c.code) as codes
FROM
stair o
JOIN
elma.companies z on (o._companies=z.__id)
LEFT JOIN component c on c.__id = o.param_id
--LEFT JOIN component c on (c.__id = ANY (o.params))
WHERE
--c.code SIMILAR TO 'iaas.(ngc|dcp).%.vcpu%-_'
(c.code LIKE 'iaas.ngc.%.vcpu%-_' OR c.code LIKE 'iaas.dcp.%.vcpu%-_')
AND c.cnt <> 0
AND o.cnt <> 0
GROUP BY
z.id_klienta,
z.__id ,
z.__name
),
sold_disk as
(
SELECT
z.id_klienta as WZ ,
z.__name as client ,
z.__id as company_uid,
round(sum(c.cnt*o.cnt)) as quantity ,
count(*) as lines ,
STRING_AGG(c.code,', ' order by c.code) as codes
FROM
stair o
JOIN elma.companies z on (o._companies=z.__id)
LEFT JOIN component c on c.__id = o.param_id
--LEFT JOIN component c on (c.__id = ANY (o.params))
WHERE
--c.code SIMILAR TO 'iaas.(ngc|dcp).%.(ssd|fstssd|sata)-_'
(c.code LIKE 'iaas.ngc.%.ssd-_' OR c.code LIKE 'iaas.dcp.%.ssd-_'
or c.code LIKE 'iaas.ngc.%.fstssd-_' OR c.code LIKE 'iaas.dcp.%.fstssd-_'
or c.code LIKE 'iaas.ngc.%.sata-_' OR c.code LIKE 'iaas.dcp.%.sata-_'
)
AND c.cnt <> 0
AND o.cnt <> 0
GROUP BY
z.id_klienta,
z.__id ,
z.__name
),
deal_stat as
(
select
STRING_AGG(distinct deal_status_id::text,', ' order by deal_status_id::text) as status_ids ,
STRING_AGG(distinct line_pricing_model_id::text,', ' order by line_pricing_model_id::text) as line_pricing_model_ids ,
z.id_klienta as WZ
from
line_expanded o
--line o
join elma.companies z on (o._companies=z.__id)
GROUP BY
z.id_klienta
)
select
r.wz as wz_sold ,
r.client as client_sold ,
r.company_uid ,
a.wz as wz_alloc ,
ds.status_ids ,
ds.line_pricing_model_ids ,
r.codes as ram_codes ,
r.quantity as ram_sold ,
a.ram as ram_alloc ,
a.ram_on as ram_alloc_on ,
c.codes as cpu_codes ,
c.quantity as cpu_sold ,
a.cpu as cpu_alloc ,
a.cpu_on as cpu_alloc_on ,
d.codes as disk_codes ,
d.quantity as disk_sold ,
da.disk_alloc ,
z.__name as alloc_company,
z.__id as alloc_company_uid
from
sold_ram r
join deal_stat ds on (lower(r.wz)=lower(ds.wz))
join sold_cpu c on (lower(r.wz)=lower(c.wz))
left join sold_disk d on (lower(r.wz)=lower(d.wz))
full join alloc a on (lower(r.wz)=lower(a.wz))
left join disk_alloc da on (a.wz=da.wz)
left join elma.companies z on (lower(a.wz)=lower(z.id_klienta))
)
+164
View File
@@ -0,0 +1,164 @@
<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:prepare_ls entity="crm2cloud" accessObject="" pageInfoOut="pageInfo" trackOut="tr"/>
<cfquery name="qVM" cachedWithin=#createTimeSpan(0, 0, 25, 0)#>
select "Name", "Object_UUID", "UUID_VM",
"VDC", "Organization_UUID", "Organization", "WZ", "Cluster", "Host",
"Host_Model", "CPU_Model", "Host_CPU_Cores", "Host_CPU_Sockets", "Host_CPU_Speed", "Host_RAM",
"Host_CPU_Used", "Host_CPU_Used_Avg",
"VDC_CPU_Reserv", "VDC_CPU_Speed",
"VM_vCPU_count", "VM_CPU_Used", "VM_CPU_Used_AVG", "VM_CPU_Reserv_GHz", "VM_CPU_Reserv_perc",
"VM_RAM_Allocated", "VM_RAM_Used",
"VM_is_ON",
k.__id as company_uid
from vmreports.compute c
left outer join elma.companies k ON (lower(k.id_klienta)=lower(c."WZ"))
where c.ts=(select max(ts) from vmreports.compute)
--order by "WZ"
</cfquery>
<!--- <cfdump var=#qVM# abort=true/> --->
<cfif isDefined("output_xls")>
<layout:xml qRead=#qCharge# titleMap=#titleMap# filename="#pageInfo.entity#.xml"/>
<cfabort/>
</cfif><cfif isDefined("output_json")>
<layout:json qRead=#qCharge# titleMap=#titleMap# filename="#pageInfo.entity#.json"/>
<cfabort/>
</cfif><!---
---><layout:page section="header" pageInfo=#pageInfo#>
<layout:attribute name="title">
<cfoutput><b>Сверка CRM - Cloud</b></cfoutput>
</layout:attribute>
<layout:attribute name="controls">
<!---skip filter link, filter is not implemented--->
<!---<layout:language_switch/>--->
</layout:attribute>
</layout:page>
<!--- <cfdump var=#qReconciliation# abort=true/> --->
<cfoutput>
<!--- <form method="post" action="">
Период с <input type="text" name="dt_start" value="#dateFormat(dt_start,'YYYY-MM-DD')#"/>
по <input type="text" name="dt_finish" value="#dateFormat(dt_finish,'YYYY-MM-DD')#"/>
<input type="submit" style="cursor:pointer;"/>
<input type="submit" name="DEBUG" value="DEBUG" style="cursor:pointer;"/>
</form> --->
<!--- Часов в периоде: <b>#hours#</b> Строк в отчете: <b>#qCharge.recordCount#</b><br/>
Актуальность данных:
VCD Computing: <b>#dateFormat(qComputingAge.dt_load,'YYYY-MM-DD')# #timeFormat(qComputingAge.dt_load,'HH:MM:SS')#</b>
VCD Storage: <b>#dateFormat(qStorageAge.dt_load,'YYYY-MM-DD')# #timeFormat(qStorageAge.dt_load,'HH:MM:SS')#</b>
S3 хранение: <b>#dateFormat(qS3VolAge.dt_load,'YYYY-MM-DD')# #timeFormat(qS3VolAge.dt_load,'HH:MM:SS')#</b>
S3 операции и трафик: <b>#dateFormat(qS3OpsTrfAge.dt_load,'YYYY-MM-DD')# #timeFormat(qS3OpsTrfAge.dt_load,'HH:MM:SS')#</b>
--->
<br/>
<a href="#request.thisPage#?output_xls" title="экспорт в Excel" style="margin-left:.5em; height:100%;" target="_blank"><img src="img/xls.gif" style="vertical-align:text-bottom;"/></a>
<a href="#request.thisPage#?output_json" title="экспорт в json" style="margin-left:.5em; height:100%;" target="_blank"><img src="img/json.svg" style="vertical-align:text-bottom;" width="13" height="13"/></a>
</cfoutput>
<cfoutput><b>#qVM.recordCount#</b></cfoutput>
<table class="worktable">
<thead>
<tr>
<th width="5%">WZ</th>
<th width="5%">Имя</th>
<th width="5%">Уникальное имя</th>
<th width="3%">Organization</th>
<th width="3%">VDC</th>
<th width="3%">VDC CPU Reserv</th>
<th width="3%">VDC CPU Speed GHz</th>
<th width="3%">Cluster</th>
<th width="3%">Host</th>
<th width="7%">Host Model</th>
<th width="7%">CPU Model</th>
<th width="3%">Host CPU Cores</th>
<th width="3%">Host CPU Sockets</th>
<th width="3%">Host CPU Speed GHz</th>
<th width="3%">Host RAM GB</th>
<th width="3%">Host CPU Used</th>
<th width="3%">Host CPU Used_Avg</th>
<th width="3%">VM vCPU count</th>
<th width="3%">VM CPU Used</th>
<th width="3%">VM CPU Used AVG</th>
<th width="3%">VM CPU Reserv GHz</th>
<th width="3%">VM CPU Reserv perc</th>
<th width="3%">VM RAM Allocated GB</th>
<th width="3%">VM RAM Used GB</th>
<th width="3%">VM is ON</th>
</tr>
</thead>
<cfoutput query="qVM">
<tr>
<td><a href="contragent.cfm?__id=#company_uid#&#tr.fwx#">#WZ#</a><a href="contragent_rpt.cfm?__id=#company_uid#&#tr.fwx#" style="float:right"><img src="img/view.gif" title="сводка по контрагенту"/></a></td>
<td>#Name#</td>
<td>#UUID_VM#</td>
<td>#Organization#</td>
<td>#VDC#</td>
<td><cftry>#round(VDC_CPU_Reserv,3)#<cfcatch></cfcatch></cftry></td>
<td><cftry>#round(VDC_CPU_Speed,3)#<cfcatch></cfcatch></cftry></td>
<td>#qVM.Cluster#</td>
<td>#Host#</td>
<td>#Host_Model#</td>
<td>#CPU_Model#</td>
<td>#Host_CPU_Cores#</td>
<td>#Host_CPU_Sockets#</td>
<td>#round(Host_CPU_Speed,3)#</td>
<td>#round(Host_RAM)#</td>
<td><cftry>#round(Host_CPU_Used,1)#<cfcatch></cfcatch></cftry></td>
<td><cftry>#round(Host_CPU_Used_Avg,1)#<cfcatch></cfcatch></cftry></td>
<td>#VM_vCPU_count#</td>
<td><cftry>#round(VM_CPU_Used,1)#<cfcatch></cfcatch></cftry></td>
<td><cftry>#round(VM_CPU_Used_AVG,1)#<cfcatch></cfcatch></cftry></td>
<td><cftry>#round(VM_CPU_Reserv_GHz,1)#<cfcatch></cfcatch></cftry></td>
<td>#VM_CPU_Reserv_perc#</td>
<td>#VM_RAM_Allocated#</td>
<td><cftry>#round(VM_RAM_Used)#<cfcatch></cfcatch></cftry></td>
<td>#VM_is_ON#</td>
<!--- <td><a href="contragent.cfm?__id=#company_uid#&#tr.fwx#">#client_sold#</a></td> --->
</tr>
</cfoutput>
</table>
<!--- <cfdump var=#qCharge#/> --->
<layout:page section="footer"/>
+4
View File
@@ -1,5 +1,6 @@
<!--- version 2.01---><!---15:25 31.01.2019---> <!--- version 2.01---><!---15:25 31.01.2019--->
<!--- version 2.02---><!---2025-08-04 15:19:34 postgre specific ilike instead of like---> <!--- version 2.02---><!---2025-08-04 15:19:34 postgre specific ilike instead of like--->
<!--- version 2.03---><!---2026-04-27 ftype=integer support--->
<!--- build query filter string ---> <!--- build query filter string --->
<!--- пустые и некорректные значения параметров вызвыают пропуск параметра ---> <!--- пустые и некорректные значения параметров вызвыают пропуск параметра --->
<cfparam name="ATTRIBUTES.filter" type="struct"/> <cfparam name="ATTRIBUTES.filter" type="struct"/>
@@ -34,6 +35,9 @@
<cfcase value="numeric"> <cfcase value="numeric">
<cfreturn "CF_SQL_NUMERIC"/> <cfreturn "CF_SQL_NUMERIC"/>
</cfcase> </cfcase>
<cfcase value="integer">
<cfreturn "CF_SQL_INTEGER"/>
</cfcase>
<cfcase value="date,time,datetime"> <cfcase value="date,time,datetime">
<cfreturn "CF_SQL_TIMESTAMP"/> <cfreturn "CF_SQL_TIMESTAMP"/>
</cfcase> </cfcase>
+8
View File
@@ -1,6 +1,7 @@
<!--- version 2.01---><!---15:25 31.01.2019---> <!--- version 2.01---><!---15:25 31.01.2019--->
<!--- 2017.06.16 исправлен баг с очисткой при числовом значении по умолчанию ---> <!--- 2017.06.16 исправлен баг с очисткой при числовом значении по умолчанию --->
<!---v0.5 10:02 02.01.2019---> <!---v0.5 10:02 02.01.2019--->
<!---v0.6 2026-04-27 integer type support --->
<cfassociate basetag="cf_filter_settings"/> <cfassociate basetag="cf_filter_settings"/>
<cfparam name="ATTRIBUTES.filter" type="struct" default=#getBaseTagData("CF_FILTER_SETTINGS",1).filter#/><!--- *** possible Railo bug, getBaseTagData works only with second parameter ---> <cfparam name="ATTRIBUTES.filter" type="struct" default=#getBaseTagData("CF_FILTER_SETTINGS",1).filter#/><!--- *** possible Railo bug, getBaseTagData works only with second parameter --->
<cfparam name="ATTRIBUTES.param" type="string"/> <cfparam name="ATTRIBUTES.param" type="string"/>
@@ -74,6 +75,13 @@ arrayAppend(array,item) механически заменил на listAppend(li
</cfif> </cfif>
</cfcase> </cfcase>
<cfcase value="integer">
<cfset element=trim(element)>
<cfif NOT isValid("integer", element)>
<cfset element=def/>
</cfif>
</cfcase>
<cfcase value="guid"> <cfcase value="guid">
<cfset element=trim(element)> <cfset element=trim(element)>
<cfif NOT isValid('guid',element)> <cfif NOT isValid('guid',element)>