43 speed and filter and totals
This commit is contained in:
+1
-1
@@ -76,7 +76,7 @@
|
||||
<!--- global settings --->
|
||||
|
||||
<cfset request.RECORDS_PER_PAGE=500/>
|
||||
<cfset request.APP_VERSION="0.00.042"/>
|
||||
<cfset request.APP_VERSION="0.00.043"/>
|
||||
<cfset request.STAND=getStand()/>
|
||||
|
||||
<cflock scope="application" type="readonly" timeout=3>
|
||||
|
||||
+31
-32
@@ -15,7 +15,7 @@
|
||||
|
||||
<cfquery name="qRead">
|
||||
with
|
||||
capacity as (
|
||||
<!--- capacity as (
|
||||
select "Cluster" as cluster, count(*) as hosts, sum(cores) as cores, round(sum(ghz)::numeric,1) as ghz, round(sum(ram)) as ram
|
||||
from (
|
||||
select "Cluster", "Host"
|
||||
@@ -25,7 +25,7 @@ from (
|
||||
group by "Cluster","Host"
|
||||
order by "Cluster","Host"
|
||||
) host
|
||||
group by "Cluster"),
|
||||
group by "Cluster"), --->
|
||||
|
||||
usage as (
|
||||
select "Cluster" as cluster
|
||||
@@ -55,6 +55,8 @@ SELECT
|
||||
,sum("CPU_Cores") as cores
|
||||
,sum(CASE WHEN "Maintenance"='notInMaintenance' THEN "CPU_Cores" ELSE 0 END) as cores_in_service
|
||||
,sum(CASE WHEN "Maintenance"='notInMaintenance' THEN "CPU_Cores"*"CPU_Speed" ELSE 0 END) as ghz_in_service
|
||||
,sum(CASE WHEN "Maintenance"='notInMaintenance' THEN "CPUtoVM" ELSE 0 END) as ghz_provisioned
|
||||
,sum(CASE WHEN "Maintenance"='notInMaintenance' THEN "RAMtoVM" ELSE 0 END) as gb_provisioned
|
||||
,sum("CPU_Used_AVG") as host_ghz_usage
|
||||
,(sum(CASE WHEN "Maintenance"='notInMaintenance' THEN "RAM_Total" ELSE 0 END)) as ram_in_service
|
||||
,(avg(CASE WHEN "Maintenance"='notInMaintenance' THEN "CPU_Speed" ELSE 0 END)) as ghz
|
||||
@@ -102,25 +104,26 @@ select
|
||||
<d:field title="CPU GHz">h.ghz</d:field>
|
||||
<d:field title="RAM GB in service">h.ram_in_service</d:field>
|
||||
<d:field title="Host CPU usage %">h.cpu_usage_perc</d:field>
|
||||
<d:field title="Hosts in use">c.hosts</d:field>
|
||||
<d:field title="Cores Capacity">c.cores as Cores_Capacity</d:field>
|
||||
<d:field title="GHz Capacity">c.ghz as GHz_Capacity</d:field>
|
||||
<!--- <d:field title="Hosts in use">h.hosts</d:field> --->
|
||||
<d:field title="Cores Capacity">h.cores as Cores_Capacity</d:field>
|
||||
<!--- <d:field title="GHz Capacity">c.ghz as GHz_Capacity</d:field> --->
|
||||
<d:field title="GHz Provisioned">h.ghz_provisioned as GHz_Provisioned</d:field><!--- за вычетом согласованных резервов --->
|
||||
<d:field title="GB Provisioned">h.gb_provisioned as GB_Provisioned</d:field><!--- за вычетом согласованных резервов --->
|
||||
<d:field title="VM GHz reserved">u.vm_ghz_reserved</d:field>
|
||||
<d:field title="VM GHz обещанные">u.vm_ghz_promised</d:field>
|
||||
<d:field title="CPU GHz provision rate %">round((u.vm_ghz_promised/c.ghz)::numeric,2)*100 as GHz_provision_rate</d:field>
|
||||
<d:field title="RAM GB Capacity">c.ram as RAM_Capacity</d:field>
|
||||
<d:field title="CPU GHz provision rate %">round((u.vm_ghz_promised/h.ghz_provisioned)::numeric,2)*100 as GHz_provision_rate</d:field>
|
||||
<!--- <d:field title="RAM GB Capacity">h.ram as RAM_Capacity</d:field> --->
|
||||
<d:field title="VM RAM GB alloc">u.vm_ram_alloc</d:field>
|
||||
<d:field title="VM RAM GB used">u.vm_ram_used</d:field>
|
||||
<d:field title="RAM alloc %">round((u.vm_ram_alloc/c.ram)::numeric,2)*100 as GB_alloc_perc</d:field>
|
||||
<d:field title="RAM usage %">round((u.vm_ram_used/c.ram)::numeric,2)*100 as GB_usage_perc</d:field>
|
||||
<d:field title="Пере подписка vCPU">round((u.vm_cores/c.cores)::numeric,1) as oversubscription</d:field>
|
||||
<d:field title="RAM alloc %">round((u.vm_ram_alloc/h.gb_provisioned)::numeric,2)*100 as GB_alloc_perc</d:field>
|
||||
<d:field title="RAM usage %">round((u.vm_ram_used/h.gb_provisioned)::numeric,2)*100 as GB_usage_perc</d:field>
|
||||
<d:field title="Пере подписка vCPU">round((u.vm_cores/h.cores)::numeric,1) as oversubscription</d:field>
|
||||
<d:field title="VM cores">u.vm_cores</d:field>
|
||||
<d:field title="VM">u.vms</d:field>
|
||||
<d:field title="VM CPU Usage %">u.vm_ghz_usage/h.ghz_in_service*100 as vm_cpu_usage_perc</d:field>
|
||||
</d:field_set>
|
||||
from cluster_stat h
|
||||
left outer join usage u on (h.cluster=u.cluster)
|
||||
left outer join capacity c on (h.cluster=c.cluster)
|
||||
left outer join cluster_naming n on (h.cluster=n.cluster)
|
||||
where 1=1 <!--- <m:filter_build filter=#pageInfo.settings.filter#/> --->
|
||||
order by <m:order_build sortArray=#pageInfo.settings.sort.sortArray# fieldCount=#fieldCount#/>
|
||||
@@ -131,13 +134,12 @@ select
|
||||
sum(hosts_total) as hosts_total
|
||||
,sum(hosts_ha) as hosts_ha
|
||||
,sum(hosts_in_maintenance) as hosts_in_maintenance
|
||||
,sum(hosts) as hosts
|
||||
,sum(host_ghz_usage) as host_ghz_usage
|
||||
,sum(cores_in_service) as cores_in_service
|
||||
,sum(ghz_in_service) as ghz_in_service
|
||||
,sum(GHz_Capacity) as GHz_Capacity
|
||||
,sum(ghz_provisioned) as ghz_provisioned
|
||||
,sum(ram_in_service) as ram_in_service
|
||||
,sum(RAM_Capacity) as RAM_Capacity
|
||||
,sum(gb_provisioned) as gb_provisioned
|
||||
,sum(cores_in_service) as cores_in_service
|
||||
,sum(vm_cores) as vm_cores
|
||||
,sum(vm_ghz_usage) as vm_ghz_usage
|
||||
@@ -208,17 +210,17 @@ from qRead
|
||||
<!--- <td class="r" style="font-size:120%">#numberFormat(ghz,".0")#</td> --->
|
||||
<td class="r">#hosts_total#</td>
|
||||
|
||||
<td class="r<cfif RAM_Capacity-vm_ram_alloc LE 0> err</cfif>" style="font-size:130%">#numberFormat(RAM_Capacity-vm_ram_alloc,"0")#</td>
|
||||
<td class="r<cfif gb_provisioned-vm_ram_alloc LE 0> err</cfif>" style="font-size:130%">#numberFormat(gb_provisioned-vm_ram_alloc,"0")#</td>
|
||||
|
||||
<td class="r<cfif GHz_Capacity-vm_ghz_reserved LE 0> err</cfif>" style="font-size:130%">#numberFormat(GHz_Capacity-vm_ghz_reserved,".0")#</td>
|
||||
<td class="r<cfif GHz_Capacity-vm_ghz_reserved LE 0> err</cfif>" style="font-size:130%">#numberFormat((GHz_Capacity-vm_ghz_reserved)/ghz/0.2,"0")#</td>
|
||||
<td class="r<cfif GHz_Capacity-vm_ghz_reserved LE 0> err</cfif>" style="font-size:130%">#numberFormat((GHz_Capacity-vm_ghz_reserved)/ghz/0.5,"0")#</td>
|
||||
<td class="r<cfif GHz_Capacity-vm_ghz_reserved LE 0> err</cfif>" style="font-size:130%">#numberFormat((GHz_Capacity-vm_ghz_reserved)/ghz/0.8,"0")#</td>
|
||||
<td class="r<cfif ghz_provisioned-vm_ghz_reserved LE 0> err</cfif>" style="font-size:130%">#numberFormat(ghz_provisioned-vm_ghz_reserved,".0")#</td>
|
||||
<td class="r<cfif ghz_provisioned-vm_ghz_reserved LE 0> err</cfif>" style="font-size:130%">#numberFormat((ghz_provisioned-vm_ghz_reserved)/ghz/0.2,"0")#</td>
|
||||
<td class="r<cfif ghz_provisioned-vm_ghz_reserved LE 0> err</cfif>" style="font-size:130%">#numberFormat((ghz_provisioned-vm_ghz_reserved)/ghz/0.5,"0")#</td>
|
||||
<td class="r<cfif ghz_provisioned-vm_ghz_reserved LE 0> err</cfif>" style="font-size:130%">#numberFormat((ghz_provisioned-vm_ghz_reserved)/ghz/0.8,"0")#</td>
|
||||
|
||||
<td class="r<cfif GHz_Capacity-vm_ghz_promised LE 0> err</cfif>" style="font-size:130%">#numberFormat(GHz_Capacity-vm_ghz_promised,".0")#</td>
|
||||
<td class="r<cfif GHz_Capacity-vm_ghz_promised LE 0> err</cfif>" style="font-size:130%">#numberFormat((GHz_Capacity-vm_ghz_promised)/ghz/0.2,"0")#</td>
|
||||
<td class="r<cfif GHz_Capacity-vm_ghz_promised LE 0> err</cfif>" style="font-size:130%">#numberFormat((GHz_Capacity-vm_ghz_promised)/ghz/0.5,"0")#</td>
|
||||
<td class="r<cfif GHz_Capacity-vm_ghz_promised LE 0> err</cfif>" style="font-size:130%">#numberFormat((GHz_Capacity-vm_ghz_promised)/ghz/0.8,"0")#</td>
|
||||
<td class="r<cfif ghz_provisioned-vm_ghz_promised LE 0> err</cfif>" style="font-size:130%">#numberFormat(ghz_provisioned-vm_ghz_promised,".0")#</td>
|
||||
<td class="r<cfif ghz_provisioned-vm_ghz_promised LE 0> err</cfif>" style="font-size:130%">#numberFormat((ghz_provisioned-vm_ghz_promised)/ghz/0.2,"0")#</td>
|
||||
<td class="r<cfif ghz_provisioned-vm_ghz_promised LE 0> err</cfif>" style="font-size:130%">#numberFormat((ghz_provisioned-vm_ghz_promised)/ghz/0.5,"0")#</td>
|
||||
<td class="r<cfif ghz_provisioned-vm_ghz_promised LE 0> err</cfif>" style="font-size:130%">#numberFormat((ghz_provisioned-vm_ghz_promised)/ghz/0.8,"0")#</td>
|
||||
|
||||
<td class="r">#vms#</td>
|
||||
|
||||
@@ -248,7 +250,6 @@ from qRead
|
||||
<th width="3%"><layout:column_head name="hosts_total"/></th>
|
||||
<th width="3%"><layout:column_head name="hosts_ha"/></th>
|
||||
<th width="3%"><layout:column_head name="hosts_in_maintenance"/></th>
|
||||
<th width="3%"><layout:column_head name="hosts"/></th>
|
||||
<!--- <th width="3%"><layout:column_head name="hosts_in_service"/></th>
|
||||
<th width="3%"><layout:column_head name="ram_in_service"/></th>
|
||||
<th width="3%"><layout:column_head name="cores_in_service"/></th>
|
||||
@@ -259,12 +260,12 @@ from qRead
|
||||
<th width="3%"><layout:column_head name="vm_cpu_usage_perc"/></th>
|
||||
<th width="3%"><layout:column_head name="oversubscription"/></th>
|
||||
<th width="3%"><layout:column_head name="Cores_Capacity"/></th>
|
||||
<th width="3%"><layout:column_head name="GHz_Capacity"/></th>
|
||||
<th width="3%"><layout:column_head name="ghz_provisioned"/></th>
|
||||
<th width="3%"><layout:column_head name="vm_ghz_reserved"/></th>
|
||||
<th width="3%"><layout:column_head name="vm_ghz_promised"/></th>
|
||||
<th width="3%"><layout:column_head name="vm_cores"/></th>
|
||||
<th width="3%"><layout:column_head name="GHz_provision_rate"/></th>
|
||||
<th width="3%"><layout:column_head name="RAM_Capacity"/></th>
|
||||
<th width="3%"><layout:column_head name="gb_provisioned"/></th>
|
||||
<th width="3%"><layout:column_head name="vm_ram_alloc"/></th>
|
||||
<th width="3%"><layout:column_head name="vm_ram_used"/></th>
|
||||
<th width="3%"><layout:column_head name="GB_alloc_perc"/></th>
|
||||
@@ -284,7 +285,6 @@ from qRead
|
||||
<td class="r">#hosts_total#</td>
|
||||
<td class="r">#hosts_ha#</td>
|
||||
<td class="r"><cfif hosts_in_maintenance NEQ 0>#hosts_in_maintenance#</cfif></td> <!--- style="background:lightcoral" --->
|
||||
<td class="r">#hosts#</td>
|
||||
<!--- <td class="r">#hosts_in_service#</td>
|
||||
<td class="r">#numberFormat(ram_in_service,"0")#</td>
|
||||
<td class="r">#cores_in_service#</td>
|
||||
@@ -295,12 +295,12 @@ from qRead
|
||||
<td class="c" style="font-size:130%;">#numberFormat(vm_cpu_usage_perc,"0")#</td>
|
||||
<td class="r">#oversubscription#</td>
|
||||
<td class="r">#Cores_Capacity#</td>
|
||||
<td class="r">#numberFormat(GHz_Capacity,".0")#</td>
|
||||
<td class="r">#numberFormat(ghz_provisioned,".0")#</td>
|
||||
<td class="r">#numberFormat(vm_ghz_reserved,".0")#</td>
|
||||
<td class="r">#numberFormat(vm_ghz_promised,".0")#</td>
|
||||
<td class="r">#vm_cores#</td>
|
||||
<td class="r">#numberFormat(GHz_provision_rate,"0")#</td>
|
||||
<td class="r">#numberFormat(RAM_Capacity,"0")#</td>
|
||||
<td class="r">#numberFormat(gb_provisioned,"0")#</td>
|
||||
<td class="r">#numberFormat(vm_ram_alloc,"0")#</td>
|
||||
<td class="r">#numberFormat(vm_ram_used,"0")#</td>
|
||||
<td class="r">#numberFormat(GB_alloc_perc,"0")#</td>
|
||||
@@ -316,7 +316,6 @@ from qRead
|
||||
<td class="r">#hosts_total#</td>
|
||||
<td class="r">#hosts_ha#</td>
|
||||
<td class="r">#hosts_in_maintenance#</td>
|
||||
<td class="r">#hosts#</td>
|
||||
<!--- <td class="r"></td>
|
||||
<td class="r">#numberFormat(ram_in_service,"0")#</td>
|
||||
<td class="r">#cores_in_service#</td>
|
||||
@@ -327,12 +326,12 @@ from qRead
|
||||
<td class="r"><!--- #cpu_usage_perc# ---></td>
|
||||
<td class="r" style="font-size:130%;">#numberFormat(vm_cores/cores_in_service,".0")#</td>
|
||||
<td class="r"></td>
|
||||
<td class="r">#numberFormat(GHz_Capacity,".0")#</td>
|
||||
<td class="r">#numberFormat(ghz_provisioned,".0")#</td>
|
||||
<td class="r">#numberFormat(vm_ghz_reserved,".0")#</td>
|
||||
<td class="r">#numberFormat(vm_ghz_promised,".0")#</td>
|
||||
<td class="r">#vm_cores#</td>
|
||||
<td class="r"></td>
|
||||
<td class="r">#numberFormat(RAM_Capacity,"0")#</td>
|
||||
<td class="r">#numberFormat(gb_provisioned,"0")#</td>
|
||||
<td class="r">#numberFormat(vm_ram_alloc,"0")#</td>
|
||||
<td class="r">#numberFormat(vm_ram_used,"0")#</td>
|
||||
<td class="r" style="font-size:130%;">#numberFormat(vm_ram_alloc/ram_in_service*100,"0")#</td>
|
||||
|
||||
+229
-126
@@ -8,110 +8,212 @@
|
||||
<m:prepare_ls entity="crm2cloud" settingsKey="crm2cloud" accessObject="" pageInfoOut="pageInfo" trackOut="tr"/>
|
||||
|
||||
<!--- *** нуждается в оптимизации, чтобы фильтр по контрагенту ускорял селект --->
|
||||
|
||||
<cfquery name="qRead" cachedWithin=#createTimeSpan(0, 0, 25, 0)#>
|
||||
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 -- should mutiliply
|
||||
,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
|
||||
--,c.__name as contract
|
||||
,siv.user_description
|
||||
,siv.params
|
||||
--,(SELECT sum(p.price*p.cnt*(100.0-COALESCE(p.discount,0.0))/100.0) FROM elma.service_parametrs p WHERE(p.__id = ANY (siv.params))) as cost
|
||||
FROM elma.deals_services siv
|
||||
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 OUTER 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 (
|
||||
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 *,
|
||||
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
|
||||
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.storage)
|
||||
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,', ') as codes
|
||||
/*,o.line_key, o.probability_pc, dt_next, o.deal_uid, o.deal, o.agreement_uid, o.line_pricing_model_id,o.dt_from, o.dt_to*/
|
||||
FROM stair o
|
||||
JOIN elma.companies z on (o._companies=z.__id)
|
||||
LEFT OUTER 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,', ') as codes
|
||||
/*,o.line_key, o.probability_pc, dt_next, o.deal_uid, o.deal, o.agreement_uid, o.line_pricing_model_id,o.dt_from, o.dt_to*/
|
||||
FROM stair o
|
||||
JOIN elma.companies z on (o._companies=z.__id)
|
||||
LEFT OUTER 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,', ') as codes
|
||||
/*,o.line_key, o.probability_pc, dt_next, o.deal_uid, o.deal, o.agreement_uid, o.line_pricing_model_id,o.dt_from, o.dt_to*/
|
||||
FROM stair o
|
||||
JOIN elma.companies z on (o._companies=z.__id)
|
||||
LEFT OUTER 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,', ') as status_ids
|
||||
,STRING_AGG(distinct 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
|
||||
)
|
||||
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( 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 = 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,
|
||||
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 ,
|
||||
ARRAY_AGG(distinct line_pricing_model_id order by line_pricing_model_id) as ar_line_pricing_model_id,
|
||||
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
|
||||
<d:field_set titleMapOut="titleMap" lengthOut="fieldCount">
|
||||
@@ -134,6 +236,7 @@ select
|
||||
<d:field title="Диски Cloud">da.disk_alloc</d:field>
|
||||
<d:field>z.__name as alloc_company</d:field>
|
||||
<d:field>z.__id as alloc_company_uid</d:field>
|
||||
<d:field>ds.ar_status_ids</d:field>
|
||||
</d:field_set>
|
||||
from sold_ram r
|
||||
join deal_stat ds on (lower(r.wz)=lower(ds.wz))
|
||||
@@ -147,7 +250,7 @@ order by <m:order_build sortArray=#pageInfo.settings.sort.sortArray# fieldCount=
|
||||
</cfquery>
|
||||
|
||||
|
||||
|
||||
<!--- <cfdump var=#qRead#> --->
|
||||
|
||||
|
||||
<cfif isDefined("output_xls")>
|
||||
@@ -222,8 +325,6 @@ S3 операции и трафик: <b>#dateFormat(qS3OpsTrfAge.dt_load,'YYYY-M
|
||||
<cfflush/>
|
||||
|
||||
<cfoutput query="qRead">
|
||||
|
||||
|
||||
<tr>
|
||||
<td>#wz_sold#</td>
|
||||
<td>
|
||||
@@ -251,39 +352,41 @@ S3 операции и трафик: <b>#dateFormat(qS3OpsTrfAge.dt_load,'YYYY-M
|
||||
<td class="r"<cfif disk_sold GT disk_alloc> style="background:lightgreen;"</cfif>>#disk_sold#</td>
|
||||
<td class="r"<cfif disk_sold LT disk_alloc> style="background:lightcoral;"</cfif>>#disk_alloc#</td>
|
||||
</tr>
|
||||
</cfoutput>
|
||||
|
||||
<cfquery name="qTotal" dbtype="query">
|
||||
select
|
||||
sum(cpu_sold) as cpu_sold
|
||||
,sum(cpu_alloc) as cpu_alloc
|
||||
,sum(cpu_alloc_on) as cpu_alloc_on
|
||||
,sum(ram_sold) as ram_sold
|
||||
,sum(ram_alloc) as ram_alloc
|
||||
,sum(ram_alloc_on) as ram_alloc_on
|
||||
,sum(disk_sold) as disk_sold
|
||||
,sum(disk_alloc) as disk_alloc
|
||||
from qRead
|
||||
</cfquery>
|
||||
|
||||
<!---
|
||||
<td class="r" style="font-size:120%; padding:0 1em;">#chargeable_metric#</td>
|
||||
<td class="c" style="font-size:90%;">#ed_izm#</td>
|
||||
<td class="r">#discounted_price#</td>
|
||||
<td class="r">#charge#</td>
|
||||
<cfoutput query="qTotal">
|
||||
<tr class="b r">
|
||||
|
||||
<td colspan="6">Итого</td>
|
||||
|
||||
<td class="r"<cfif cpu_sold GT ram_alloc> style="background:lightgreen;"</cfif>>#cpu_sold#</td>
|
||||
<td class="r"<cfif cpu_sold LT cpu_alloc> style="background:lightcoral;"</cfif>>#cpu_alloc#</td>
|
||||
<td class="r"<cfif cpu_sold LT cpu_alloc_on> style="background:lightcoral;"</cfif>>#cpu_alloc_on#</td>
|
||||
|
||||
<td></td>
|
||||
<td class="r"<cfif ram_sold GT ram_alloc> style="background:lightgreen;"</cfif>>#ram_sold#</td>
|
||||
<td class="r"<cfif ram_sold LT ram_alloc> style="background:lightcoral;"</cfif>>#ram_alloc#</td>
|
||||
<td class="r"<cfif ram_sold LT ram_alloc_on> style="background:lightcoral;"</cfif>>#ram_alloc_on#</td>
|
||||
|
||||
<td>#abstract_service# #modifier#</td>
|
||||
<td>#component#</td>
|
||||
<td>#user_description#</td>
|
||||
|
||||
<td class="r">#price#</td>
|
||||
<td class="r">#discount#</td>
|
||||
|
||||
<td class="r">#dateFormat(dt_from,'YYYY-MM-DD')#</td>
|
||||
<td class="r">#dateFormat(dt_to,'YYYY-MM-DD')#</td>
|
||||
|
||||
<td class="r">#line_key#</td>
|
||||
<td class="r" style="color:##bbb">#raw_metric#</td>
|
||||
<td class="r">#metric#</td>
|
||||
<td><a href="contract.cfm?__id=#contract_uid#&#tr.fwx#">#contract#</a></td>
|
||||
<td><a href="additional_agreement.cfm?__id=#additional_agreement_uid#&#tr.fwx#">#additional_agreement#</a></td>
|
||||
<td><a href="deal.cfm?__id=#deal_uid#&#tr.fwx#">#deal#</a></td>
|
||||
</tr> --->
|
||||
|
||||
<td></td>
|
||||
<td class="r"<cfif disk_sold GT disk_alloc> style="background:lightgreen;"</cfif>>#disk_sold#</td>
|
||||
<td class="r"<cfif disk_sold LT disk_alloc> style="background:lightcoral;"</cfif>>#disk_alloc#</td>
|
||||
</tr>
|
||||
</cfoutput>
|
||||
|
||||
</table>
|
||||
<!--- <cfdump var=#qCharge#/> --->
|
||||
|
||||
|
||||
<layout:page section="footer"/>
|
||||
|
||||
|
||||
@@ -11,6 +11,10 @@
|
||||
<m:filterparam filter=#filter# param="contragent_id" ftype="guid" compare="EQ" field="z.__id" default=""/>
|
||||
<m:filterparam filter=#filter# param="contragent" ftype="string" compare="LIKE%" field="z.__name" 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="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="line_pricing_model_id" ftype="numeric" expression="(?=ANY(ds.ar_line_pricing_model_id))" suffix="" prefix="" default=""/>
|
||||
</m:filter_settings>
|
||||
|
||||
<cfif isDefined("resetAndClose") or isDefined("saveAndClose")>
|
||||
@@ -42,6 +46,46 @@ $(document).ready(function() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="tr">
|
||||
<div class="th">Код артикула</div>
|
||||
<div class="td">
|
||||
<input type="text" name="code" value="#code#" size="50"/>
|
||||
<i>#i18("по вхождению подстроки в любой из списков кодов","by substring")#</i>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="tr">
|
||||
<div class="th">Статус</div>
|
||||
<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>
|
||||
<option value=6""<cfif status_id EQ 6> selected</cfif>>Закрыта успешно</option>
|
||||
<option value="7"<cfif status_id EQ 7> selected</cfif>>Закрыта неуспешно</option>
|
||||
<option value="8"<cfif status_id EQ 8> selected</cfif>>Тестирование</option>
|
||||
<option value="10"<cfif status_id EQ 10> selected</cfif>>Отправлено ТКП</option>
|
||||
<option value="12"<cfif status_id EQ 12> selected</cfif>>Договор на согласовании</option>
|
||||
<option value="15"<cfif status_id EQ 15> selected</cfif>>Договор на подписании</option>
|
||||
<option value="37"<cfif status_id EQ 37> selected</cfif>>Внутреннее согласование</option>
|
||||
</select>
|
||||
<i>по вхождению в список</i>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="tr">
|
||||
<div class="th">Модель оплаты</div>
|
||||
<div class="td">
|
||||
<select name="line_pricing_model_id">
|
||||
<option></option>
|
||||
<option value="1"<cfif line_pricing_model_id EQ 1> selected</cfif>>1 install</option>
|
||||
<option value=3""<cfif line_pricing_model_id EQ 2> selected</cfif>>2 fix</option>
|
||||
<option value="3"<cfif line_pricing_model_id EQ 3> selected</cfif>>3 metered</option>
|
||||
</select>
|
||||
<i>по вхождению в список</i>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="tr">
|
||||
<div class="th">Контрагент</div>
|
||||
|
||||
Reference in New Issue
Block a user