046 versioning fixes
This commit is contained in:
+128
-59
@@ -109,62 +109,129 @@
|
||||
|
||||
<layout:page section="extension" closeForm="Yes"/>
|
||||
|
||||
<cfif len(d.__id)>
|
||||
|
||||
<cfif len(d.__id)>
|
||||
|
||||
<cfquery name="qService">
|
||||
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)
|
||||
)
|
||||
select
|
||||
siv.__id
|
||||
,siv.__name
|
||||
,siv.user_description
|
||||
,siv.discount
|
||||
,siv.cnt
|
||||
,siv.modifier_code
|
||||
,siv.abstractive_service_code
|
||||
,siv.is_actual
|
||||
,siv.type
|
||||
,siv.hash
|
||||
,siv.version
|
||||
,siv.__index
|
||||
,siv.date_nop
|
||||
,siv.date_end
|
||||
,siv.is_easy
|
||||
,siv.params::text
|
||||
,a.__id::text as additional_agreement_uid
|
||||
,a.__name as 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.__index as deal_index
|
||||
,d.__id as deal_uid
|
||||
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>
|
||||
|
||||
)
|
||||
,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
|
||||
,siv.__index AS siv_index
|
||||
,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.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.cnt as p_cnt
|
||||
,p.ed_izm
|
||||
,p.code
|
||||
,p.discount as p_discount
|
||||
,p.__id::text as p_uid
|
||||
,p.name
|
||||
FROM stair d
|
||||
JOIN status s ON (d.deal_status_id = s.status_id)
|
||||
LEFT JOIN LATERAL unnest(d.params) AS arr(param_id) ON TRUE
|
||||
JOIN component p ON (p.__id = arr.param_id)
|
||||
WHERE d.dt_from <= CURRENT_TIMESTAMP AND (CURRENT_TIMESTAMP < d.dt_next)
|
||||
</cfquery>
|
||||
|
||||
<!--- <cfdump var=#qService#/> --->
|
||||
<cfoutput>
|
||||
<h3>Услуги по данным CRM (версии строк спецификации, только актуальные на сегодня, сделки с вероятностью от 50% (начиная с тестирования) <!--- (#qService.recordCount#) ---></h3>
|
||||
</cfoutput>
|
||||
@@ -173,6 +240,7 @@
|
||||
<table class="worktable">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
<th width="3%">__index</th>
|
||||
<th width="5%">Код</th>
|
||||
<th width="20%">Пользовательское наименование</th>
|
||||
@@ -184,13 +252,13 @@
|
||||
<th width="5%">date_end</th>
|
||||
<th width="5%">Вер.%</th>
|
||||
<th width="10%">Дополнительное соглашение</th>
|
||||
<th width="5%">Ключ строки</th>
|
||||
</tr>
|
||||
</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>>
|
||||
<td class="c"><a href="deal_service.cfm?__id=#__id#&#tr.fwx#" title="__id">#__index#</a></td>
|
||||
<!--- <td class="c">#__name#</td> --->
|
||||
<td class="c"><a href="deal_service.cfm?__id=#siv_uid#&#tr.fwx#">#siv_index#</a></td>
|
||||
<td class="l">#abstractive_service_code#<cfif len(modifier_code)>.#modifier_code#</cfif></td>
|
||||
<td class="l">#user_description#</td>
|
||||
<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="c">
|
||||
<cfswitch expression=#type#>
|
||||
<cfswitch expression=#line_pricing_model_id#>
|
||||
<cfcase value=1>install</cfcase>
|
||||
<cfcase value=2>fix</cfcase>
|
||||
<cfcase value=3>payg</cfcase>
|
||||
</cfswitch> (#type#)
|
||||
</cfswitch> (#line_pricing_model_id#)
|
||||
</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">#dateFormat(date_nop,'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">#dateFormat(dt_from,'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"><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>
|
||||
</cfoutput>
|
||||
</table>
|
||||
@@ -330,7 +397,7 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="10%">Организация</th>
|
||||
<th width="10%">Статус организации</th>
|
||||
<!--- <th width="10%">Статус организации</th> --->
|
||||
<th width="10%">VDC</th>
|
||||
<th width="10%">Кластер</th>
|
||||
<th width="10%">Политика хранения</th>
|
||||
@@ -410,4 +477,6 @@
|
||||
<cfdump var=#qStorage#/> --->
|
||||
|
||||
</cfif><!--- len(d.__id) --->
|
||||
<br/><br/>
|
||||
добавить реестр GPU и VDC для поиска потеряшек
|
||||
<layout:page section="footer"/>
|
||||
Reference in New Issue
Block a user