Log

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 191

2018-03-15 10:55:08,735-Adding file [ExcessInventoryHelper.

xml] to list of watched


files.
2018-03-15 10:55:08,757-Adding file [StockoutAvailabilityChartHelper.xml] to list
of watched files.
2018-03-15 10:55:08,758-Adding file [InventoryTurnsHelper.xml] to list of watched
files.
2018-03-15 10:55:08,758-Statement Id: [SelectInventoryTurns] Prepared SQL: [select
rpl.transaction_date, rpl.category_id, rpl.category_name,
date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date, sum(1) as
count, sum(rpl.closing_quantity) as closing_quantity, sum(rpl.sales) as sales
from replenishment rpl where rpl.category_id is not null and
rpl.transaction_date = ?param0 group by rpl.transaction_date,
rpl.category_id]
2018-03-15 10:55:08,758-Statement Id: [SelectInventoryTurnsSKU] Prepared SQL:
[select rpl.transaction_date, rpl.category_id, rpl.sku_id, rpl.category_name,
date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date, sum(1) as
count, sum(rpl.closing_quantity) as closing_quantity, sum(rpl.sales) as sales
from replenishment rpl where rpl.category_id is not null and
rpl.transaction_date = ?param0 group by rpl.transaction_date,
rpl.category_id, rpl.sku_id]
2018-03-15 10:55:08,759-Adding file [CntQtyFillRateChartHelper.xml] to list of
watched files.
2018-03-15 10:55:08,759-Statement Id: [SelectCntQtyFillRateChart] Prepared SQL:
[select rpl.transaction_date, rpl.closing_stock_zone,
group_concat(distinct(rpl.sku_id) SEPARATOR ',') as str_sku_ids,
date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date,
sum(rpl.closing_quantity) as closing_quantity, sum(rpl.buffer_norm) as buffer_norm
from replenishment rpl where rpl.closing_stock_zone != "White" and
rpl.transaction_date = ?param0 group by rpl.transaction_date,
rpl.closing_stock_zone]
2018-03-15 10:55:08,759-Statement Id: [SelectCntQtyFillRateChartNode] Prepared SQL:
[select rpl.transaction_date, rpl.closing_stock_zone, rpl.node_id,
group_concat(distinct(rpl.sku_id) SEPARATOR ',') as str_sku_ids,
date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date,
sum(rpl.closing_quantity) as closing_quantity, sum(rpl.buffer_norm) as buffer_norm
from replenishment rpl where rpl.closing_stock_zone != "White" and
rpl.transaction_date = ?param0 group by rpl.transaction_date,
rpl.closing_stock_zone, rpl.node_id]
2018-03-15 10:55:08,759-Statement Id: [SelectCntQtyFillRateChartCategory] Prepared
SQL: [select rpl.transaction_date, rpl.closing_stock_zone, rpl.category_id,
group_concat(distinct(rpl.sku_id) SEPARATOR ',') as str_sku_ids,
date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date,
sum(rpl.closing_quantity) as closing_quantity, sum(rpl.buffer_norm) as buffer_norm
from replenishment rpl where rpl.closing_stock_zone != "White" and
rpl.transaction_date = ?param0 group by rpl.transaction_date,
rpl.closing_stock_zone, rpl.category_id]
2018-03-15 10:55:08,759-Statement Id: [SelectCntQtyFillRateChartSKU] Prepared SQL:
[select rpl.transaction_date, rpl.closing_stock_zone, rpl.sku_id,
group_concat(distinct(rpl.sku_id) SEPARATOR ',') as str_sku_ids,
date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date,
sum(rpl.closing_quantity) as closing_quantity, sum(rpl.buffer_norm) as buffer_norm
from replenishment rpl where rpl.closing_stock_zone != "White" and
rpl.transaction_date = ?param0 group by rpl.transaction_date,
rpl.closing_stock_zone, rpl.sku_id]
2018-03-15 10:55:08,760-Adding file [UserDataPermissionHelper.xml] to list of
watched files.
2018-03-15 10:55:08,760-Statement Id: [SelectDataPermissionByRole] Prepared SQL:
[select user_data_id, role_id, object_type, object_id, chk_state, created_by,
created_on from user_data_permissions WHERE role_id = ?param0 AND
object_type = ?param1]
2018-03-15 10:55:08,760-Statement Id: [InsertUserDataPermission] Prepared SQL:
[insert into user_data_permissions (role_id, object_type, object_id,
chk_state, created_by, created_on) values ( ?param0 , ?param1 , ?
param2 , ?param3 , ?param4 , NOW());]
2018-03-15 10:55:08,760-Statement Id: [InsertUserDataPermission.SelectKey] Prepared
SQL: [select last_insert_id() as value]
2018-03-15 10:55:08,761-Statement Id: [DeleteDataPermissionByRole] Prepared SQL:
[delete from user_data_permissions where role_id = ?param0]
2018-03-15 10:55:08,761-Adding file [RoleHelper.xml] to list of watched files.
2018-03-15 10:55:08,761-Statement Id: [SelectRoleNameDuplicate] Prepared SQL:
[select role_id,role_name,status,created_by,created_on,modified_by,modified_on
from role where role_name = ?param0 and role_id != ?param1]
2018-03-15 10:55:08,761-Statement Id: [InsertRole] Prepared SQL: [insert into role
(role_name,status,created_by,created_on) values ( ?param0 , ?
param1 , ?param2 , NOW());]
2018-03-15 10:55:08,761-Statement Id: [InsertRole.SelectKey] Prepared SQL: [select
last_insert_id() as value]
2018-03-15 10:55:08,761-Statement Id: [UpdateRole] Prepared SQL: [update role set
role_name = ?param0 , status = ?param1 , modified_by = ?param2 ,
modified_on = NOW() where role_id = ?param3]
2018-03-15 10:55:08,761-Adding file [BOMHelper.xml] to list of watched files.
2018-03-15 10:55:08,762-Statement Id: [SelectBOMDictionary] Prepared SQL: [SELECT
DISTINCT sk.sku_code, bm.sku_id FROM sku sk INNER JOIN bom bm ON bm.sku_id =
sk.sku_id]
2018-03-15 10:55:08,762-Adding file [Matrix1Helper.xml] to list of watched files.
2018-03-15 10:55:08,766-Statement Id: [SelectNodeDictionary] Prepared SQL: [select
node_code,node_id from node]
2018-03-15 10:55:08,767-Statement Id: [SelectNodeDictionary] PreparedStatement :
[select node_code,node_id from node]
2018-03-15 10:55:08,767-Open Connection "66569552" to "MySQL, MySQL provider ver
6:5:4:0".
2018-03-15 10:55:08,769-Close Connection "66569552" to "MySQL, MySQL provider ver
6:5:4:0".
2018-03-15 10:55:08,772-Adding file [SqlMap.config] to list of watched files.
2018-03-15 10:55:08,773-Add property "provider" value "MySql6"
2018-03-15 10:55:08,773-Add property "datasource" value "localhost"
2018-03-15 10:55:08,773-Add property "database" value "scmplus"
2018-03-15 10:55:08,773-Add property "port" value "3306"
2018-03-15 10:55:08,773-Add property "userid" value "root"
2018-03-15 10:55:08,773-Add property "password" value "root"
2018-03-15 10:55:08,773-Add property "mapperResources" value
"./bin/iBatis/SqlMapper/"
2018-03-15 10:55:08,774-Adding file [CategoryHelper.xml] to list of watched files.
2018-03-15 10:55:08,774-Statement Id: [SelectCategoryByCode] Prepared SQL: [select
category_id, category_code, category_name, parent_id, status, created_by,
created_on, modified_by, modified_on from category where category_code = ?
param0]
2018-03-15 10:55:08,774-Statement Id: [SelectCategoryForDuplicate] Prepared SQL:
[select category_id, category_code, category_name, parent_id, status, created_by,
created_on, modified_by, modified_on from category where category_code = ?
param0 and category_name = ?param1 and parent_id = ?param2]
2018-03-15 10:55:08,774-Statement Id: [SelectCategoryBy] Prepared SQL: [select
category_id, parent_id, category_name, category_code, status, created_by,
created_on, modified_by, modified_on from category where ?param0 = ?
param1]
2018-03-15 10:55:08,774-Statement Id: [InsertCategory] Prepared SQL: [insert into
category (category_code, category_name, parent_id, status, created_by,
created_on) values ( ?param0 , ?param1 , ?param2 , ?param3 , ?
param4 , NOW());]
2018-03-15 10:55:08,774-Statement Id: [InsertCategory.SelectKey] Prepared SQL:
[select last_insert_id() as value]
2018-03-15 10:55:08,774-Statement Id: [UpdateCategory] Prepared SQL: [update
category set category_name = ?param0 , parent_id = ?param1 ,
status = ?param2 , modified_by = ?param3 , modified_on = NOW()
where category_code = ?param4]
2018-03-15 10:55:08,774-Statement Id: [DeleteCategory] Prepared SQL: [delete from
category where category_id = ?param0]
2018-03-15 10:55:08,774-Adding file [NodeHelper.xml] to list of watched files.
2018-03-15 10:55:08,774-Statement Id: [MapNode] Prepared SQL: [select node_id,
node_code, node_name, address_line1, address_line2, status from node where node_id
= ?param0 union all select '' as node_id, '' as node_code, '' as
node_name, '' as address_line1, '' as address_line2, null as status limit 1]
2018-03-15 10:55:08,774-Statement Id: [SelectNodeByCode] Prepared SQL: [select
node_id, node_code, node_name, parent_id, location_id, address_line1,
address_line2, latitude, longitude, status, created_by, created_on,
modified_by, modified_on from node where node_code = ?param0]
2018-03-15 10:55:08,774-Statement Id: [SelectNodeForDuplicate] Prepared SQL:
[select node_id, node_code, node_name, parent_id, location_id, address_line1,
address_line2, latitude, longitude, status, created_by, created_on,
modified_by, modified_on from node where node_code = ?param0 and node_name
= ?param1 and parent_id = ?param2]
2018-03-15 10:55:08,774-Statement Id: [InsertNode] Prepared SQL: [insert into node
(node_code, node_name, parent_id, location_id, address_line1, address_line2,
latitude, longitude, status, created_by, created_on) values
( ?param0 , ?param1 , ?param2 , ?param3 , ?param4 , ?param5 , ?param6 , ?
param7 , ?param8 , ?param9 , NOW());]
2018-03-15 10:55:08,774-Statement Id: [InsertNode.SelectKey] Prepared SQL: [select
last_insert_id() as value]
2018-03-15 10:55:08,774-Statement Id: [UpdateNode] Prepared SQL: [update node set
node_name = ?param0 , parent_id = ?param1 , location_id = ?
param2 , address_line1 = ?param3 , address_line2 = ?param4 ,
latitude = ?param5 , longitude = ?param6 , status = ?param7 ,
modified_by = ?param8 , modified_on = NOW() where node_code = ?
param9]
2018-03-15 10:55:08,774-Statement Id: [DeleteNode] Prepared SQL: [delete from node
where node_id = ?param0]
2018-03-15 10:55:08,774-Adding file [AttributeHelper.xml] to list of watched files.
2018-03-15 10:55:08,774-Statement Id: [SelectAttributeByCode] Prepared SQL: [select
attribute_id, attribute_code, attribute_name, data_type, optional, status,
created_by, created_on, modified_by, modified_on from attribute where
attribute_code = ?param0]
2018-03-15 10:55:08,774-Statement Id: [InsertAttribute] Prepared SQL: [insert into
attribute (attribute_code, attribute_name, data_type, optional, status,
created_by, created_on) values ( ?param0 , ?param1 , ?param2 , ?
param3 , ?param4 , ?param5 , NOW());]
2018-03-15 10:55:08,774-Statement Id: [InsertAttribute.SelectKey] Prepared SQL:
[select last_insert_id() as value]
2018-03-15 10:55:08,774-Statement Id: [UpdateAttribute] Prepared SQL: [update
attribute set attribute_name = ?param0 , data_type = ?param1 ,
optional = ?param2 , status = ?param3 , modified_by = ?param4 ,
modified_on = NOW() where attribute_id = ?param5]
2018-03-15 10:55:08,774-Statement Id: [DeleteAttribute] Prepared SQL: [delete from
attribute where attribute_id = ?param0]
2018-03-15 10:55:08,774-Adding file [SKUHelper.xml] to list of watched files.
2018-03-15 10:55:08,774-Statement Id: [MapSKU] Prepared SQL: [select * from sku
where sku_id = ?param0]
2018-03-15 10:55:08,774-Statement Id: [SelectSKUByCode] Prepared SQL: [select
sku_id, sku_code, sku_name, sku_description, status, created_by, created_on,
modified_by, modified_on from sku where sku_code = ?param0]
2018-03-15 10:55:08,774-Statement Id: [SelectSKUForDuplicate] Prepared SQL: [select
sku_id, sku_code, sku_name, sku_description, status, created_by, created_on,
modified_by, modified_on from sku where sku_code = ?param0 and sku_name =
?param1 and sku_description = ?param2]
2018-03-15 10:55:08,774-Statement Id: [SelectBatchInsertedSKU] Prepared SQL:
[select sku_id, sku_code, sku_name, sku_description, status, created_by,
created_on, modified_by, modified_on from sku where sku_id >= (SELECT
(AUTO_INCREMENT - ?param0 ) FROM information_schema.`TABLES` WHERE TABLE_NAME =
'sku' LIMIT 1)]
2018-03-15 10:55:08,774-Statement Id: [InsertSKU] Prepared SQL: [insert into sku
(sku_code, sku_name, sku_description, status, created_by, created_on) values
( ?param0 , ?param1 , ?param2 , ?param3 , ?param4 , NOW());]
2018-03-15 10:55:08,774-Statement Id: [InsertSKU.SelectKey] Prepared SQL: [select
last_insert_id() as value]
2018-03-15 10:55:08,774-Statement Id: [UpdateSKU] Prepared SQL: [update sku set
sku_name = ?param0 , sku_description = ?param1 , status = ?
param2 , modified_by = ?param3 , modified_on = NOW() where
sku_id = ?param4]
2018-03-15 10:55:08,774-Statement Id: [DeleteSKU] Prepared SQL: [delete from sku
where sku_id = ?param0]
2018-03-15 10:55:08,774-Adding file [SKUAttributeHelper.xml] to list of watched
files.
2018-03-15 10:55:08,774-Statement Id: [SelectSKUAttributeMappingBySKUAttribute]
Prepared SQL: [select sku_attribute_mapping_id, sku_id, attribute_id, value,
created_by, created_on from sku_attribute_mapping where sku_id = ?param0
and attribute_id = ?param1]
2018-03-15 10:55:08,774-Statement Id: [SelectSKUAttributeMappingBySKU] Prepared
SQL: [select sku_attribute_mapping_id, sku_id, attribute_id, value, created_by,
created_on from sku_attribute_mapping where sku_id = ?param0]
2018-03-15 10:55:08,774-Statement Id: [InsertSKUAttributeMapping] Prepared SQL:
[insert into sku_attribute_mapping (sku_id, attribute_id, value, created_by,
created_on) values ( ?param0 , ?param1 , ?param2 , ?param3 ,
NOW());]
2018-03-15 10:55:08,774-Statement Id: [InsertSKUAttributeMapping.SelectKey]
Prepared SQL: [select last_insert_id() as value]
2018-03-15 10:55:08,774-Statement Id: [UpdateSKUAttributeMapping] Prepared SQL:
[update sku_attribute_mapping set value = ?param0 , where
sku_attribute_mapping_id = ?param1]
2018-03-15 10:55:08,774-Statement Id: [DeleteSKUAttributeMapping] Prepared SQL:
[delete from sku_attribute_mapping where sku_id = ?param0 and attribute_id
= ?param1]
2018-03-15 10:55:08,774-Adding file [NodeSKUHelper.xml] to list of watched files.
2018-03-15 10:55:08,774-Statement Id: [SelectNodeSKUMappingByNodeSKU] Prepared SQL:
[select node_sku_mapping_id, receiver_node_id, sku_id, supplier_node_id,
effective_date, created_by, created_on from node_sku_mapping where sku_id =
?param0 and receiver_node_id = ?param1 and supplier_node_id = ?param2 and
effective_date = ?param3]
2018-03-15 10:55:08,774-Statement Id: [selectSKU] Prepared SQL: [select * from sku
where sku_id = ?param0]
2018-03-15 10:55:08,774-Statement Id: [selectNode] Prepared SQL: [select * from
node where node_id = ?param0]
2018-03-15 10:55:08,774-Statement Id: [InsertNodeSKUMapping] Prepared SQL: [insert
into node_sku_mapping (receiver_node_id, sku_id, supplier_node_id,
effective_date, created_by, created_on) values ( ?param0 , ?param1 ,
?param2 , date_format( ?param3 , "%Y-%c-%e %H:%i:%s"), ?param4 , NOW());]
2018-03-15 10:55:08,774-Statement Id: [InsertNodeSKUMapping.SelectKey] Prepared
SQL: [select last_insert_id() as value]
2018-03-15 10:55:08,774-Statement Id: [DeleteNodeSKUMapping] Prepared SQL: [delete
from node_sku_mapping where node_sku_mapping_id = ?param0]
2018-03-15 10:55:08,774-Adding file [BufferNormHelper.xml] to list of watched
files.
2018-03-15 10:55:08,774-Statement Id: [MapBufferNorm] Prepared SQL: [select
buffer_norm_id, sku_id, node_id, buffer_norm, olt, plt, tlt, rlt,
max_sales_per_day, safety_factor, unit_selling_price, unit_purchase_price,
moq, eoq, effective_from, created_by, created_on, modified_by, modified_on
from buffer_norm where buffer_norm_id = ?param0 union all select '' as
buffer_norm_id, '' as sku_id, '' as node_id, 0 as buffer_norm, 0 as olt, 0 as plt,
0 as tlt, 0 as rlt, 0 as max_sales_per_day, 0 as safety_factor, 0 as
unit_selling_price, 0 as unit_purchase_price, 0 as moq, 0 as eoq, '' as
effective_from, null as created_by, null as created_on, null as modified_by, null
as modified_on limit 1]
2018-03-15 10:55:08,774-Statement Id: [SelectBufferNormBySKUNode] Prepared SQL:
[select buffer_norm_id, sku_id, node_id, buffer_norm, olt, plt, tlt, rlt,
max_sales_per_day, safety_factor, unit_selling_price, unit_purchase_price,
moq, eoq, effective_from, created_by, created_on, modified_by,
modified_on,IFNULL(is_default_zone,'Y') AS is_default_zone, IFNULL(red_zone,0) AS
red_zone, IFNULL(yellow_zone,0) AS yellow_zone from buffer_norm where sku_id
= ?param0 and node_id = ?param1 and effective_from = ?param2]
2018-03-15 10:55:08,774-Statement Id: [SelectBatchInsertedBufferNorm] Prepared SQL:
[select b.buffer_norm_id, b.sku_id, b.node_id, b.buffer_norm, b.olt, b.plt, b.tlt,
b.rlt, b.max_sales_per_day, b.safety_factor, b.unit_selling_price,
b.unit_purchase_price, b.moq, b.eoq, b.effective_from, b.created_by, b.created_on,
b.modified_by, b.modified_on, b.identifier, b.is_default_zone, b.red_zone,
b.yellow_zone from buffer_norm b where identifier = ?param0]
2018-03-15 10:55:08,774-Statement Id: [InsertBufferNorm] Prepared SQL: [insert into
buffer_norm (sku_id, node_id, buffer_norm, olt, plt, tlt, rlt,
max_sales_per_day, safety_factor, unit_selling_price, unit_purchase_price,
moq, eoq, effective_from, created_by, created_on) values ( ?param0 ,
?param1 , ?param2 , ?param3 , ?param4 , ?param5 , ?param6 , ?param7 , ?
param8 , ?param9 , ?param10 , ?param11 , ?param12 , date_format( ?
param13 , "%Y-%c-%e %H:%i:%s"), ?param14 , NOW());]
2018-03-15 10:55:08,774-Statement Id: [InsertBufferNorm.SelectKey] Prepared SQL:
[select last_insert_id() as value]
2018-03-15 10:55:08,774-Statement Id: [UpdateBufferNorm] Prepared SQL: [update
buffer_norm set sku_id = ?param0 , node_id = ?param1 ,
buffer_norm = ?param2 , olt = ?param3 , plt = ?param4 , tlt
= ?param5 , rlt = ?param6 , max_sales_per_day = ?param7 ,
safety_factor = ?param8 , unit_selling_price = ?param9 ,
unit_purchase_price = ?param10 , moq = ?param11 , eoq = ?param12 ,
effective_from = date_format( ?param13 , "%Y-%c-%e %H:%i:%s"), modified_by =
?param14 , modified_on = NOW() where buffer_norm_id = ?param15]
2018-03-15 10:55:08,774-Statement Id: [DeleteBufferNorm] Prepared SQL: [delete from
buffer_norm where buffer_norm_id = ?param0]
2018-03-15 10:55:08,774-Adding file [TransactionHelper.xml] to list of watched
files.
2018-03-15 10:55:08,774-Statement Id: [SelectTransactionForDuplicate] Prepared SQL:
[select transaction_id, sku_id, node_id, supply_node_id, transaction_date, grn,
sales, closing_quantity, in_transit, inst_hold, quality_hold, qa_hold,
pending_orders, orders_in_hand, transport_mode, db_sync, mongo_sync, created_by,
created_on, open_stock_transfer_order, open_planned_order,
open_purchase_request, open_production_order, open_purchase_order, field1, field2,
field3, field4, field5, field6, field7, field8, field9, field10 from
transaction where sku_id = ?param0 and node_id = ?param1 and transaction_date =
?param2]
2018-03-15 10:55:08,774-Statement Id: [SelectReplenishmentList] Prepared SQL:
[select tr.transaction_id, tr.transaction_date,
date_format(tr.transaction_date,'%d/%m/%Y') as display_date,
date_format(tr.transaction_date,'%Y%m%d') as transfilter_date, tr.sku_id,
s.sku_code, s.sku_name, tr.node_id, n.node_code, n.node_name, sc.category_id,
cat.category_code, cat.category_name, ifnull(bn.buffer_norm, 0) as
buffer_norm, ifnull(tr.closing_quantity, 0) as closing_quantity,
ifnull(tr.in_transit, 0) as in_transit, ifnull(tr.sales, 0) as sales,
ifnull(tr.inst_hold, 0) as inst_hold, ifnull(tr.quality_hold, 0) as quality_hold,
ifnull(tr.qa_hold, 0) as qa_hold, ifnull(tr.pending_orders, 0) as
pending_orders, ifnull(tr.orders_in_hand, 0) as orders_in_hand,
ifnull(tr.transport_mode, '') as transport_mode, nsm.supplier_node_id as
supply_node_id, sn.node_name as supply_node_name, sn.node_code as
supply_node_code, ifnull(str.closing_quantity, 0) as supplying_quantity,
ifnull(sbn.buffer_norm, 0) as supplying_buffer_norm,
round(ifnull(bn.buffer_norm, 0),2) as 'green_zone_qty', CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2)
END AS 'yellow_zone_qty', CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END as 'red_zone_qty', case
when ifnull(bn.buffer_norm, 0) = 0 then 'White' when
(ifnull(tr.closing_quantity, 0) <= 0 and ifnull(bn.buffer_norm, 0) > 0) then
'Black' when (ifnull(tr.closing_quantity, 0) > ifnull(bn.buffer_norm, 0) and
ifnull(bn.buffer_norm, 0) > 0) then 'Blue' when (ifnull(tr.closing_quantity,
0) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) and ifnull(tr.closing_quantity,
0) <= ifnull(bn.buffer_norm, 0) and ifnull(bn.buffer_norm, 0) > 0) then 'Green'
when (ifnull(tr.closing_quantity, 0) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) and ifnull(tr.closing_quantity, 0) <=
(CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) and ifnull(bn.buffer_norm, 0) >
0) then 'Yellow' when (ifnull(tr.closing_quantity, 0) > 0 and
ifnull(tr.closing_quantity, 0) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) and ifnull(bn.buffer_norm, 0) > 0) then
'Red' end as 'closing_stock_zone', case when
ifnull(bn.buffer_norm, 0) = 0 then 6 when (ifnull(tr.closing_quantity, 0) <=
0 and ifnull(bn.buffer_norm, 0) > 0) then 1 when
(ifnull(tr.closing_quantity, 0) > ifnull(bn.buffer_norm, 0) and
ifnull(bn.buffer_norm, 0) > 0) then 2 when (ifnull(tr.closing_quantity, 0) >
(CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) and ifnull(tr.closing_quantity,
0) <= ifnull(bn.buffer_norm, 0) and ifnull(bn.buffer_norm, 0) > 0) then 4
when (ifnull(tr.closing_quantity, 0) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) and ifnull(tr.closing_quantity, 0) <=
(CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) and ifnull(bn.buffer_norm, 0) >
0) then 3 when (ifnull(tr.closing_quantity, 0) > 0 and
ifnull(tr.closing_quantity, 0) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) and ifnull(bn.buffer_norm, 0) > 0) then
5 end as 'closing_stock_zone_sort', case when
ifnull(bn.buffer_norm, 0) = 0 then 'White' when
((ifnull(tr.closing_quantity, 0) + ifnull(tr.in_transit, 0) -
ifnull(tr.pending_orders, 0)) <= 0 and ifnull(bn.buffer_norm, 0) > 0) then 'Black'
when ((ifnull(tr.closing_quantity, 0) + ifnull(tr.in_transit, 0) -
ifnull(tr.pending_orders, 0)) > ifnull(bn.buffer_norm, 0) and
ifnull(bn.buffer_norm, 0) > 0) then 'Blue' when
((ifnull(tr.closing_quantity, 0) + ifnull(tr.in_transit, 0) -
ifnull(tr.pending_orders, 0)) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) and
(ifnull(tr.closing_quantity, 0) + tr.in_transit - tr.pending_orders) <=
ifnull(bn.buffer_norm, 0) and ifnull(bn.buffer_norm, 0) > 0) then 'Green'
when ((ifnull(tr.closing_quantity, 0) + ifnull(tr.in_transit, 0) -
ifnull(tr.pending_orders, 0)) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) and (tr.closing_quantity +
tr.in_transit - tr.pending_orders) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2)
ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) and ifnull(bn.buffer_norm,
0) > 0) then 'Yellow' when ((ifnull(tr.closing_quantity, 0) +
ifnull(tr.in_transit, 0) - ifnull(tr.pending_orders, 0)) > 0 and
(ifnull(tr.closing_quantity, 0) + tr.in_transit - tr.pending_orders) <= (CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) and
ifnull(bn.buffer_norm, 0) > 0) then 'Red' end as 'in_transit_zone',
case when ifnull(bn.buffer_norm, 0) = 0 then 6 when
((ifnull(tr.closing_quantity, 0) + ifnull(tr.in_transit, 0) -
ifnull(tr.pending_orders, 0)) <= 0 and ifnull(bn.buffer_norm, 0) > 0) then 1
when ((ifnull(tr.closing_quantity, 0) + ifnull(tr.in_transit, 0) -
ifnull(tr.pending_orders, 0)) > ifnull(bn.buffer_norm, 0) and
ifnull(bn.buffer_norm, 0) > 0) then 2 when ((ifnull(tr.closing_quantity, 0)
+ ifnull(tr.in_transit, 0) - ifnull(tr.pending_orders, 0)) > (CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2)
END) and (ifnull(tr.closing_quantity, 0) + tr.in_transit - tr.pending_orders) <=
ifnull(bn.buffer_norm, 0) and ifnull(bn.buffer_norm, 0) > 0) then 4 when
((ifnull(tr.closing_quantity, 0) + ifnull(tr.in_transit, 0) -
ifnull(tr.pending_orders, 0)) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) and (ifnull(tr.closing_quantity, 0) +
tr.in_transit - tr.pending_orders) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2)
ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) and ifnull(bn.buffer_norm,
0) > 0) then 3 when ((ifnull(tr.closing_quantity, 0) + ifnull(tr.in_transit,
0) - ifnull(tr.pending_orders, 0)) > 0 and (ifnull(tr.closing_quantity, 0) +
tr.in_transit - tr.pending_orders) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) and ifnull(bn.buffer_norm, 0) > 0) then
5 end as 'in_transit_zone_sort', case when
ifnull(sbn.buffer_norm, 0) = 0 then 'White' when
(ifnull(str.closing_quantity, 0) <= 0 and ifnull(sbn.buffer_norm, 0) > 0) then
'Black' when (ifnull(str.closing_quantity, 0) > ifnull(sbn.buffer_norm, 0)
and ifnull(sbn.buffer_norm, 0) > 0) then 'Blue' when
(ifnull(str.closing_quantity, 0) > (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) and
ifnull(str.closing_quantity, 0) <= ifnull(sbn.buffer_norm, 0) and
ifnull(sbn.buffer_norm, 0) > 0) then 'Green' when
(ifnull(str.closing_quantity, 0) > (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) and ifnull(str.closing_quantity, 0) <=
(CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) and ifnull(sbn.buffer_norm, 0)
> 0) then 'Yellow' when (ifnull(str.closing_quantity, 0) > 0 and
ifnull(str.closing_quantity, 0) <= (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) and ifnull(sbn.buffer_norm, 0) > 0)
then 'Red' end as 'supplying_node_zone', case when
ifnull(sbn.buffer_norm, 0) = 0 then 6 when (ifnull(str.closing_quantity, 0)
<= 0 and ifnull(sbn.buffer_norm, 0) > 0) then 1 when
(ifnull(str.closing_quantity, 0) > ifnull(sbn.buffer_norm, 0) and
ifnull(sbn.buffer_norm, 0) > 0) then 2 when (ifnull(str.closing_quantity,
0) > (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) and
ifnull(str.closing_quantity, 0) <= ifnull(sbn.buffer_norm, 0) and
ifnull(sbn.buffer_norm, 0) > 0) then 4 when (ifnull(str.closing_quantity, 0)
> (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) and ifnull(str.closing_quantity, 0) <=
(CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) and ifnull(sbn.buffer_norm, 0)
> 0) then 3 when (ifnull(str.closing_quantity, 0) > 0 and
ifnull(str.closing_quantity, 0) <= (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) and ifnull(sbn.buffer_norm, 0) > 0)
then 5 end as 'supplying_node_zone_sort', case when
((ifnull(bn.buffer_norm, 0) - ifnull(tr.closing_quantity, 0) -
ifnull(tr.in_transit, 0)) + ifnull(tr.pending_orders, 0)) -
(ifnull(tr.open_planned_order, 0) + ifnull(tr.open_purchase_request, 0) +
ifnull(tr.open_production_order, 0) + ifnull(tr.open_purchase_order, 0)) <= 0 then
0 else ((ifnull(bn.buffer_norm, 0) - ifnull(tr.closing_quantity, 0) -
ifnull(tr.in_transit, 0)) + ifnull(tr.pending_orders, 0)) -
(ifnull(tr.open_planned_order, 0) + ifnull(tr.open_purchase_request, 0) +
ifnull(tr.open_production_order, 0) + ifnull(tr.open_purchase_order, 0)) end
as 'replenishment_quantity', case when (ifnull(tr.closing_quantity,
0) + ifnull(tr.in_transit, 0) + ifnull(tr.open_planned_order, 0) +
ifnull(tr.open_purchase_request, 0) + ifnull(tr.open_production_order, 0) +
ifnull(tr.open_purchase_order, 0) ) - ifnull(tr.pending_orders, 0) <= 0 then 0
else (ifnull(tr.closing_quantity, 0) + ifnull(tr.in_transit, 0) +
ifnull(tr.open_planned_order, 0) + ifnull(tr.open_purchase_request, 0) +
ifnull(tr.open_production_order, 0) + ifnull(tr.open_purchase_order, 0) ) -
ifnull(tr.pending_orders, 0) end as 'final_quantity', case
when ifnull(bn.buffer_norm, 0) = 0 then 0 else (CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END)
end as 'mrq', (select count(1) from transaction_comment where
transaction_id = tr.transaction_id) as 'transaction_comment',
ifnull(tr.open_stock_transfer_order, 0) as open_stock_transfer_order,
ifnull(tr.open_planned_order, 0) as open_planned_order,
ifnull(tr.open_purchase_request, 0) as open_purchase_request,
ifnull(tr.open_production_order, 0) as open_production_order,
ifnull(tr.open_purchase_order, 0) as open_purchase_order, tr.field1,
tr.field2, tr.field3, tr.field4, tr.field5, tr.field6, tr.field7, tr.field8,
tr.field9, tr.field10 from ( select transaction_id from
transaction where transaction_date = ?param0 limit ?param1 , ?
param2 ) otr join transaction tr on tr.transaction_id
= otr.transaction_id left join buffer_norm bn on bn.sku_id =
tr.sku_id and bn.node_id = tr.node_id and bn.effective_from = (
select max(effective_from) from buffer_norm where effective_from <=
tr.transaction_date and sku_id = tr.sku_id and node_id = tr.node_id)
left join sku s on s.sku_id = tr.sku_id left join sku_category sc
on sc.sku_id = tr.sku_id left join category cat on cat.category_id
= sc.category_id left join node n on n.node_id = tr.node_id
left join node_sku_mapping nsm on nsm.receiver_node_id = tr.node_id
and nsm.sku_id = tr.sku_id and nsm.effective_date = ( select
max(effective_date) from node_sku_mapping where effective_date <=
tr.transaction_date and sku_id = tr.sku_id and receiver_node_id =
tr.node_id) left join node sn on sn.node_id = nsm.supplier_node_id
left join buffer_norm sbn on sbn.sku_id = nsm.sku_id and sbn.node_id
= nsm.supplier_node_id and sbn.effective_from = ( select
max(effective_from) from buffer_norm where effective_from <=
tr.transaction_date and sku_id = tr.sku_id and node_id = tr.node_id)
left join ( select transaction_id, sku_id, node_id, closing_quantity
from transaction where transaction_date = ?param0 ) str
on str.sku_id = nsm.sku_id and str.node_id = nsm.supplier_node_id and
str.transaction_id = otr.transaction_id order by tr.transaction_id]
2018-03-15 10:55:08,774-Statement Id: [MapTransaction] Prepared SQL: [select * from
transaction where transaction_id = ?param0]
2018-03-15 10:55:08,774-Statement Id: [SelectMaxTransactionDate] Prepared SQL:
[select date_sub(max(transaction_date), interval 15 day) as avg_date,
max(transaction_date) as transaction_date from transaction]
2018-03-15 10:55:08,774-Statement Id: [SelectSKUNodeGroup] Prepared SQL: [select
sku_id, node_id from transaction group by sku_id, node_id]
2018-03-15 10:55:08,774-Statement Id: [SelectTransactionBySKUNode] Prepared SQL:
[select transaction_id, sku_id, node_id, supply_node_id, transaction_date, grn,
sales, closing_quantity, in_transit, inst_hold, quality_hold, qa_hold,
pending_orders, orders_in_hand, transport_mode, db_sync, mongo_sync, created_by,
created_on, open_stock_transfer_order, open_planned_order,
open_purchase_request, open_production_order, open_purchase_order, field1, field2,
field3, field4, field5, field6, field7, field8, field9, field10 from
transaction where sku_id = ?param0 and node_id = ?param1]
2018-03-15 10:55:08,774-Statement Id: [SelectTransactionByDate] Prepared SQL:
[select transaction_id, sku_id, node_id, supply_node_id, transaction_date, grn,
sales, closing_quantity, in_transit, inst_hold, quality_hold, qa_hold,
pending_orders, orders_in_hand, transport_mode, db_sync, mongo_sync, created_by,
created_on, open_stock_transfer_order, open_planned_order,
open_purchase_request, open_production_order, open_purchase_order, field1, field2,
field3, field4, field5, field6, field7, field8, field9, field10 from
transaction where transaction_date = ?param0]
2018-03-15 10:55:08,774-Statement Id: [SelectTransactionDates] Prepared SQL:
[select DATE_FORMAT(transaction_date, '%Y-%m-%d %H:%i:%s') as transaction_date from
transaction group by transaction_date asc limit ?param0]
2018-03-15 10:55:08,774-Statement Id: [SelectBNCalculationTransactionDates]
Prepared SQL: [select DATE_FORMAT(transaction_date, '%Y-%m-%d %H:%i:%s') as
transaction_date from transaction where transaction_date >= ?param0
group by transaction_date asc]
2018-03-15 10:55:08,774-Statement Id: [SelectTransactionIdsForBNCalculation]
Prepared SQL: [select transaction_id from transaction where transaction_date
= ?param0 and sku_id = ?param1 and node_id = ?param2]
2018-03-15 10:55:08,774-Statement Id: [SelectBatchInsertedTransactionID] Prepared
SQL: [select transaction_id, identifier from transaction where identifier = ?
param0]
2018-03-15 10:55:08,774-Statement Id: [SelectUpdateTransactionImport] Prepared SQL:
[select DISTINCT transaction_id from update_transaction WHERE identifier = ?
param0]
2018-03-15 10:55:08,774-Statement Id: [SelectClosingStockForTransactionDate]
Prepared SQL: [SELECT transaction_date, closing_quantity, sales, grn from
transaction WHERE transaction_date < ?param0 AND sku_id = ?param1
AND node_id = ?param2 ORDER BY transaction_date DESC LIMIT 1]
2018-03-15 10:55:08,774-Statement Id: [InsertTransaction] Prepared SQL: [insert
into transaction (sku_id, node_id, supply_node_id, transaction_date, grn,
sales, closing_quantity, in_transit, inst_hold, quality_hold, qa_hold,
pending_orders, orders_in_hand, transport_mode, db_sync, mongo_sync, created_by,
created_on, open_stock_transfer_order, open_planned_order,
open_purchase_request, open_production_order, open_purchase_order, field1, field2,
field3, field4, field5, field6, field7, field8, field9, field10) values
( ?param0 , ?param1 , ?param2 , ?param3 , ?param4 , ?param5 , ?param6 , ?
param7 , ?param8 , ?param9 , ?param10 , ?param11 , ?param12 , ?param13
, 0, 0, ?param14 , NOW(), ?param15 , ?param16 , ?param17 , ?
param18 , ?param19 , ?param20 , ?param21 , ?param22 , ?param23 , ?param24 ,
?param25 , ?param26 , ?param27 , ?param28 , ?param29 );]
2018-03-15 10:55:08,774-Statement Id: [InsertTransaction.SelectKey] Prepared SQL:
[select last_insert_id() as value]
2018-03-15 10:55:08,774-Statement Id: [InsertTransactionComment] Prepared SQL:
[insert into transaction_comment (transaction_id, sku_id, node_id, comment,
reason, created_by, created_on) values ( ?param0 , ?param1 , ?
param2 , ?param3 , ?param4 , ?param5 , NOW());]
2018-03-15 10:55:08,774-Statement Id: [InsertTransactionComment.SelectKey] Prepared
SQL: [select last_insert_id() as value]
2018-03-15 10:55:08,774-Statement Id: [UpdateTransaction] Prepared SQL: [update
transaction set sku_id = ?param0 , node_id = ?param1 ,
supply_node_id = ?param2 , transaction_date = ?param3 , grn = ?
param4 , sales = ?param5 , closing_quantity = ?param6 ,
in_transit = ?param7 , inst_hold = ?param8 , quality_hold = ?
param9 , qa_hold = ?param10 , pending_orders = ?param11 ,
orders_in_hand = ?param12 , transport_mode = ?param13 , db_sync
= ?param14 , mongo_sync = ?param15 where transaction_id = ?
param16]
2018-03-15 10:55:08,774-Statement Id: [DeleteUpdatesTransaction] Prepared SQL:
[delete from update_transaction WHERE identifier = ?param0]
2018-03-15 10:55:08,774-Adding file [SKUCategoryHelper.xml] to list of watched
files.
2018-03-15 10:55:08,774-Statement Id: [SelectSKUCategoryBySKUCategory] Prepared
SQL: [select sku_category_id, sku_id, category_id, created_by, created_on
from sku_category where sku_id = ?param0 and category_id = ?param1]
2018-03-15 10:55:08,774-Statement Id: [InsertSKUCategory] Prepared SQL: [insert
into sku_category (sku_id, category_id, created_by, created_on)
values ( ?param0 , ?param1 , ?param2 , NOW());]
2018-03-15 10:55:08,774-Statement Id: [InsertSKUCategory.SelectKey] Prepared SQL:
[select last_insert_id() as value]
2018-03-15 10:55:08,774-Adding file [SKUChartHelper.xml] to list of watched files.
2018-03-15 10:55:08,774-Statement Id: [SelectSKUChart] Prepared SQL: [select
rpl.transaction_date, date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date,
sum(rpl.closing_quantity) as closing_quantity, sum(rpl.red_zone_qty) as
red_zone_qty, sum(rpl.yellow_zone_qty) as yellow_zone_qty,
sum(rpl.green_zone_qty) as green_zone_qty, sum(rpl.in_transit) as in_transit,
sum(rpl.sales) as sales, count(distinct(rpl.sku_id)) as total_sku_count,
(select count(distinct(sku_id)) from replenishment where closing_stock_zone_sort =
2 and transaction_date = rpl.transaction_date) as blue_sku_count, (select
count(distinct(sku_id)) from replenishment where (closing_stock_zone_sort = 1 or
closing_stock_zone_sort = 5) and transaction_date = rpl.transaction_date) as
rb_sku_count from replenishment rpl where rpl.transaction_date = ?
param0 group by rpl.transaction_date]
2018-03-15 10:55:08,774-Statement Id: [SelectSKUChartNode] Prepared SQL: [select
rpl.transaction_date, date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date, rpl.node_id,
sum(rpl.closing_quantity) as closing_quantity, sum(rpl.red_zone_qty) as
red_zone_qty, sum(rpl.yellow_zone_qty) as yellow_zone_qty,
sum(rpl.green_zone_qty) as green_zone_qty, sum(rpl.in_transit) as in_transit,
sum(rpl.sales) as sales, count(distinct(rpl.sku_id)) as total_sku_count,
ifnull((select count(distinct(sku_id)) from replenishment where
closing_stock_zone_sort = 2 and transaction_date = rpl.transaction_date and node_id
= rpl.node_id), 0) as blue_sku_count, ifnull((select count(distinct(sku_id))
from replenishment where (closing_stock_zone_sort = 1 or closing_stock_zone_sort =
5) and transaction_date = rpl.transaction_date and node_id = rpl.node_id), 0) as
rb_sku_count from replenishment rpl where rpl.transaction_date = ?
param0 group by rpl.transaction_date, rpl.node_id]
2018-03-15 10:55:08,774-Statement Id: [SelectSKUChartCategory] Prepared SQL:
[select rpl.transaction_date, date_format(rpl.transaction_date,'%d/%m/%Y') as
display_date, date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date,
rpl.category_id, sum(rpl.closing_quantity) as closing_quantity,
sum(rpl.red_zone_qty) as red_zone_qty, sum(rpl.yellow_zone_qty) as yellow_zone_qty,
sum(rpl.green_zone_qty) as green_zone_qty, sum(rpl.in_transit) as in_transit,
sum(rpl.sales) as sales, count(distinct(rpl.sku_id)) as total_sku_count,
ifnull((select count(distinct(sku_id)) from replenishment where
closing_stock_zone_sort = 2 and transaction_date = rpl.transaction_date and
category_id = rpl.category_id), 0) as blue_sku_count, ifnull((select
count(distinct(sku_id)) from replenishment where (closing_stock_zone_sort = 1 or
closing_stock_zone_sort = 5) and transaction_date = rpl.transaction_date and
category_id = rpl.category_id), 0) as rb_sku_count from replenishment rpl
where rpl.transaction_date = ?param0 and rpl.category_id is not null
group by rpl.transaction_date, rpl.category_id]
2018-03-15 10:55:08,774-Statement Id: [SelectSKUChartSKU] Prepared SQL: [select
rpl.transaction_date, date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date, rpl.sku_id,
sum(rpl.closing_quantity) as closing_quantity, sum(rpl.red_zone_qty) as
red_zone_qty, sum(rpl.yellow_zone_qty) as yellow_zone_qty,
sum(rpl.green_zone_qty) as green_zone_qty, sum(rpl.in_transit) as in_transit,
sum(rpl.sales) as sales, count(distinct(rpl.sku_id)) as total_sku_count,
ifnull((select count(distinct(sku_id)) from replenishment where
closing_stock_zone_sort = 2 and transaction_date = rpl.transaction_date and sku_id
= rpl.sku_id), 0) as blue_sku_count, ifnull((select count(distinct(sku_id))
from replenishment where (closing_stock_zone_sort = 1 or closing_stock_zone_sort =
5) and transaction_date = rpl.transaction_date and sku_id = rpl.sku_id), 0) as
rb_sku_count from replenishment rpl use index(inx_sku_chart_s) where
rpl.transaction_date = ?param0 group by rpl.transaction_date, rpl.sku_id]
2018-03-15 10:55:08,774-Adding file [ImportExportLogHelper.xml] to list of watched
files.
2018-03-15 10:55:08,774-Statement Id: [SelectImportExportLogByType] Prepared SQL:
[select import_export_log_id, reference_date, reference_type, reference_title,
type, log_file, status, status_text, comment, created_by, created_on from
import_export_log where type = ?param0 order by reference_date desc]
2018-03-15 10:55:08,774-Statement Id: [InsertImportExportLog] Prepared SQL: [insert
into import_export_log (reference_date, reference_type, reference_title,
type, log_file, status, status_text, comment, created_by, created_on) values
(date_format( ?param0 , "%Y-%c-%e %H:%i:%s"), ?param1 , ?param2 , ?param3 , ?
param4 , ?param5 , ?param6 , ?param7 , ?param8 , NOW() );]
2018-03-15 10:55:08,774-Statement Id: [InsertImportExportLog.SelectKey] Prepared
SQL: [select last_insert_id() as value]
2018-03-15 10:55:08,774-Statement Id: [UpdateImportExportLog] Prepared SQL: [update
import_export_log set reference_date = date_format( ?param0 , "%Y-%c-%e %H:
%i:%s"), reference_type = ?param1 , reference_title = ?param2 ,
type = ?param3 , log_file = ?param4 , status = ?param5 ,
status_text = ?param6 , comment = ?param7 where
import_export_log_id = ?param8]
2018-03-15 10:55:08,790-Statement Id: [DeleteImportExportLog] Prepared SQL: [delete
from import_export_log where import_export_log_id = ?param0]
2018-03-15 10:55:08,790-Adding file [DynamicBufferManagementHelper.xml] to list of
watched files.
2018-03-15 10:55:08,790-Statement Id: [InsertDynamicBufferManagement] Prepared SQL:
[insert into dynamic_buffer_management (activate_auto_dbm,
excess_inv_occ_count, excess_inv_decrease_per, excess_inv_wait_cycle,
stockout_inv_occ_count, stockout_inv_decrease_per, stockout_inv_wait_cycle,
override_sku_location_dbm, activate_auto_dcm, red_percentage,
yellow_percentage, green_percentage, created_by, created_on) values (
?param0 , ?param1 , ?param2 , ?param3 , ?param4 , ?param5 , ?param6 ,
?param7 , ?param8 , ?param9 , ?param10 , ?param11 , ?param12 , NOW());]
2018-03-15 10:55:08,790-Statement Id: [InsertDynamicBufferManagement.SelectKey]
Prepared SQL: [select last_insert_id() as value]
2018-03-15 10:55:08,791-Statement Id: [UpdateDynamicBufferManagement] Prepared SQL:
[update dynamic_buffer_management set activate_auto_dbm = ?param0 ,
excess_inv_occ_count = ?param1 , excess_inv_decrease_per = ?param2 ,
excess_inv_wait_cycle = ?param3 , stockout_inv_occ_count = ?param4 ,
stockout_inv_decrease_per = ?param5 , stockout_inv_wait_cycle = ?param6 ,
override_sku_location_dbm = ?param7 , activate_auto_dcm = ?param8 ,
red_percentage = ?param9 , yellow_percentage = ?param10 ,
green_percentage = ?param11 , modified_by = ?param12 , modified_on
= NOW() where dynamic_buffer_management_id = ?param13]
2018-03-15 10:55:08,791-Adding file [ReplenishmentHelper.xml] to list of watched
files.
2018-03-15 10:55:08,791-Statement Id: [SelectReplenishmentData] Prepared SQL:
[select transaction_id, transaction_date, display_date, transfilter_date, sku_id,
sku_code, sku_name, node_id, node_code, node_name, category_id,
category_code, category_name, buffer_norm, grn, closing_quantity, in_transit,
sales, inst_hold, quality_hold, qa_hold, pending_orders, orders_in_hand,
transport_mode, supply_node_id, supply_node_name, supply_node_code,
supplying_quantity, supplying_buffer_norm, green_zone_qty, yellow_zone_qty,
red_zone_qty, closing_stock_zone, closing_stock_zone_sort, in_transit_zone,
in_transit_zone_sort, supplying_node_zone, supplying_node_zone_sort,
replenishment_quantity, final_quantity, mrq, transaction_comment,
open_stock_transfer_order, open_planned_order, open_purchase_request,
open_production_order, open_purchase_order, field1, field2, field3, field4,
field5, field6, field7, field8, field9, field10, mtd_sales, mtd_grn from
replenishment where transaction_date = ?param0]
2018-03-15 10:55:08,791-Statement Id: [SelectReplenishmentBySKUNode] Prepared SQL:
[select transaction_id, transaction_date, display_date, transfilter_date, sku_id,
sku_code, sku_name, node_id, node_code, node_name, category_id,
category_code, category_name, buffer_norm, closing_quantity, grn, in_transit,
sales, inst_hold, quality_hold, qa_hold, pending_orders, orders_in_hand,
transport_mode, supply_node_id, supply_node_name, supply_node_code,
supplying_quantity, supplying_buffer_norm, green_zone_qty, yellow_zone_qty,
red_zone_qty, closing_stock_zone, closing_stock_zone_sort, in_transit_zone,
in_transit_zone_sort, supplying_node_zone, supplying_node_zone_sort,
replenishment_quantity, final_quantity, mrq, transaction_comment,
open_stock_transfer_order, open_planned_order, open_purchase_request,
open_production_order, open_purchase_order, field1, field2, field3, field4,
field5, field6, field7, field8, field9, field10, mtd_sales, mtd_grn from
replenishment where transaction_date = ?param0 and sku_id = ?
param1 and node_id = ?param2]
2018-03-15 10:55:08,792-Statement Id: [SelectReplenishmentDates] Prepared SQL:
[SELECT DATE_FORMAT(transaction_date,'%Y-%m-%d') AS transaction_date FROM
replenishment USE INDEX (transaction_date) WHERE (transaction_date
BETWEEN ?param0 and ?param1 ) GROUP BY transaction_date]
2018-03-15 10:55:08,792-Statement Id: [InsertReplenishmentList] Prepared SQL:
[insert into replenishment (transaction_id, transaction_date, display_date,
transfilter_date, sku_id, sku_code, sku_name, node_id, node_code, node_name,
category_id, category_code, category_name, buffer_norm, grn, in_transit,
sales, inst_hold, quality_hold, qa_hold, pending_orders, orders_in_hand,
transport_mode, supply_node_id, supply_node_name, supply_node_code,
supplying_quantity, supplying_buffer_norm, green_zone_qty, yellow_zone_qty,
red_zone_qty, closing_stock_zone, closing_stock_zone_sort, in_transit_zone,
in_transit_zone_sort, supplying_node_zone, supplying_node_zone_sort,
replenishment_quantity, final_quantity, mrq, transaction_comment, db_sync,
mongo_sync, open_stock_transfer_order, open_planned_order,
open_purchase_request, open_production_order, open_purchase_order, field1,
field2, field3, field4, field5, field6, field7, field8, field9, field10,
closing_quantity, mtd_sales, mtd_grn ) SELECT tmt.transaction_id,
tmt.transaction_date, tmt.display_date, tmt.transfilter_date, tmt.sku_id,
tmt.sku_code, tmt.sku_name, tmt.node_id, tmt.node_code, tmt.node_name,
tmt.category_id, tmt.category_code, tmt.category_name, tmt.buffer_norm,
tmt.grn, tmt.in_transit, tmt.sales, tmt.inst_hold, tmt.quality_hold,
tmt.qa_hold, tmt.pending_orders, tmt.orders_in_hand, tmt.transport_mode,
tmt.supply_node_id, tmt.supply_node_name, tmt.supply_node_code,
tmt.supplying_quantity, tmt.supplying_buffer_norm, tmt.green_zone_qty,
tmt.yellow_zone_qty, tmt.red_zone_qty, tmt.closing_stock_zone,
tmt.closing_stock_zone_sort, tmt.in_transit_zone, tmt.in_transit_zone_sort,
tmt.supplying_node_zone, tmt.supplying_node_zone_sort,
tmt.replenishment_quantity, tmt.final_quantity, tmt.mrq,
tmt.transaction_comment, tmt.db_sync, tmt.mongo_sync,
tmt.open_stock_transfer_order, tmt.open_planned_order, tmt.open_purchase_request,
tmt.open_production_order, tmt.open_purchase_order, tmt.field1, tmt.field2,
tmt.field3, tmt.field4, tmt.field5, tmt.field6, tmt.field7, tmt.field8, tmt.field9,
tmt.field10, CASE WHEN IFNULL(tmt.closing_quantity,0) > 0 THEN
tmt.closing_quantity ELSE IFNULL((SELECT tcl.closing_quantity FROM
TRANSACTION tcl WHERE tcl.transaction_date < tmt.transaction_date AND
tcl.sku_id = tmt.sku_id AND tcl.node_id = tmt.node_id ORDER BY
tcl.transaction_date DESC LIMIT 1), 0) END AS closing_quantity,
IFNULL((SELECT SUM(tms.sales) FROM TRANSACTION tms USE INDEX
(inx_tdt_sku_node_sales) WHERE tms.transaction_date <= tmt.transaction_date
AND tms.transaction_date >= DATE_FORMAT(tmt.transaction_date,'%Y-%m-01') AND
tms.sku_id = tmt.sku_id AND tms.node_id = tmt.node_id), 0) AS mtd_sales,
IFNULL((SELECT SUM(tmg.grn) FROM TRANSACTION tmg USE INDEX (inx_tdt_sku_node_grn)
WHERE tmg.transaction_date <= tmt.transaction_date AND tmg.transaction_date >=
DATE_FORMAT(tmt.transaction_date,'%Y-%m-01') AND tmg.sku_id = tmt.sku_id AND
tmg.node_id = tmt.node_id), 0) AS mtd_grn FROM (SELECT
tr.transaction_id, tr.transaction_date, DATE_FORMAT(tr.transaction_date,'%d/%m/%Y')
AS display_date, DATE_FORMAT(tr.transaction_date,'%Y%m%d') AS transfilter_date,
tr.sku_id, s.sku_code, s.sku_name, tr.node_id, n.node_code, n.node_name,
sc.category_id, cat.category_code, cat.category_name, IFNULL(bn.buffer_norm,
0) AS buffer_norm, IFNULL(tr.closing_quantity, 0) AS closing_quantity,
IFNULL(tr.grn,0) AS grn, IFNULL(tr.in_transit, 0) AS in_transit, IFNULL(tr.sales,
0) AS sales, IFNULL(tr.inst_hold, 0) AS inst_hold, IFNULL(tr.quality_hold,
0) AS quality_hold, IFNULL(tr.qa_hold, 0) AS qa_hold,
IFNULL(tr.pending_orders, 0) AS pending_orders, IFNULL(tr.orders_in_hand, 0) AS
orders_in_hand, IFNULL(tr.transport_mode, '') AS transport_mode, CASE WHEN
IFNULL(tr.supply_node_id,0) > 0 THEN IFNULL(tr.supply_node_id,0) ELSE
IFNULL(nsm.supplier_node_id,0) END AS supply_node_id, sn.node_name AS
supply_node_name, sn.node_code AS supply_node_code,
IFNULL(str.closing_quantity, 0) AS supplying_quantity,
IFNULL(sbn.buffer_norm, 0) AS supplying_buffer_norm,
ROUND(IFNULL(bn.buffer_norm, 0),2) AS 'green_zone_qty', CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2)
END AS 'yellow_zone_qty', CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END AS 'red_zone_qty', CASE
WHEN IFNULL(bn.buffer_norm, 0) = 0 THEN 'White' WHEN
(IFNULL(tr.closing_quantity, 0) <= 0 AND IFNULL(bn.buffer_norm, 0) > 0) THEN
'Black' WHEN (IFNULL(tr.closing_quantity, 0) > IFNULL(bn.buffer_norm, 0) AND
IFNULL(bn.buffer_norm, 0) > 0) THEN 'Blue' WHEN (IFNULL(tr.closing_quantity,
0) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(tr.closing_quantity,
0) <= IFNULL(bn.buffer_norm, 0) AND IFNULL(bn.buffer_norm, 0) > 0) THEN 'Green'
WHEN (IFNULL(tr.closing_quantity, 0) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(tr.closing_quantity, 0) <=
(CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(bn.buffer_norm, 0) >
0) THEN 'Yellow' WHEN (IFNULL(tr.closing_quantity, 0) > 0 AND
IFNULL(tr.closing_quantity, 0) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(bn.buffer_norm, 0) > 0) THEN
'Red' END AS 'closing_stock_zone', CASE WHEN
IFNULL(bn.buffer_norm, 0) = 0 THEN 6 WHEN (IFNULL(tr.closing_quantity, 0) <=
0 AND IFNULL(bn.buffer_norm, 0) > 0) THEN 1 WHEN
(IFNULL(tr.closing_quantity, 0) > IFNULL(bn.buffer_norm, 0) AND
IFNULL(bn.buffer_norm, 0) > 0) THEN 2 WHEN (IFNULL(tr.closing_quantity, 0) >
(CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(tr.closing_quantity,
0) <= IFNULL(bn.buffer_norm, 0) AND IFNULL(bn.buffer_norm, 0) > 0) THEN 4
WHEN (IFNULL(tr.closing_quantity, 0) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(tr.closing_quantity, 0) <=
(CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(bn.buffer_norm, 0) >
0) THEN 3 WHEN (IFNULL(tr.closing_quantity, 0) > 0 AND
IFNULL(tr.closing_quantity, 0) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(bn.buffer_norm, 0) > 0) THEN
5 END AS 'closing_stock_zone_sort', CASE WHEN
IFNULL(bn.buffer_norm, 0) = 0 THEN 'White' WHEN
((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) <= 0 AND IFNULL(bn.buffer_norm, 0) > 0) THEN 'Black'
WHEN ((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > IFNULL(bn.buffer_norm, 0) AND
IFNULL(bn.buffer_norm, 0) > 0) THEN 'Blue' WHEN
((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND
(IFNULL(tr.closing_quantity, 0) + tr.in_transit - tr.pending_orders) <=
IFNULL(bn.buffer_norm, 0) AND IFNULL(bn.buffer_norm, 0) > 0) THEN 'Green'
WHEN ((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND (tr.closing_quantity +
tr.in_transit - tr.pending_orders) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2)
ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(bn.buffer_norm,
0) > 0) THEN 'Yellow' WHEN ((IFNULL(tr.closing_quantity, 0) +
IFNULL(tr.in_transit, 0) - IFNULL(tr.pending_orders, 0)) > 0 AND
(IFNULL(tr.closing_quantity, 0) + tr.in_transit - tr.pending_orders) <= (CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND
IFNULL(bn.buffer_norm, 0) > 0) THEN 'Red' END AS 'in_transit_zone',
CASE WHEN IFNULL(bn.buffer_norm, 0) = 0 THEN 6 WHEN
((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) <= 0 AND IFNULL(bn.buffer_norm, 0) > 0) THEN 1
WHEN ((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > IFNULL(bn.buffer_norm, 0) AND
IFNULL(bn.buffer_norm,
0) > 0) THEN 2 WHEN ((IFNULL(tr.closing_quantity, 0) +
IFNULL(tr.in_transit, 0) - IFNULL(tr.pending_orders, 0)) > (CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2)
END) AND (IFNULL(tr.closing_quantity, 0) + tr.in_transit - tr.pending_orders) <=
IFNULL(bn.buffer_norm, 0) AND IFNULL(bn.buffer_norm, 0) > 0) THEN 4 WHEN
((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND (IFNULL(tr.closing_quantity, 0) +
tr.in_transit - tr.pending_orders) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2)
ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(bn.buffer_norm,
0) > 0) THEN 3 WHEN ((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit,
0) - IFNULL(tr.pending_orders, 0)) > 0 AND (IFNULL(tr.closing_quantity, 0) +
tr.in_transit - tr.pending_orders) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(bn.buffer_norm, 0) > 0) THEN
5 END AS 'in_transit_zone_sort', CASE WHEN
IFNULL(sbn.buffer_norm, 0) = 0 THEN 'White' WHEN
(IFNULL(str.closing_quantity, 0) <= 0 AND IFNULL(sbn.buffer_norm, 0) > 0) THEN
'Black' WHEN (IFNULL(str.closing_quantity, 0) > IFNULL(sbn.buffer_norm, 0)
AND IFNULL(sbn.buffer_norm, 0) > 0) THEN 'Blue' WHEN
(IFNULL(str.closing_quantity, 0) > (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) AND
IFNULL(str.closing_quantity, 0) <= IFNULL(sbn.buffer_norm, 0) AND
IFNULL(sbn.buffer_norm, 0) > 0) THEN 'Green' WHEN
(IFNULL(str.closing_quantity, 0) > (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) AND IFNULL(str.closing_quantity, 0) <=
(CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) AND IFNULL(sbn.buffer_norm, 0)
> 0) THEN 'Yellow' WHEN (IFNULL(str.closing_quantity, 0) > 0 AND
IFNULL(str.closing_quantity, 0) <= (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) AND IFNULL(sbn.buffer_norm, 0) > 0)
THEN 'Red' END AS 'supplying_node_zone', CASE WHEN
IFNULL(sbn.buffer_norm, 0) = 0 THEN 6 WHEN (IFNULL(str.closing_quantity, 0)
<= 0 AND IFNULL(sbn.buffer_norm, 0) > 0) THEN 1 WHEN
(IFNULL(str.closing_quantity, 0) > IFNULL(sbn.buffer_norm, 0) AND
IFNULL(sbn.buffer_norm, 0) > 0) THEN 2 WHEN (IFNULL(str.closing_quantity, 0)
> (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) AND
IFNULL(str.closing_quantity, 0) <= IFNULL(sbn.buffer_norm, 0) AND
IFNULL(sbn.buffer_norm, 0) > 0) THEN 4 WHEN (IFNULL(str.closing_quantity, 0)
> (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) AND IFNULL(str.closing_quantity, 0) <=
(CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) AND IFNULL(sbn.buffer_norm, 0)
> 0) THEN 3 WHEN (IFNULL(str.closing_quantity, 0) > 0 AND
IFNULL(str.closing_quantity, 0) <= (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) AND IFNULL(sbn.buffer_norm, 0) > 0)
THEN 5 END AS 'supplying_node_zone_sort', CASE WHEN
((IFNULL(bn.buffer_norm, 0) - IFNULL(tr.closing_quantity, 0) -
IFNULL(tr.in_transit, 0)) + IFNULL(tr.pending_orders, 0)) -
(IFNULL(tr.open_planned_order, 0) + IFNULL(tr.open_purchase_request, 0) +
IFNULL(tr.open_production_order, 0) + IFNULL(tr.open_purchase_order, 0)) <= 0 THEN
0 ELSE ((IFNULL(bn.buffer_norm, 0) - IFNULL(tr.closing_quantity, 0) -
IFNULL(tr.in_transit, 0)) + IFNULL(tr.pending_orders, 0)) -
(IFNULL(tr.open_planned_order, 0) + IFNULL(tr.open_purchase_request, 0) +
IFNULL(tr.open_production_order, 0) + IFNULL(tr.open_purchase_order, 0)) END
AS 'replenishment_quantity', CASE WHEN (IFNULL(tr.closing_quantity,
0) + IFNULL(tr.in_transit, 0) + IFNULL(tr.open_planned_order, 0) +
IFNULL(tr.open_purchase_request, 0) + IFNULL(tr.open_production_order, 0) +
IFNULL(tr.open_purchase_order, 0) ) - IFNULL(tr.pending_orders, 0) <= 0 THEN 0
ELSE (IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) +
IFNULL(tr.open_planned_order, 0) + IFNULL(tr.open_purchase_request, 0) +
IFNULL(tr.open_production_order, 0) + IFNULL(tr.open_purchase_order, 0) ) -
IFNULL(tr.pending_orders, 0) END AS 'final_quantity', CASE
WHEN IFNULL(bn.buffer_norm, 0) = 0 THEN 0 ELSE (CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END)
END AS 'mrq', (SELECT COUNT(1) FROM transaction_comment WHERE
transaction_id = tr.transaction_id) AS 'transaction_comment', 0 AS db_sync, 0 AS
mongo_sync, IFNULL(tr.open_stock_transfer_order, 0) AS
open_stock_transfer_order, IFNULL(tr.open_planned_order, 0) AS open_planned_order,
IFNULL(tr.open_purchase_request, 0) AS open_purchase_request,
IFNULL(tr.open_production_order, 0) AS open_production_order,
IFNULL(tr.open_purchase_order, 0) AS open_purchase_order, tr.field1,
tr.field2, tr.field3, tr.field4, tr.field5, tr.field6, tr.field7, tr.field8,
tr.field9, tr.field10 from ( select tt.transaction_id from
transaction tt use index (transaction_date) inner join update_transaction ut
use index (inx_transactionid) on ut.transaction_id = tt.transaction_id
where tt.transaction_date = ?param0 ORDER BY tt.sku_id limit ?
param1 , ?param2 ) otr join transaction tr on
tr.transaction_id = otr.transaction_id LEFT JOIN buffer_norm bn USE INDEX
(inx_sku_node_efdt) ON bn.sku_id = tr.sku_id AND bn.node_id =
tr.node_id AND bn.effective_from = ( SELECT MAX(effective_from) FROM
buffer_norm WHERE effective_from <= tr.transaction_date AND sku_id =
tr.sku_id AND node_id = tr.node_id) LEFT JOIN sku s ON
s.sku_id = tr.sku_id LEFT JOIN sku_category sc ON
sc.sku_category_id = (SELECT sku_category_id FROM sku_category WHERE sku_id =
tr.sku_id LIMIT 1) LEFT JOIN category cat ON cat.category_id =
sc.category_id LEFT JOIN node n ON n.node_id = tr.node_id
LEFT OUTER JOIN node_sku_mapping nsm USE INDEX (inx_sku_receiver_node_efdt)
ON nsm.receiver_node_id = tr.node_id AND nsm.sku_id = tr.sku_id AND
nsm.effective_date = ( SELECT MAX(effective_date) FROM node_sku_mapping
WHERE effective_date <= tr.transaction_date AND sku_id = tr.sku_id
AND receiver_node_id = tr.node_id) LEFT JOIN node sn ON CASE WHEN
IFNULL(tr.supply_node_id,0) > 0 THEN sn.node_id = tr.supply_node_id ELSE
sn.node_id = nsm.supplier_node_id END LEFT JOIN buffer_norm sbn USE INDEX
(inx_sku_node_efdt) ON sbn.sku_id = tr.sku_id AND CASE WHEN
IFNULL(tr.supply_node_id,0) > 0 THEN sbn.node_id = tr.supply_node_id ELSE
sbn.node_id = nsm.supplier_node_id END AND sbn.effective_from =
( SELECT MAX(effective_from) FROM buffer_norm WHERE effective_from <=
tr.transaction_date AND sku_id = tr.sku_id AND node_id = tr.node_id)
LEFT JOIN TRANSACTION str USE INDEX (inx_tdt_sku_node_snode) ON
str.transaction_date = tr.transaction_date AND str.sku_id = tr.sku_id
AND CASE WHEN IFNULL(tr.supply_node_id,0) > 0 THEN str.node_id =
IFNULL(tr.supply_node_id,0) ELSE str.node_id = nsm.supplier_node_id END
GROUP BY tr.transaction_id ORDER BY tr.transaction_id) tmt ON
DUPLICATE KEY UPDATE category_id=VALUES(category_id),
category_code=VALUES(category_code), category_name=VALUES(category_name),
buffer_norm=VALUES(buffer_norm), closing_quantity=VALUES(closing_quantity),
grn=VALUES(grn), in_transit=VALUES(in_transit), sales=VALUES(sales),
inst_hold=VALUES(inst_hold), quality_hold=VALUES(quality_hold),
qa_hold=VALUES(qa_hold), pending_orders=VALUES(pending_orders),
orders_in_hand=VALUES(orders_in_hand), mtd_sales=VALUES(mtd_sales),
mtd_grn=VALUES(mtd_grn), transport_mode=VALUES(transport_mode),
supply_node_id=VALUES(supply_node_id), supply_node_name=VALUES(supply_node_name),
supply_node_code=VALUES(supply_node_code),
supplying_quantity=VALUES(supplying_quantity),
supplying_buffer_norm=VALUES(supplying_buffer_norm),
green_zone_qty=VALUES(green_zone_qty), yellow_zone_qty=VALUES(yellow_zone_qty),
red_zone_qty=VALUES(red_zone_qty), closing_stock_zone=VALUES(closing_stock_zone),
closing_stock_zone_sort=VALUES(closing_stock_zone_sort),
in_transit_zone=VALUES(in_transit_zone),
in_transit_zone_sort=VALUES(in_transit_zone_sort),
supplying_node_zone=VALUES(supplying_node_zone),
supplying_node_zone_sort=VALUES(supplying_node_zone_sort),
replenishment_quantity=VALUES(replenishment_quantity),
final_quantity=VALUES(final_quantity), mrq=VALUES(mrq), db_sync=VALUES(db_sync),
mongo_sync=VALUES(mongo_sync),
open_stock_transfer_order=VALUES(open_stock_transfer_order),
open_planned_order=VALUES(open_planned_order),
open_purchase_request=VALUES(open_purchase_request),
open_production_order=VALUES(open_production_order),
open_purchase_order=VALUES(open_purchase_order), field1=VALUES(field1),
field2=VALUES(field2), field3=VALUES(field3), field4=VALUES(field4),
field5=VALUES(field5), field6=VALUES(field6), field7=VALUES(field7),
field8=VALUES(field8), field9=VALUES(field9), field10=VALUES(field10);]
2018-03-15 10:55:08,792-Statement Id: [InsertReplenishmentListFullSync] Prepared
SQL: [insert into replenishment (transaction_id, transaction_date,
display_date, transfilter_date, sku_id, sku_code, sku_name, node_id, node_code,
node_name, category_id, category_code, category_name, buffer_norm,
closing_quantity, in_transit, sales, inst_hold, quality_hold, qa_hold,
pending_orders, orders_in_hand, transport_mode, supply_node_id,
supply_node_name, supply_node_code, supplying_quantity, supplying_buffer_norm,
green_zone_qty, yellow_zone_qty, red_zone_qty, closing_stock_zone,
closing_stock_zone_sort, in_transit_zone, in_transit_zone_sort,
supplying_node_zone, supplying_node_zone_sort, replenishment_quantity,
final_quantity, mrq, transaction_comment, db_sync, mongo_sync,
open_stock_transfer_order, open_planned_order, open_purchase_request,
open_production_order, open_purchase_order, field1, field2, field3, field4, field5,
field6, field7, field8, field9, field10 ) SELECT tr.transaction_id,
tr.transaction_date, DATE_FORMAT(tr.transaction_date,'%d/%m/%Y') AS display_date,
DATE_FORMAT(tr.transaction_date,'%Y%m%d') AS transfilter_date, tr.sku_id,
s.sku_code, s.sku_name, tr.node_id, n.node_code, n.node_name, sc.category_id,
cat.category_code, cat.category_name, IFNULL(bn.buffer_norm, 0) AS
buffer_norm, IFNULL(tr.closing_quantity, 0) AS closing_quantity,
IFNULL(tr.in_transit, 0) AS in_transit, IFNULL(tr.sales, 0) AS sales,
IFNULL(tr.inst_hold, 0) AS inst_hold, IFNULL(tr.quality_hold, 0) AS quality_hold,
IFNULL(tr.qa_hold, 0) AS qa_hold, IFNULL(tr.pending_orders, 0) AS
pending_orders, IFNULL(tr.orders_in_hand, 0) AS orders_in_hand,
IFNULL(tr.transport_mode, '') AS transport_mode, CASE WHEN
IFNULL(tr.supply_node_id,0) > 0 THEN IFNULL(tr.supply_node_id,0) ELSE
IFNULL(nsm.supplier_node_id,0) END AS supply_node_id, sn.node_name AS
supply_node_name, sn.node_code AS supply_node_code,
IFNULL(str.closing_quantity, 0) AS supplying_quantity,
IFNULL(sbn.buffer_norm, 0) AS supplying_buffer_norm,
ROUND(IFNULL(bn.buffer_norm, 0),2) AS 'green_zone_qty', CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2)
END AS 'yellow_zone_qty', CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END AS 'red_zone_qty', CASE
WHEN IFNULL(bn.buffer_norm, 0) = 0 THEN 'White' WHEN
(IFNULL(tr.closing_quantity, 0) <= 0 AND IFNULL(bn.buffer_norm, 0) > 0) THEN
'Black' WHEN (IFNULL(tr.closing_quantity, 0) > IFNULL(bn.buffer_norm, 0) AND
IFNULL(bn.buffer_norm, 0) > 0) THEN 'Blue' WHEN (IFNULL(tr.closing_quantity,
0) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(tr.closing_quantity,
0) <= IFNULL(bn.buffer_norm, 0) AND IFNULL(bn.buffer_norm, 0) > 0) THEN 'Green'
WHEN (IFNULL(tr.closing_quantity, 0) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(tr.closing_quantity, 0) <=
(CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(bn.buffer_norm, 0) >
0) THEN 'Yellow' WHEN (IFNULL(tr.closing_quantity, 0) > 0 AND
IFNULL(tr.closing_quantity, 0) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(bn.buffer_norm, 0) > 0) THEN
'Red' END AS 'closing_stock_zone', CASE WHEN
IFNULL(bn.buffer_norm, 0) = 0 THEN 6 WHEN (IFNULL(tr.closing_quantity, 0) <=
0 AND IFNULL(bn.buffer_norm, 0) > 0) THEN 1 WHEN
(IFNULL(tr.closing_quantity, 0) > IFNULL(bn.buffer_norm, 0) AND
IFNULL(bn.buffer_norm, 0) > 0) THEN 2 WHEN (IFNULL(tr.closing_quantity, 0) >
(CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(tr.closing_quantity,
0) <= IFNULL(bn.buffer_norm, 0) AND IFNULL(bn.buffer_norm, 0) > 0) THEN 4
WHEN (IFNULL(tr.closing_quantity, 0) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(tr.closing_quantity, 0) <=
(CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(bn.buffer_norm, 0) >
0) THEN 3 WHEN (IFNULL(tr.closing_quantity, 0) > 0 AND
IFNULL(tr.closing_quantity, 0) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(bn.buffer_norm, 0) > 0) THEN
5 END AS 'closing_stock_zone_sort', CASE WHEN
IFNULL(bn.buffer_norm, 0) = 0 THEN 'White' WHEN
((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) <= 0 AND IFNULL(bn.buffer_norm, 0) > 0) THEN 'Black'
WHEN ((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > IFNULL(bn.buffer_norm, 0) AND
IFNULL(bn.buffer_norm, 0) > 0) THEN 'Blue' WHEN
((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND
(IFNULL(tr.closing_quantity, 0) + tr.in_transit - tr.pending_orders) <=
IFNULL(bn.buffer_norm, 0) AND IFNULL(bn.buffer_norm, 0) > 0) THEN 'Green'
WHEN ((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND (tr.closing_quantity +
tr.in_transit - tr.pending_orders) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2)
ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(bn.buffer_norm,
0) > 0) THEN 'Yellow' WHEN ((IFNULL(tr.closing_quantity, 0) +
IFNULL(tr.in_transit, 0) - IFNULL(tr.pending_orders, 0)) > 0 AND
(IFNULL(tr.closing_quantity, 0) + tr.in_transit - tr.pending_orders) <= (CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND
IFNULL(bn.buffer_norm, 0) > 0) THEN 'Red' END AS 'in_transit_zone',
CASE WHEN IFNULL(bn.buffer_norm, 0) = 0 THEN 6 WHEN
((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) <= 0 AND IFNULL(bn.buffer_norm, 0) > 0) THEN 1
WHEN ((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > IFNULL(bn.buffer_norm, 0) AND
IFNULL(bn.buffer_norm, 0) > 0) THEN 2 WHEN ((IFNULL(tr.closing_quantity, 0)
+ IFNULL(tr.in_transit, 0) - IFNULL(tr.pending_orders, 0)) > (CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2)
END) AND (IFNULL(tr.closing_quantity, 0) + tr.in_transit - tr.pending_orders) <=
IFNULL(bn.buffer_norm, 0) AND IFNULL(bn.buffer_norm, 0) > 0) THEN 4 WHEN
((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND (IFNULL(tr.closing_quantity, 0) +
tr.in_transit - tr.pending_orders) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2)
ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(bn.buffer_norm,
0) > 0) THEN 3 WHEN ((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit,
0) - IFNULL(tr.pending_orders, 0)) > 0 AND (IFNULL(tr.closing_quantity, 0) +
tr.in_transit - tr.pending_orders) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(bn.buffer_norm, 0) > 0) THEN
5 END AS 'in_transit_zone_sort', CASE WHEN
IFNULL(sbn.buffer_norm, 0) = 0 THEN 'White' WHEN
(IFNULL(str.closing_quantity, 0) <= 0 AND IFNULL(sbn.buffer_norm, 0) > 0) THEN
'Black' WHEN (IFNULL(str.closing_quantity, 0) > IFNULL(sbn.buffer_norm, 0)
AND IFNULL(sbn.buffer_norm, 0) > 0) THEN 'Blue' WHEN
(IFNULL(str.closing_quantity, 0) > (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) AND
IFNULL(str.closing_quantity, 0) <= IFNULL(sbn.buffer_norm, 0) AND
IFNULL(sbn.buffer_norm, 0) > 0) THEN 'Green' WHEN
(IFNULL(str.closing_quantity, 0) > (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.red_zone,0)
/ 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE ROUND(IFNULL(sbn.buffer_norm, 0) /
3,2) END) AND IFNULL(str.closing_quantity, 0) <= (CASE WHEN
IFNULL(sbn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(sbn.yellow_zone,0) / 100)
* IFNULL(sbn.buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(sbn.buffer_norm,
0)),2) END) AND IFNULL(sbn.buffer_norm, 0) > 0) THEN 'Yellow' WHEN
(IFNULL(str.closing_quantity, 0) > 0 AND IFNULL(str.closing_quantity, 0) <= (CASE
WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(sbn.red_zone,0) /
100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2)
END) AND IFNULL(sbn.buffer_norm, 0) > 0) THEN 'Red' END AS
'supplying_node_zone', CASE WHEN IFNULL(sbn.buffer_norm, 0) = 0
THEN 6 WHEN (IFNULL(str.closing_quantity, 0) <= 0 AND
IFNULL(sbn.buffer_norm, 0) > 0) THEN 1 WHEN (IFNULL(str.closing_quantity, 0)
> IFNULL(sbn.buffer_norm, 0) AND IFNULL(sbn.buffer_norm, 0) > 0) THEN 2 WHEN
(IFNULL(str.closing_quantity, 0) > (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) AND
IFNULL(str.closing_quantity, 0) <= IFNULL(sbn.buffer_norm, 0) AND
IFNULL(sbn.buffer_norm, 0) > 0) THEN 4 WHEN (IFNULL(str.closing_quantity, 0)
> (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) AND IFNULL(str.closing_quantity, 0) <=
(CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) AND IFNULL(sbn.buffer_norm, 0)
> 0) THEN 3 WHEN (IFNULL(str.closing_quantity, 0) > 0 AND
IFNULL(str.closing_quantity, 0) <= (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) AND IFNULL(sbn.buffer_norm, 0) > 0)
THEN 5 END AS 'supplying_node_zone_sort', CASE WHEN
((IFNULL(bn.buffer_norm, 0) - IFNULL(tr.closing_quantity, 0) -
IFNULL(tr.in_transit, 0)) + IFNULL(tr.pending_orders, 0)) -
(IFNULL(tr.open_planned_order, 0) + IFNULL(tr.open_purchase_request, 0) +
IFNULL(tr.open_production_order, 0) + IFNULL(tr.open_purchase_order, 0)) <= 0 THEN
0 ELSE ((IFNULL(bn.buffer_norm, 0) - IFNULL(tr.closing_quantity, 0) -
IFNULL(tr.in_transit, 0)) + IFNULL(tr.pending_orders, 0)) -
(IFNULL(tr.open_planned_order, 0) + IFNULL(tr.open_purchase_request, 0) +
IFNULL(tr.open_production_order, 0) + IFNULL(tr.open_purchase_order, 0)) END
AS 'replenishment_quantity', CASE WHEN (IFNULL(tr.closing_quantity,
0) + IFNULL(tr.in_transit, 0) + IFNULL(tr.open_planned_order, 0) +
IFNULL(tr.open_purchase_request, 0) + IFNULL(tr.open_production_order, 0) +
IFNULL(tr.open_purchase_order, 0) ) - IFNULL(tr.pending_orders, 0) <= 0 THEN 0
ELSE (IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) +
IFNULL(tr.open_planned_order, 0) + IFNULL(tr.open_purchase_request, 0) +
IFNULL(tr.open_production_order, 0) + IFNULL(tr.open_purchase_order, 0) ) -
IFNULL(tr.pending_orders, 0) END AS 'final_quantity', CASE
WHEN IFNULL(bn.buffer_norm, 0) = 0 THEN 0 ELSE (CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END)
END AS 'mrq', (SELECT COUNT(1) FROM transaction_comment WHERE
transaction_id = tr.transaction_id) AS 'transaction_comment', 0 AS db_sync, 0 AS
mongo_sync, IFNULL(tr.open_stock_transfer_order, 0),
IFNULL(tr.open_planned_order, 0), IFNULL(tr.open_purchase_request,
0),IFNULL(tr.open_production_order, 0), IFNULL(tr.open_purchase_order, 0),
tr.field1, tr.field2, tr.field3, tr.field4, tr.field5, tr.field6, tr.field7,
tr.field8, tr.field9, tr.field10 from ( select tt.transaction_id
from transaction tt use index (transaction_date) where
tt.transaction_date = ?param0 ORDER BY tt.sku_id limit ?
param1 , ?param2 ) otr join transaction tr on
tr.transaction_id = otr.transaction_id LEFT JOIN buffer_norm bn USE INDEX
(inx_sku_node_efdt) ON bn.sku_id = tr.sku_id AND bn.node_id =
tr.node_id AND bn.effective_from = ( SELECT MAX(effective_from) FROM
buffer_norm WHERE effective_from <= tr.transaction_date AND sku_id =
tr.sku_id AND node_id = tr.node_id) LEFT JOIN sku s ON
s.sku_id = tr.sku_id LEFT JOIN sku_category sc ON
sc.sku_category_id = (SELECT sku_category_id FROM sku_category WHERE sku_id =
tr.sku_id LIMIT 1) LEFT JOIN category cat ON cat.category_id =
sc.category_id LEFT JOIN node n ON n.node_id = tr.node_id
LEFT OUTER JOIN node_sku_mapping nsm USE INDEX (inx_sku_receiver_node_efdt)
ON nsm.receiver_node_id = tr.node_id AND nsm.sku_id = tr.sku_id AND
nsm.effective_date = ( SELECT MAX(effective_date) FROM node_sku_mapping
WHERE effective_date <= tr.transaction_date AND sku_id = tr.sku_id
AND receiver_node_id = tr.node_id) LEFT JOIN node sn ON CASE WHEN
IFNULL(tr.supply_node_id,0) > 0 THEN sn.node_id = tr.supply_node_id ELSE
sn.node_id = nsm.supplier_node_id END LEFT JOIN buffer_norm sbn USE INDEX
(inx_sku_node_efdt) ON sbn.sku_id = tr.sku_id AND CASE WHEN
IFNULL(tr.supply_node_id,0) > 0 THEN sbn.node_id = tr.supply_node_id ELSE
sbn.node_id = nsm.supplier_node_id END AND sbn.effective_from =
( SELECT MAX(effective_from) FROM buffer_norm WHERE effective_from <=
tr.transaction_date AND sku_id = tr.sku_id AND node_id = tr.node_id)
LEFT JOIN TRANSACTION str USE INDEX (inx_tdt_sku_node_snode) ON
str.transaction_date = tr.transaction_date AND str.sku_id = tr.sku_id
AND CASE WHEN IFNULL(tr.supply_node_id,0) > 0 THEN str.node_id =
IFNULL(tr.supply_node_id,0) ELSE str.node_id = nsm.supplier_node_id END
GROUP BY tr.transaction_id ORDER BY tr.transaction_id]
2018-03-15 10:55:08,792-Adding file [UserHelper.xml] to list of watched files.
2018-03-15 10:55:08,792-Statement Id: [SelectUserNameDuplicate] Prepared SQL:
[select user_id, user_name, first_name, middle_name, last_name, email, mobile,
description, password, status, approved, locked, role_id, region_id,
created_by, created_on, modified_by, modified_on from user where user_name =
?param0 and user_id != ?param1]
2018-03-15 10:55:08,792-Statement Id: [SelectUserMobileDuplicate] Prepared SQL:
[select user_id, user_name, first_name, middle_name, last_name, email, mobile,
description, password, status, approved, locked, role_id, region_id,
created_by, created_on, modified_by, modified_on from user where mobile = ?
param0 and user_id != ?param1]
2018-03-15 10:55:08,792-Statement Id: [SelectUserCheckAuthenticate] Prepared SQL:
[select user_id, user_name, first_name, middle_name, last_name, email, mobile,
description, password, status, approved, locked, role_id, region_id,
created_by, created_on, modified_by, modified_on from user where user_name =
?param0 and password = ?param1 and status = 1]
2018-03-15 10:55:08,792-Statement Id: [SelectUserCheckLocked] Prepared SQL: [select
user_id, user_name, first_name, middle_name, last_name, email, mobile, description,
password, status, approved, locked, role_id, region_id, created_by,
created_on, modified_by, modified_on from user where user_name = ?param0]
2018-03-15 10:55:08,792-Statement Id: [InsertUser] Prepared SQL: [insert into user
(user_name, first_name, middle_name, last_name, email, mobile, description,
password, status, approved, locked, role_id, region_id, created_by,
created_on) values ( ?param0 , ?param1 , ?param2 , ?param3 , ?
param4 , ?param5 , ?param6 , ?param7 , ?param8 , ?param9 , ?param10 ,
?param11 , ?param12 , ?param13 , NOW());]
2018-03-15 10:55:08,792-Statement Id: [InsertUser.SelectKey] Prepared SQL: [select
last_insert_id() as value]
2018-03-15 10:55:08,792-Statement Id: [UpdateUser] Prepared SQL: [update user set
user_name = ?param0 , first_name = ?param1 , middle_name = ?param2
, last_name = ?param3 , email = ?param4 , mobile = ?
param5 , description = ?param6 , password = ?param7 , status
= ?param8 , approved = ?param9 , locked = ?param10 ,
role_id = ?param11 , region_id = ?param12 , modified_by = ?param13
, modified_on = NOW() where user_id = ?param14]
2018-03-15 10:55:08,792-Statement Id: [DeleteUser] Prepared SQL: [delete from user
where user_id = ?param0]
2018-03-15 10:55:08,792-Adding file [UserModuleHelper.xml] to list of watched
files.
2018-03-15 10:55:08,792-Statement Id: [InsertUserModule] Prepared SQL: [insert into
user_module (role_id, module_id, created_by, created_on) values
( ?param0 , ?param1 , ?param2 , NOW());]
2018-03-15 10:55:08,792-Statement Id: [InsertUserModule.SelectKey] Prepared SQL:
[select last_insert_id() as value]
2018-03-15 10:55:08,792-Statement Id: [DeleteUserModule] Prepared SQL: [delete from
user_module where user_module_id = ?param0]
2018-03-15 10:55:08,792-Statement Id: [DeleteModuleByRole] Prepared SQL: [delete
from user_module where role_id = ?param0]
2018-03-15 10:55:08,792-Adding file [SKUGridHelper.xml] to list of watched files.
2018-03-15 10:55:08,792-Statement Id: [SelectSKUGrid] Prepared SQL: [select
s.sku_name, n.node_name, c.category_id, c.category_name, sku_grid.*, case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (1 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(1 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (1 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (1 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (1 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (1 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (1 * avg_sales)) > 0 and (closing_quantity - (1 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(red_zone,0) /
100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and
buffer_norm > 0) then 'Red' end as 'one', case when (closing_quantity
- (1 * avg_sales)) <= 0 then 0 else (closing_quantity - (1 * avg_sales)) end as
'one_qty', case when ifnull(buffer_norm, 0) = 0 then 'White'
when ((closing_quantity - (2 * avg_sales)) <= 0 and buffer_norm > 0) then 'Black'
when ((closing_quantity - (2 * avg_sales)) > buffer_norm and buffer_norm > 0) then
'Blue' when ((closing_quantity - (2 * avg_sales)) > (CASE WHEN
IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) *
IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END)
and (closing_quantity - (2 * avg_sales)) <= buffer_norm and buffer_norm > 0) then
'Green' when ((closing_quantity - (2 * avg_sales)) > (CASE WHEN
IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(red_zone,0) / 100) *
IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and
(closing_quantity - (2 * avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow'
when ((closing_quantity - (2 * avg_sales)) > 0 and (closing_quantity - (2 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'two', case when (closing_quantity - (2 * avg_sales)) <= 0 then 0 else
(closing_quantity - (2 * avg_sales)) end as 'two_qty', case when
ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (3 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(3 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (3 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (3 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (3 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (3 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (3 * avg_sales)) > 0 and (closing_quantity - (3 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(red_zone,0) /
100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and
buffer_norm > 0) then 'Red' end as 'three', case when
(closing_quantity - (3 * avg_sales)) <= 0 then 0 else (closing_quantity - (3 *
avg_sales)) end as 'three_qty', case when ifnull(buffer_norm, 0) = 0
then 'White' when ((closing_quantity - (4 * avg_sales)) <= 0 and buffer_norm
> 0) then 'Black' when ((closing_quantity - (4 * avg_sales)) > buffer_norm
and buffer_norm > 0) then 'Blue' when ((closing_quantity - (4 * avg_sales))
> (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(yellow_zone,0) /
100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2)
END) and (closing_quantity - (4 * avg_sales)) <= buffer_norm and buffer_norm > 0)
then 'Green' when ((closing_quantity - (4 * avg_sales)) > (CASE WHEN
IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(red_zone,0) / 100) *
IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and
(closing_quantity - (4 * avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow'
when ((closing_quantity - (4 * avg_sales)) > 0 and (closing_quantity - (4 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'four', case when (closing_quantity - (4 * avg_sales)) <= 0 then 0 else
(closing_quantity - (4 * avg_sales)) end as 'four_qty', case when
ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (5 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(5 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (5 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (5 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (5 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (5 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (5 * avg_sales)) > 0 and (closing_quantity - (5 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(red_zone,0) /
100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and
buffer_norm > 0) then 'Red' end as 'five', case when
(closing_quantity - (5 * avg_sales)) <= 0 then 0 else (closing_quantity - (5 *
avg_sales)) end as 'five_qty', case when ifnull(buffer_norm, 0) = 0
then 'White' when ((closing_quantity - (6 * avg_sales)) <= 0 and buffer_norm
> 0) then 'Black' when ((closing_quantity - (6 * avg_sales)) > buffer_norm
and buffer_norm > 0) then 'Blue' when ((closing_quantity - (6 * avg_sales))
> (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(yellow_zone,0) /
100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2)
END) and (closing_quantity - (6 * avg_sales)) <= buffer_norm and buffer_norm > 0)
then 'Green' when ((closing_quantity - (6 * avg_sales)) > (CASE WHEN
IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(red_zone,0) / 100) *
IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and
(closing_quantity - (6 * avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow'
when ((closing_quantity - (6 * avg_sales)) > 0 and (closing_quantity - (6 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'six', case when (closing_quantity - (6 * avg_sales)) <= 0 then 0 else
(closing_quantity - (6 * avg_sales)) end as 'six_qty', case when
ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (7 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(7 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (7 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (7 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (7 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (7 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm
> 0) then 'Yellow' when ((closing_quantity - (7 * avg_sales)) > 0 and
(closing_quantity - (7 * avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'seven', case when (closing_quantity - (7 * avg_sales)) <= 0 then 0 else
(closing_quantity - (7 * avg_sales)) end as 'seven_qty', case when
ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (8 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(8 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (8 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (8 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (8 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (8 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (8 * avg_sales)) > 0 and (closing_quantity - (8 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(red_zone,0) /
100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and
buffer_norm > 0) then 'Red' end as 'eight', case when
(closing_quantity - (8 * avg_sales)) <= 0 then 0 else (closing_quantity - (8 *
avg_sales)) end as 'eight_qty', case when ifnull(buffer_norm, 0) = 0
then 'White' when ((closing_quantity - (9 * avg_sales)) <= 0 and buffer_norm
> 0) then 'Black' when ((closing_quantity - (9 * avg_sales)) > buffer_norm
and buffer_norm > 0) then 'Blue' when ((closing_quantity - (9 * avg_sales))
> (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(yellow_zone,0) /
100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2)
END) and (closing_quantity - (9 * avg_sales)) <= buffer_norm and buffer_norm > 0)
then 'Green' when ((closing_quantity - (9 * avg_sales)) > (CASE WHEN
IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(red_zone,0) / 100) *
IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and
(closing_quantity - (9 * avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow'
when ((closing_quantity - (9 * avg_sales)) > 0 and (closing_quantity - (9 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'nine', case when (closing_quantity - (9 * avg_sales)) <= 0 then 0 else
(closing_quantity - (9 * avg_sales)) end as 'nine_qty', case when
ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (10 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(10 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (10 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (10 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (10 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (10 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (10 * avg_sales)) > 0 and (closing_quantity - (10 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'ten', case when (closing_quantity - (10 * avg_sales)) <= 0 then 0 else
(closing_quantity - (10 * avg_sales)) end as 'ten_qty', case when
ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (11 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(11 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (11 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (11 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (11 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (11 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (11 * avg_sales)) > 0 and (closing_quantity - (11 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'eleven', case when (closing_quantity - (11 * avg_sales)) <= 0 then 0
else (closing_quantity - (11 * avg_sales)) end as 'eleven_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (12 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(12 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (12 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (12 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (12 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (12 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (12 * avg_sales)) > 0 and (closing_quantity - (12 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twelve', case when (closing_quantity - (12 * avg_sales)) <= 0 then 0
else (closing_quantity - (12 * avg_sales)) end as 'twelve_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (13 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(13 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (13 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (13 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (13 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (13 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (13 * avg_sales)) > 0 and (closing_quantity - (13 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'thirteen', case when (closing_quantity - (13 * avg_sales)) <= 0 then 0
else (closing_quantity - (13 * avg_sales)) end as 'thirteen_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (14 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(14 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (14 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (14 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (14 * avg_sales)) > (CASE
WHEN IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(red_zone,0) / 100) *
IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and
(closing_quantity - (14 * avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow'
when ((closing_quantity - (14 * avg_sales)) > 0 and (closing_quantity - (14 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'fourteen', case when (closing_quantity - (14 * avg_sales)) <= 0 then 0
else (closing_quantity - (14 * avg_sales)) end as 'fourteen_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (15 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(15 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (15 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (15 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (15 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (15 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (15 * avg_sales)) > 0 and (closing_quantity - (15 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'fifteen', case when (closing_quantity - (15 * avg_sales)) <= 0 then 0
else (closing_quantity - (15 * avg_sales)) end as 'fifteen_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (16 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(16 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (16 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (16 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (16 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (16 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (16 * avg_sales)) > 0 and (closing_quantity - (16 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'sixteen', case when (closing_quantity - (16 * avg_sales)) <= 0 then 0
else (closing_quantity - (16 * avg_sales)) end as 'sixteen_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (17 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(17 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (17 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (17 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (17 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (17 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (17 * avg_sales)) > 0 and (closing_quantity - (17 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'seventeen', case when (closing_quantity - (17 * avg_sales)) <= 0 then 0
else (closing_quantity - (17 * avg_sales)) end as 'seventeen_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (18 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(18 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (18 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (18 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (18 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (18 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (18 * avg_sales)) > 0 and (closing_quantity - (18 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'eighteen', case when (closing_quantity - (18 * avg_sales)) <= 0 then 0
else (closing_quantity - (18 * avg_sales)) end as 'eighteen_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (19 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(19 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (19 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (19 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (19 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (19 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (19 * avg_sales)) > 0 and (closing_quantity - (19 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'nineteen', case when (closing_quantity - (19 * avg_sales)) <= 0 then 0
else (closing_quantity - (19 * avg_sales)) end as 'nineteen_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (20 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(20 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (20 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (20 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (20 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (20 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (20 * avg_sales)) > 0 and (closing_quantity - (20 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twenty', case when (closing_quantity - (20 * avg_sales)) <= 0 then 0
else (closing_quantity - (20 * avg_sales)) end as 'twenty_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (21 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity
- (21 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (21 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (21 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (21 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (21 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (21 * avg_sales)) > 0 and (closing_quantity - (21 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twentyone', case when (closing_quantity - (21 * avg_sales)) <= 0 then 0
else (closing_quantity - (21 * avg_sales)) end as 'twentyone_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (22 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(22 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (22 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (22 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (22 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (22 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (22 * avg_sales)) > 0 and (closing_quantity - (22 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twentytwo', case when (closing_quantity - (22 * avg_sales)) <= 0 then 0
else (closing_quantity - (22 * avg_sales)) end as 'twentytwo_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (23 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(23 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (23 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (23 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (23 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (23 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (23 * avg_sales)) > 0 and (closing_quantity - (23 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twentythree', case when (closing_quantity - (23 * avg_sales)) <= 0 then
0 else (closing_quantity - (23 * avg_sales)) end as 'twentythree_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (24 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(24 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (24 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (24 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (24 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (24 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (24 * avg_sales)) > 0 and (closing_quantity - (24 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twentyfour', case when (closing_quantity - (24 * avg_sales)) <= 0 then 0
else (closing_quantity - (24 * avg_sales)) end as 'twentyfour_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (25 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(25 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (25 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (25 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (25 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (25 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (25 * avg_sales)) > 0 and (closing_quantity - (25 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twentyfive', case when (closing_quantity - (25 * avg_sales)) <= 0 then 0
else (closing_quantity - (25 * avg_sales)) end as 'twentyfive_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (26 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(26 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (26 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (26 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (26 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (26 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (26 * avg_sales)) > 0 and (closing_quantity - (26 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twentysix', case when (closing_quantity - (26 * avg_sales)) <= 0 then 0
else (closing_quantity - (26 * avg_sales)) end as 'twentysix_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (27 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(27 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (27 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (27 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (27 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (27 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (27 * avg_sales)) > 0 and (closing_quantity - (27 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0)
/ 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END)
and buffer_norm > 0) then 'Red' end as 'twentyseven', case when
(closing_quantity - (27 * avg_sales)) <= 0 then 0 else (closing_quantity - (27 *
avg_sales)) end as 'twentyseven_qty', case when ifnull(buffer_norm,
0) = 0 then 'White' when ((closing_quantity - (28 * avg_sales)) <= 0 and
buffer_norm > 0) then 'Black' when ((closing_quantity - (28 * avg_sales)) >
buffer_norm and buffer_norm > 0) then 'Blue' when ((closing_quantity - (28 *
avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (28 * avg_sales)) <=
buffer_norm and buffer_norm > 0) then 'Green' when ((closing_quantity - (28
* avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (28 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (28 * avg_sales)) > 0 and (closing_quantity - (28 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twentyeight', case when (closing_quantity - (28 * avg_sales)) <= 0 then
0 else (closing_quantity - (28 * avg_sales)) end as 'twentyeight_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (29 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(29 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (29 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (29 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (29 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (29 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (29 * avg_sales)) > 0 and (closing_quantity - (29 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twentynine', case when (closing_quantity - (29 * avg_sales)) <= 0 then 0
else (closing_quantity - (29 * avg_sales)) end as 'twentynine_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (30 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(30 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (30 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (30 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (30 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (30 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (30 * avg_sales)) > 0 and (closing_quantity - (30 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'thirty', case when (closing_quantity - (30 * avg_sales)) <= 0 then 0
else (closing_quantity - (30 * avg_sales)) end as 'thirty_qty' from (
select tr.sku_id, tr.node_id, round(sum(tr.sales) / 15, 2) as avg_sales,
t.closing_quantity, ifnull(bn.buffer_norm, (select buffer_norm from
buffer_norm use index(inx_sku_node_efdt) where effective_from < tr.transaction_date
and sku_id = tr.sku_id and node_id = tr.node_id order by effective_from desc limit
1)) as buffer_norm, ifnull(bn.is_default_zone,'Y') as is_default_zone,
ifnull(bn.yellow_zone,0) as yellow_zone, ifnull(bn.red_zone,0) as red_zone,
case when (t.closing_quantity + t.in_transit - t.pending_orders) <= 0 then 0
else (t.closing_quantity + t.in_transit - t.pending_orders) end as
'final_quantity' from transaction tr inner join transaction t
on t.transaction_date = ?param0 and t.sku_id = tr.sku_id and
t.node_id = tr.node_id left join buffer_norm bn use
index(inx_sku_node_efdt) on bn.sku_id = tr.sku_id and bn.node_id =
tr.node_id and bn.effective_from = ?param0 where tr.sku_id = ?
param1 and tr.node_id = ?param2 and tr.transaction_date > ?param3 group
by tr.sku_id, tr.node_id ) as sku_grid inner join sku s on
s.sku_id = sku_grid.sku_id inner join node n on n.node_id =
sku_grid.node_id inner join sku_category sc on sc.sku_category_id =
(select sku_category_id from sku_category where sku_id = sku_grid.sku_id limit 1)
inner join category c on c.category_id = sc.category_id]
2018-03-15 10:55:08,792-Adding file [ExcessInventoryHelper.xml] to list of watched
files.
2018-03-15 10:55:08,792-Adding file [StockoutAvailabilityChartHelper.xml] to list
of watched files.
2018-03-15 10:55:08,792-Adding file [InventoryTurnsHelper.xml] to list of watched
files.
2018-03-15 10:55:08,808-Statement Id: [SelectInventoryTurns] Prepared SQL: [select
rpl.transaction_date, rpl.category_id, rpl.category_name,
date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date, sum(1) as
count, sum(rpl.closing_quantity) as closing_quantity, sum(rpl.sales) as sales
from replenishment rpl where rpl.category_id is not null and
rpl.transaction_date = ?param0 group by rpl.transaction_date,
rpl.category_id]
2018-03-15 10:55:08,808-Statement Id: [SelectInventoryTurnsSKU] Prepared SQL:
[select rpl.transaction_date, rpl.category_id, rpl.sku_id, rpl.category_name,
date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date, sum(1) as
count, sum(rpl.closing_quantity) as closing_quantity, sum(rpl.sales) as sales
from replenishment rpl where rpl.category_id is not null and
rpl.transaction_date = ?param0 group by rpl.transaction_date,
rpl.category_id, rpl.sku_id]
2018-03-15 10:55:08,810-Adding file [CntQtyFillRateChartHelper.xml] to list of
watched files.
2018-03-15 10:55:08,810-Statement Id: [SelectCntQtyFillRateChart] Prepared SQL:
[select rpl.transaction_date, rpl.closing_stock_zone,
group_concat(distinct(rpl.sku_id) SEPARATOR ',') as str_sku_ids,
date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date,
sum(rpl.closing_quantity) as closing_quantity, sum(rpl.buffer_norm) as buffer_norm
from replenishment rpl where rpl.closing_stock_zone != "White" and
rpl.transaction_date = ?param0 group by rpl.transaction_date,
rpl.closing_stock_zone]
2018-03-15 10:55:08,810-Statement Id: [SelectCntQtyFillRateChartNode] Prepared SQL:
[select rpl.transaction_date, rpl.closing_stock_zone, rpl.node_id,
group_concat(distinct(rpl.sku_id) SEPARATOR ',') as str_sku_ids,
date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date,
sum(rpl.closing_quantity) as closing_quantity, sum(rpl.buffer_norm) as buffer_norm
from replenishment rpl where rpl.closing_stock_zone != "White" and
rpl.transaction_date = ?param0 group by rpl.transaction_date,
rpl.closing_stock_zone, rpl.node_id]
2018-03-15 10:55:08,810-Statement Id: [SelectCntQtyFillRateChartCategory] Prepared
SQL: [select rpl.transaction_date, rpl.closing_stock_zone, rpl.category_id,
group_concat(distinct(rpl.sku_id) SEPARATOR ',') as str_sku_ids,
date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date,
sum(rpl.closing_quantity) as closing_quantity, sum(rpl.buffer_norm) as buffer_norm
from replenishment rpl where rpl.closing_stock_zone != "White" and
rpl.transaction_date = ?param0 group by rpl.transaction_date,
rpl.closing_stock_zone, rpl.category_id]
2018-03-15 10:55:08,810-Statement Id: [SelectCntQtyFillRateChartSKU] Prepared SQL:
[select rpl.transaction_date, rpl.closing_stock_zone, rpl.sku_id,
group_concat(distinct(rpl.sku_id) SEPARATOR ',') as str_sku_ids,
date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date,
sum(rpl.closing_quantity) as closing_quantity, sum(rpl.buffer_norm) as buffer_norm
from replenishment rpl where rpl.closing_stock_zone != "White" and
rpl.transaction_date = ?param0 group by rpl.transaction_date,
rpl.closing_stock_zone, rpl.sku_id]
2018-03-15 10:55:08,811-Adding file [UserDataPermissionHelper.xml] to list of
watched files.
2018-03-15 10:55:08,811-Statement Id: [SelectDataPermissionByRole] Prepared SQL:
[select user_data_id, role_id, object_type, object_id, chk_state, created_by,
created_on from user_data_permissions WHERE role_id = ?param0 AND
object_type = ?param1]
2018-03-15 10:55:08,811-Statement Id: [InsertUserDataPermission] Prepared SQL:
[insert into user_data_permissions (role_id, object_type, object_id,
chk_state, created_by, created_on) values ( ?param0 , ?param1 , ?
param2 , ?param3 , ?param4 , NOW());]
2018-03-15 10:55:08,811-Statement Id: [InsertUserDataPermission.SelectKey] Prepared
SQL: [select last_insert_id() as value]
2018-03-15 10:55:08,811-Statement Id: [DeleteDataPermissionByRole] Prepared SQL:
[delete from user_data_permissions where role_id = ?param0]
2018-03-15 10:55:08,811-Adding file [RoleHelper.xml] to list of watched files.
2018-03-15 10:55:08,811-Statement Id: [SelectRoleNameDuplicate] Prepared SQL:
[select role_id,role_name,status,created_by,created_on,modified_by,modified_on
from role where role_name = ?param0 and role_id != ?param1]
2018-03-15 10:55:08,811-Statement Id: [InsertRole] Prepared SQL: [insert into role
(role_name,status,created_by,created_on) values ( ?param0 , ?
param1 , ?param2 , NOW());]
2018-03-15 10:55:08,811-Statement Id: [InsertRole.SelectKey] Prepared SQL: [select
last_insert_id() as value]
2018-03-15 10:55:08,811-Statement Id: [UpdateRole] Prepared SQL: [update role set
role_name = ?param0 , status = ?param1 , modified_by = ?param2 ,
modified_on = NOW() where role_id = ?param3]
2018-03-15 10:55:08,811-Adding file [BOMHelper.xml] to list of watched files.
2018-03-15 10:55:08,811-Statement Id: [SelectBOMDictionary] Prepared SQL: [SELECT
DISTINCT sk.sku_code, bm.sku_id FROM sku sk INNER JOIN bom bm ON bm.sku_id =
sk.sku_id]
2018-03-15 10:55:08,811-Adding file [Matrix1Helper.xml] to list of watched files.
2018-03-15 10:55:08,811-Statement Id: [DropTmpNodeSKUMappingTable] Prepared SQL:
[DROP TABLE IF EXISTS tmp_node_sku_mapping2018_03_15_10_55_08]
2018-03-15 10:55:08,811-Statement Id: [DropTmpNodeSKUMappingTable]
PreparedStatement : [DROP TABLE IF EXISTS tmp_node_sku_mapping2018_03_15_10_55_08]
2018-03-15 10:55:08,811-Open Connection "57038224" to "MySQL, MySQL provider ver
6:5:4:0".
2018-03-15 10:55:08,824-Close Connection "57038224" to "MySQL, MySQL provider ver
6:5:4:0".
2018-03-15 10:55:08,824-UploadNodeSKUMapping::
System.FormatException: String was not recognized as a valid DateTime.
at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles
styles)
at System.Convert.ToDateTime(String value)
at SCMPLUS.Upload.<>c__DisplayClass9a.<UploadNodeSkuMapping>b__8c(DataRow drow)
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at SCMPLUS.Upload.UploadNodeSkuMapping(Object parameter)
2018-03-15 10:55:08,826-Adding file [SqlMap.config] to list of watched files.
2018-03-15 10:55:08,827-Add property "provider" value "MySql6"
2018-03-15 10:55:08,827-Add property "datasource" value "localhost"
2018-03-15 10:55:08,827-Add property "database" value "scmplus"
2018-03-15 10:55:08,827-Add property "port" value "3306"
2018-03-15 10:55:08,827-Add property "userid" value "root"
2018-03-15 10:55:08,827-Add property "password" value "root"
2018-03-15 10:55:08,827-Add property "mapperResources" value
"./bin/iBatis/SqlMapper/"
2018-03-15 10:55:08,828-Adding file [CategoryHelper.xml] to list of watched files.
2018-03-15 10:55:08,829-Statement Id: [SelectCategoryByCode] Prepared SQL: [select
category_id, category_code, category_name, parent_id, status, created_by,
created_on, modified_by, modified_on from category where category_code = ?
param0]
2018-03-15 10:55:08,829-Statement Id: [SelectCategoryForDuplicate] Prepared SQL:
[select category_id, category_code, category_name, parent_id, status, created_by,
created_on, modified_by, modified_on from category where category_code = ?
param0 and category_name = ?param1 and parent_id = ?param2]
2018-03-15 10:55:08,829-Statement Id: [SelectCategoryBy] Prepared SQL: [select
category_id, parent_id, category_name, category_code, status, created_by,
created_on, modified_by, modified_on from category where ?param0 = ?
param1]
2018-03-15 10:55:08,829-Statement Id: [InsertCategory] Prepared SQL: [insert into
category (category_code, category_name, parent_id, status, created_by,
created_on) values ( ?param0 , ?param1 , ?param2 , ?param3 , ?
param4 , NOW());]
2018-03-15 10:55:08,829-Statement Id: [InsertCategory.SelectKey] Prepared SQL:
[select last_insert_id() as value]
2018-03-15 10:55:08,829-Statement Id: [UpdateCategory] Prepared SQL: [update
category set category_name = ?param0 , parent_id = ?param1 ,
status = ?param2 , modified_by = ?param3 , modified_on = NOW()
where category_code = ?param4]
2018-03-15 10:55:08,829-Statement Id: [DeleteCategory] Prepared SQL: [delete from
category where category_id = ?param0]
2018-03-15 10:55:08,829-Adding file [NodeHelper.xml] to list of watched files.
2018-03-15 10:55:08,829-Statement Id: [MapNode] Prepared SQL: [select node_id,
node_code, node_name, address_line1, address_line2, status from node where node_id
= ?param0 union all select '' as node_id, '' as node_code, '' as
node_name, '' as address_line1, '' as address_line2, null as status limit 1]
2018-03-15 10:55:08,829-Statement Id: [SelectNodeByCode] Prepared SQL: [select
node_id, node_code, node_name, parent_id, location_id, address_line1,
address_line2, latitude, longitude, status, created_by, created_on,
modified_by, modified_on from node where node_code = ?param0]
2018-03-15 10:55:08,829-Statement Id: [SelectNodeForDuplicate] Prepared SQL:
[select node_id, node_code, node_name, parent_id, location_id, address_line1,
address_line2, latitude, longitude, status, created_by, created_on,
modified_by, modified_on from node where node_code = ?param0 and node_name
= ?param1 and parent_id = ?param2]
2018-03-15 10:55:08,829-Statement Id: [InsertNode] Prepared SQL: [insert into node
(node_code, node_name, parent_id, location_id, address_line1, address_line2,
latitude, longitude, status, created_by, created_on) values
( ?param0 , ?param1 , ?param2 , ?param3 , ?param4 , ?param5 , ?param6 , ?
param7 , ?param8 , ?param9 , NOW());]
2018-03-15 10:55:08,829-Statement Id: [InsertNode.SelectKey] Prepared SQL: [select
last_insert_id() as value]
2018-03-15 10:55:08,829-Statement Id: [UpdateNode] Prepared SQL: [update node set
node_name = ?param0 , parent_id = ?param1 , location_id = ?
param2 , address_line1 = ?param3 , address_line2 = ?param4 ,
latitude = ?param5 , longitude = ?param6 , status = ?param7 ,
modified_by = ?param8 , modified_on = NOW() where node_code = ?
param9]
2018-03-15 10:55:08,829-Statement Id: [DeleteNode] Prepared SQL: [delete from node
where node_id = ?param0]
2018-03-15 10:55:08,829-Adding file [AttributeHelper.xml] to list of watched files.
2018-03-15 10:55:08,829-Statement Id: [SelectAttributeByCode] Prepared SQL: [select
attribute_id, attribute_code, attribute_name, data_type, optional, status,
created_by, created_on, modified_by, modified_on from attribute where
attribute_code = ?param0]
2018-03-15 10:55:08,829-Statement Id: [InsertAttribute] Prepared SQL: [insert into
attribute (attribute_code, attribute_name, data_type, optional, status,
created_by, created_on) values ( ?param0 , ?param1 , ?param2 , ?
param3 , ?param4 , ?param5 , NOW());]
2018-03-15 10:55:08,829-Statement Id: [InsertAttribute.SelectKey] Prepared SQL:
[select last_insert_id() as value]
2018-03-15 10:55:08,829-Statement Id: [UpdateAttribute] Prepared SQL: [update
attribute set attribute_name = ?param0 , data_type = ?param1 ,
optional = ?param2 , status = ?param3 , modified_by = ?param4 ,
modified_on = NOW() where attribute_id = ?param5]
2018-03-15 10:55:08,829-Statement Id: [DeleteAttribute] Prepared SQL: [delete from
attribute where attribute_id = ?param0]
2018-03-15 10:55:08,829-Adding file [SKUHelper.xml] to list of watched files.
2018-03-15 10:55:08,829-Statement Id: [MapSKU] Prepared SQL: [select * from sku
where sku_id = ?param0]
2018-03-15 10:55:08,829-Statement Id: [SelectSKUByCode] Prepared SQL: [select
sku_id, sku_code, sku_name, sku_description, status, created_by, created_on,
modified_by, modified_on from sku where sku_code = ?param0]
2018-03-15 10:55:08,829-Statement Id: [SelectSKUForDuplicate] Prepared SQL: [select
sku_id, sku_code, sku_name, sku_description, status, created_by, created_on,
modified_by, modified_on from sku where sku_code = ?param0 and sku_name =
?param1 and sku_description = ?param2]
2018-03-15 10:55:08,829-Statement Id: [SelectBatchInsertedSKU] Prepared SQL:
[select sku_id, sku_code, sku_name, sku_description, status, created_by,
created_on, modified_by, modified_on from sku where sku_id >= (SELECT
(AUTO_INCREMENT - ?param0 ) FROM information_schema.`TABLES` WHERE TABLE_NAME =
'sku' LIMIT 1)]
2018-03-15 10:55:08,829-Statement Id: [InsertSKU] Prepared SQL: [insert into sku
(sku_code, sku_name, sku_description, status, created_by, created_on) values
( ?param0 , ?param1 , ?param2 , ?param3 , ?param4 , NOW());]
2018-03-15 10:55:08,829-Statement Id: [InsertSKU.SelectKey] Prepared SQL: [select
last_insert_id() as value]
2018-03-15 10:55:08,829-Statement Id: [UpdateSKU] Prepared SQL: [update sku set
sku_name = ?param0 , sku_description = ?param1 , status = ?
param2 , modified_by = ?param3 , modified_on = NOW() where
sku_id = ?param4]
2018-03-15 10:55:08,829-Statement Id: [DeleteSKU] Prepared SQL: [delete from sku
where sku_id = ?param0]
2018-03-15 10:55:08,829-Adding file [SKUAttributeHelper.xml] to list of watched
files.
2018-03-15 10:55:08,829-Statement Id: [SelectSKUAttributeMappingBySKUAttribute]
Prepared SQL: [select sku_attribute_mapping_id, sku_id, attribute_id, value,
created_by, created_on from sku_attribute_mapping where sku_id = ?param0
and attribute_id = ?param1]
2018-03-15 10:55:08,829-Statement Id: [SelectSKUAttributeMappingBySKU] Prepared
SQL: [select sku_attribute_mapping_id, sku_id, attribute_id, value, created_by,
created_on from sku_attribute_mapping where sku_id = ?param0]
2018-03-15 10:55:08,829-Statement Id: [InsertSKUAttributeMapping] Prepared SQL:
[insert into sku_attribute_mapping (sku_id, attribute_id, value, created_by,
created_on) values ( ?param0 , ?param1 , ?param2 , ?param3 ,
NOW());]
2018-03-15 10:55:08,829-Statement Id: [InsertSKUAttributeMapping.SelectKey]
Prepared SQL: [select last_insert_id() as value]
2018-03-15 10:55:08,829-Statement Id: [UpdateSKUAttributeMapping] Prepared SQL:
[update sku_attribute_mapping set value = ?param0 , where
sku_attribute_mapping_id = ?param1]
2018-03-15 10:55:08,829-Statement Id: [DeleteSKUAttributeMapping] Prepared SQL:
[delete from sku_attribute_mapping where sku_id = ?param0 and attribute_id
= ?param1]
2018-03-15 10:55:08,829-Adding file [NodeSKUHelper.xml] to list of watched files.
2018-03-15 10:55:08,829-Statement Id: [SelectNodeSKUMappingByNodeSKU] Prepared SQL:
[select node_sku_mapping_id, receiver_node_id, sku_id, supplier_node_id,
effective_date, created_by, created_on from node_sku_mapping where sku_id =
?param0 and receiver_node_id = ?param1 and supplier_node_id = ?param2 and
effective_date = ?param3]
2018-03-15 10:55:08,829-Statement Id: [selectSKU] Prepared SQL: [select * from sku
where sku_id = ?param0]
2018-03-15 10:55:08,829-Statement Id: [selectNode] Prepared SQL: [select * from
node where node_id = ?param0]
2018-03-15 10:55:08,829-Statement Id: [InsertNodeSKUMapping] Prepared SQL: [insert
into node_sku_mapping (receiver_node_id, sku_id, supplier_node_id,
effective_date, created_by, created_on) values ( ?param0 , ?param1 ,
?param2 , date_format( ?param3 , "%Y-%c-%e %H:%i:%s"), ?param4 , NOW());]
2018-03-15 10:55:08,829-Statement Id: [InsertNodeSKUMapping.SelectKey] Prepared
SQL: [select last_insert_id() as value]
2018-03-15 10:55:08,829-Statement Id: [DeleteNodeSKUMapping] Prepared SQL: [delete
from node_sku_mapping where node_sku_mapping_id = ?param0]
2018-03-15 10:55:08,829-Adding file [BufferNormHelper.xml] to list of watched
files.
2018-03-15 10:55:08,829-Statement Id: [MapBufferNorm] Prepared SQL: [select
buffer_norm_id, sku_id, node_id, buffer_norm, olt, plt, tlt, rlt,
max_sales_per_day, safety_factor, unit_selling_price, unit_purchase_price,
moq, eoq, effective_from, created_by, created_on, modified_by, modified_on
from buffer_norm where buffer_norm_id = ?param0 union all select '' as
buffer_norm_id, '' as sku_id, '' as node_id, 0 as buffer_norm, 0 as olt, 0 as plt,
0 as tlt, 0 as rlt, 0 as max_sales_per_day, 0 as safety_factor, 0 as
unit_selling_price, 0 as unit_purchase_price, 0 as moq, 0 as eoq, '' as
effective_from, null as created_by, null as created_on, null as modified_by, null
as modified_on limit 1]
2018-03-15 10:55:08,829-Statement Id: [SelectBufferNormBySKUNode] Prepared SQL:
[select buffer_norm_id, sku_id, node_id, buffer_norm, olt, plt, tlt, rlt,
max_sales_per_day, safety_factor, unit_selling_price, unit_purchase_price,
moq, eoq, effective_from, created_by, created_on, modified_by,
modified_on,IFNULL(is_default_zone,'Y') AS is_default_zone, IFNULL(red_zone,0) AS
red_zone, IFNULL(yellow_zone,0) AS yellow_zone from buffer_norm where sku_id
= ?param0 and node_id = ?param1 and effective_from = ?param2]
2018-03-15 10:55:08,829-Statement Id: [SelectBatchInsertedBufferNorm] Prepared SQL:
[select b.buffer_norm_id, b.sku_id, b.node_id, b.buffer_norm, b.olt, b.plt, b.tlt,
b.rlt, b.max_sales_per_day, b.safety_factor, b.unit_selling_price,
b.unit_purchase_price, b.moq, b.eoq, b.effective_from, b.created_by, b.created_on,
b.modified_by, b.modified_on, b.identifier, b.is_default_zone, b.red_zone,
b.yellow_zone from buffer_norm b where identifier = ?param0]
2018-03-15 10:55:08,829-Statement Id: [InsertBufferNorm] Prepared SQL: [insert into
buffer_norm (sku_id, node_id, buffer_norm, olt, plt, tlt, rlt,
max_sales_per_day, safety_factor, unit_selling_price, unit_purchase_price,
moq, eoq, effective_from, created_by, created_on) values ( ?param0 ,
?param1 , ?param2 , ?param3 , ?param4 , ?param5 , ?param6 , ?param7 , ?
param8 , ?param9 , ?param10 , ?param11 , ?param12 , date_format( ?
param13 , "%Y-%c-%e %H:%i:%s"), ?param14 , NOW());]
2018-03-15 10:55:08,829-Statement Id: [InsertBufferNorm.SelectKey] Prepared SQL:
[select last_insert_id() as value]
2018-03-15 10:55:08,829-Statement Id: [UpdateBufferNorm] Prepared SQL: [update
buffer_norm set sku_id = ?param0 , node_id = ?param1 ,
buffer_norm = ?param2 , olt = ?param3 , plt = ?param4 , tlt
= ?param5 , rlt = ?param6 , max_sales_per_day = ?param7 ,
safety_factor = ?param8 , unit_selling_price = ?param9 ,
unit_purchase_price = ?param10 , moq = ?param11 , eoq = ?param12 ,
effective_from = date_format( ?param13 , "%Y-%c-%e %H:%i:%s"), modified_by =
?param14 , modified_on = NOW() where buffer_norm_id = ?param15]
2018-03-15 10:55:08,829-Statement Id: [DeleteBufferNorm] Prepared SQL: [delete from
buffer_norm where buffer_norm_id = ?param0]
2018-03-15 10:55:08,829-Adding file [TransactionHelper.xml] to list of watched
files.
2018-03-15 10:55:08,829-Statement Id: [SelectTransactionForDuplicate] Prepared SQL:
[select transaction_id, sku_id, node_id, supply_node_id, transaction_date, grn,
sales, closing_quantity, in_transit, inst_hold, quality_hold, qa_hold,
pending_orders, orders_in_hand, transport_mode, db_sync, mongo_sync, created_by,
created_on, open_stock_transfer_order, open_planned_order,
open_purchase_request, open_production_order, open_purchase_order, field1, field2,
field3, field4, field5, field6, field7, field8, field9, field10 from
transaction where sku_id = ?param0 and node_id = ?param1 and transaction_date =
?param2]
2018-03-15 10:55:08,829-Statement Id: [SelectReplenishmentList] Prepared SQL:
[select tr.transaction_id, tr.transaction_date,
date_format(tr.transaction_date,'%d/%m/%Y') as display_date,
date_format(tr.transaction_date,'%Y%m%d') as transfilter_date, tr.sku_id,
s.sku_code, s.sku_name, tr.node_id, n.node_code, n.node_name, sc.category_id,
cat.category_code, cat.category_name, ifnull(bn.buffer_norm, 0) as
buffer_norm, ifnull(tr.closing_quantity, 0) as closing_quantity,
ifnull(tr.in_transit, 0) as in_transit, ifnull(tr.sales, 0) as sales,
ifnull(tr.inst_hold, 0) as inst_hold, ifnull(tr.quality_hold, 0) as quality_hold,
ifnull(tr.qa_hold, 0) as qa_hold, ifnull(tr.pending_orders, 0) as
pending_orders, ifnull(tr.orders_in_hand, 0) as orders_in_hand,
ifnull(tr.transport_mode, '') as transport_mode, nsm.supplier_node_id as
supply_node_id, sn.node_name as supply_node_name, sn.node_code as
supply_node_code, ifnull(str.closing_quantity, 0) as supplying_quantity,
ifnull(sbn.buffer_norm, 0) as supplying_buffer_norm,
round(ifnull(bn.buffer_norm, 0),2) as 'green_zone_qty', CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2)
END AS 'yellow_zone_qty', CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END as 'red_zone_qty', case
when ifnull(bn.buffer_norm, 0) = 0 then 'White' when
(ifnull(tr.closing_quantity, 0) <= 0 and ifnull(bn.buffer_norm, 0) > 0) then
'Black' when (ifnull(tr.closing_quantity, 0) > ifnull(bn.buffer_norm, 0) and
ifnull(bn.buffer_norm, 0) > 0) then 'Blue' when (ifnull(tr.closing_quantity,
0) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) and ifnull(tr.closing_quantity,
0) <= ifnull(bn.buffer_norm, 0) and ifnull(bn.buffer_norm, 0) > 0) then 'Green'
when (ifnull(tr.closing_quantity, 0) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) and ifnull(tr.closing_quantity, 0) <=
(CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) and ifnull(bn.buffer_norm, 0) >
0) then 'Yellow' when (ifnull(tr.closing_quantity, 0) > 0 and
ifnull(tr.closing_quantity, 0) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) and ifnull(bn.buffer_norm, 0) > 0) then
'Red' end as 'closing_stock_zone', case when
ifnull(bn.buffer_norm, 0) = 0 then 6 when (ifnull(tr.closing_quantity, 0) <=
0 and ifnull(bn.buffer_norm, 0) > 0) then 1 when
(ifnull(tr.closing_quantity, 0) > ifnull(bn.buffer_norm, 0) and
ifnull(bn.buffer_norm, 0) > 0) then 2 when (ifnull(tr.closing_quantity, 0) >
(CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) and ifnull(tr.closing_quantity,
0) <= ifnull(bn.buffer_norm, 0) and ifnull(bn.buffer_norm, 0) > 0) then 4
when (ifnull(tr.closing_quantity, 0) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) and ifnull(tr.closing_quantity, 0) <=
(CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) and ifnull(bn.buffer_norm, 0) >
0) then 3 when (ifnull(tr.closing_quantity, 0) > 0 and
ifnull(tr.closing_quantity, 0) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) and ifnull(bn.buffer_norm, 0) > 0) then
5 end as 'closing_stock_zone_sort', case when
ifnull(bn.buffer_norm, 0) = 0 then 'White' when
((ifnull(tr.closing_quantity, 0) + ifnull(tr.in_transit, 0) -
ifnull(tr.pending_orders, 0)) <= 0 and ifnull(bn.buffer_norm, 0) > 0) then 'Black'
when ((ifnull(tr.closing_quantity, 0) + ifnull(tr.in_transit, 0) -
ifnull(tr.pending_orders, 0)) > ifnull(bn.buffer_norm, 0) and
ifnull(bn.buffer_norm, 0) > 0) then 'Blue' when
((ifnull(tr.closing_quantity, 0) + ifnull(tr.in_transit, 0) -
ifnull(tr.pending_orders, 0)) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) and
(ifnull(tr.closing_quantity, 0) + tr.in_transit - tr.pending_orders) <=
ifnull(bn.buffer_norm, 0) and ifnull(bn.buffer_norm, 0) > 0) then 'Green'
when ((ifnull(tr.closing_quantity, 0) + ifnull(tr.in_transit, 0) -
ifnull(tr.pending_orders, 0)) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) and (tr.closing_quantity +
tr.in_transit - tr.pending_orders) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2)
ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) and ifnull(bn.buffer_norm,
0) > 0) then 'Yellow' when ((ifnull(tr.closing_quantity, 0) +
ifnull(tr.in_transit, 0) - ifnull(tr.pending_orders, 0)) > 0 and
(ifnull(tr.closing_quantity, 0) + tr.in_transit - tr.pending_orders) <= (CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) and
ifnull(bn.buffer_norm, 0) > 0) then 'Red' end as 'in_transit_zone',
case when ifnull(bn.buffer_norm, 0) = 0 then 6 when
((ifnull(tr.closing_quantity, 0) + ifnull(tr.in_transit, 0) -
ifnull(tr.pending_orders, 0)) <= 0 and ifnull(bn.buffer_norm, 0) > 0) then 1
when ((ifnull(tr.closing_quantity, 0) + ifnull(tr.in_transit, 0) -
ifnull(tr.pending_orders, 0)) > ifnull(bn.buffer_norm, 0) and
ifnull(bn.buffer_norm, 0) > 0) then 2 when ((ifnull(tr.closing_quantity, 0)
+ ifnull(tr.in_transit, 0) - ifnull(tr.pending_orders, 0)) > (CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2)
END) and (ifnull(tr.closing_quantity, 0) + tr.in_transit - tr.pending_orders) <=
ifnull(bn.buffer_norm, 0) and ifnull(bn.buffer_norm, 0) > 0) then 4 when
((ifnull(tr.closing_quantity, 0) + ifnull(tr.in_transit, 0) -
ifnull(tr.pending_orders, 0)) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) and (ifnull(tr.closing_quantity, 0) +
tr.in_transit - tr.pending_orders) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2)
ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) and ifnull(bn.buffer_norm,
0) > 0) then 3 when ((ifnull(tr.closing_quantity, 0) + ifnull(tr.in_transit,
0) - ifnull(tr.pending_orders, 0)) > 0 and (ifnull(tr.closing_quantity, 0) +
tr.in_transit - tr.pending_orders) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) and ifnull(bn.buffer_norm, 0) > 0) then
5 end as 'in_transit_zone_sort', case when
ifnull(sbn.buffer_norm, 0) = 0 then 'White' when
(ifnull(str.closing_quantity, 0) <= 0 and ifnull(sbn.buffer_norm, 0) > 0) then
'Black' when (ifnull(str.closing_quantity, 0) > ifnull(sbn.buffer_norm, 0)
and ifnull(sbn.buffer_norm, 0) > 0) then 'Blue' when
(ifnull(str.closing_quantity, 0) > (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) and
ifnull(str.closing_quantity, 0) <= ifnull(sbn.buffer_norm, 0) and
ifnull(sbn.buffer_norm, 0) > 0) then 'Green' when
(ifnull(str.closing_quantity, 0) > (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) and ifnull(str.closing_quantity, 0) <=
(CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) and ifnull(sbn.buffer_norm, 0)
> 0) then 'Yellow' when (ifnull(str.closing_quantity, 0) > 0 and
ifnull(str.closing_quantity, 0) <= (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) and ifnull(sbn.buffer_norm, 0) > 0)
then 'Red' end as 'supplying_node_zone', case when
ifnull(sbn.buffer_norm, 0) = 0 then 6 when (ifnull(str.closing_quantity, 0)
<= 0 and ifnull(sbn.buffer_norm, 0) > 0) then 1 when
(ifnull(str.closing_quantity, 0) > ifnull(sbn.buffer_norm, 0) and
ifnull(sbn.buffer_norm, 0) > 0) then 2 when (ifnull(str.closing_quantity,
0) > (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) and
ifnull(str.closing_quantity, 0) <= ifnull(sbn.buffer_norm, 0) and
ifnull(sbn.buffer_norm, 0) > 0) then 4 when (ifnull(str.closing_quantity, 0)
> (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) and ifnull(str.closing_quantity, 0) <=
(CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) and ifnull(sbn.buffer_norm, 0)
> 0) then 3 when (ifnull(str.closing_quantity, 0) > 0 and
ifnull(str.closing_quantity, 0) <= (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) and ifnull(sbn.buffer_norm, 0) > 0)
then 5 end as 'supplying_node_zone_sort', case when
((ifnull(bn.buffer_norm, 0) - ifnull(tr.closing_quantity, 0) -
ifnull(tr.in_transit, 0)) + ifnull(tr.pending_orders, 0)) -
(ifnull(tr.open_planned_order, 0) + ifnull(tr.open_purchase_request, 0) +
ifnull(tr.open_production_order, 0) + ifnull(tr.open_purchase_order, 0)) <= 0 then
0 else ((ifnull(bn.buffer_norm, 0) - ifnull(tr.closing_quantity, 0) -
ifnull(tr.in_transit, 0)) + ifnull(tr.pending_orders, 0)) -
(ifnull(tr.open_planned_order, 0) + ifnull(tr.open_purchase_request, 0) +
ifnull(tr.open_production_order, 0) + ifnull(tr.open_purchase_order, 0)) end
as 'replenishment_quantity', case when (ifnull(tr.closing_quantity,
0) + ifnull(tr.in_transit, 0) + ifnull(tr.open_planned_order, 0) +
ifnull(tr.open_purchase_request, 0) + ifnull(tr.open_production_order, 0) +
ifnull(tr.open_purchase_order, 0) ) - ifnull(tr.pending_orders, 0) <= 0 then 0
else (ifnull(tr.closing_quantity, 0) + ifnull(tr.in_transit, 0) +
ifnull(tr.open_planned_order, 0) + ifnull(tr.open_purchase_request, 0) +
ifnull(tr.open_production_order, 0) + ifnull(tr.open_purchase_order, 0) ) -
ifnull(tr.pending_orders, 0) end as 'final_quantity', case
when ifnull(bn.buffer_norm, 0) = 0 then 0 else (CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END)
end as 'mrq', (select count(1) from transaction_comment where
transaction_id = tr.transaction_id) as 'transaction_comment',
ifnull(tr.open_stock_transfer_order, 0) as open_stock_transfer_order,
ifnull(tr.open_planned_order, 0) as open_planned_order,
ifnull(tr.open_purchase_request, 0) as open_purchase_request,
ifnull(tr.open_production_order, 0) as open_production_order,
ifnull(tr.open_purchase_order, 0) as open_purchase_order, tr.field1,
tr.field2, tr.field3, tr.field4, tr.field5, tr.field6, tr.field7, tr.field8,
tr.field9, tr.field10 from ( select transaction_id from
transaction where transaction_date = ?param0 limit ?param1 , ?
param2 ) otr join transaction tr on tr.transaction_id
= otr.transaction_id left join buffer_norm bn on bn.sku_id =
tr.sku_id and bn.node_id = tr.node_id and bn.effective_from = (
select max(effective_from) from buffer_norm where effective_from <=
tr.transaction_date and sku_id = tr.sku_id and node_id = tr.node_id)
left join sku s on s.sku_id = tr.sku_id left join sku_category sc
on sc.sku_id = tr.sku_id left join category cat on cat.category_id
= sc.category_id left join node n on n.node_id = tr.node_id
left join node_sku_mapping nsm on nsm.receiver_node_id = tr.node_id
and nsm.sku_id = tr.sku_id and nsm.effective_date = ( select
max(effective_date) from node_sku_mapping where effective_date <=
tr.transaction_date and sku_id = tr.sku_id and receiver_node_id =
tr.node_id) left join node sn on sn.node_id = nsm.supplier_node_id
left join buffer_norm sbn on sbn.sku_id = nsm.sku_id and sbn.node_id
= nsm.supplier_node_id and sbn.effective_from = ( select
max(effective_from) from buffer_norm where effective_from <=
tr.transaction_date and sku_id = tr.sku_id and node_id = tr.node_id)
left join ( select transaction_id, sku_id, node_id, closing_quantity
from transaction where transaction_date = ?param0 ) str
on str.sku_id = nsm.sku_id and str.node_id = nsm.supplier_node_id and
str.transaction_id = otr.transaction_id order by tr.transaction_id]
2018-03-15 10:55:08,829-Statement Id: [MapTransaction] Prepared SQL: [select * from
transaction where transaction_id = ?param0]
2018-03-15 10:55:08,829-Statement Id: [SelectMaxTransactionDate] Prepared SQL:
[select date_sub(max(transaction_date), interval 15 day) as avg_date,
max(transaction_date) as transaction_date from transaction]
2018-03-15 10:55:08,829-Statement Id: [SelectSKUNodeGroup] Prepared SQL: [select
sku_id, node_id from transaction group by sku_id, node_id]
2018-03-15 10:55:08,829-Statement Id: [SelectTransactionBySKUNode] Prepared SQL:
[select transaction_id, sku_id, node_id, supply_node_id, transaction_date, grn,
sales, closing_quantity, in_transit, inst_hold, quality_hold, qa_hold,
pending_orders, orders_in_hand, transport_mode, db_sync, mongo_sync, created_by,
created_on, open_stock_transfer_order, open_planned_order,
open_purchase_request, open_production_order, open_purchase_order, field1, field2,
field3, field4, field5, field6, field7, field8, field9, field10 from
transaction where sku_id = ?param0 and node_id = ?param1]
2018-03-15 10:55:08,829-Statement Id: [SelectTransactionByDate] Prepared SQL:
[select transaction_id, sku_id, node_id, supply_node_id, transaction_date, grn,
sales, closing_quantity, in_transit, inst_hold, quality_hold, qa_hold,
pending_orders, orders_in_hand, transport_mode, db_sync, mongo_sync, created_by,
created_on, open_stock_transfer_order, open_planned_order,
open_purchase_request, open_production_order, open_purchase_order, field1, field2,
field3, field4, field5, field6, field7, field8, field9, field10 from
transaction where transaction_date = ?param0]
2018-03-15 10:55:08,829-Statement Id: [SelectTransactionDates] Prepared SQL:
[select DATE_FORMAT(transaction_date, '%Y-%m-%d %H:%i:%s') as transaction_date from
transaction group by transaction_date asc limit ?param0]
2018-03-15 10:55:08,829-Statement Id: [SelectBNCalculationTransactionDates]
Prepared SQL: [select DATE_FORMAT(transaction_date, '%Y-%m-%d %H:%i:%s') as
transaction_date from transaction where transaction_date >= ?param0
group by transaction_date asc]
2018-03-15 10:55:08,829-Statement Id: [SelectTransactionIdsForBNCalculation]
Prepared SQL: [select transaction_id from transaction where transaction_date
= ?param0 and sku_id = ?param1 and node_id = ?param2]
2018-03-15 10:55:08,829-Statement Id: [SelectBatchInsertedTransactionID] Prepared
SQL: [select transaction_id, identifier from transaction where identifier = ?
param0]
2018-03-15 10:55:08,829-Statement Id: [SelectUpdateTransactionImport] Prepared SQL:
[select DISTINCT transaction_id from update_transaction WHERE identifier = ?
param0]
2018-03-15 10:55:08,829-Statement Id: [SelectClosingStockForTransactionDate]
Prepared SQL: [SELECT transaction_date, closing_quantity, sales, grn from
transaction WHERE transaction_date < ?param0 AND sku_id = ?param1
AND node_id = ?param2 ORDER BY transaction_date DESC LIMIT 1]
2018-03-15 10:55:08,829-Statement Id: [InsertTransaction] Prepared SQL: [insert
into transaction (sku_id, node_id, supply_node_id, transaction_date, grn,
sales, closing_quantity, in_transit, inst_hold, quality_hold, qa_hold,
pending_orders, orders_in_hand, transport_mode, db_sync, mongo_sync, created_by,
created_on, open_stock_transfer_order, open_planned_order,
open_purchase_request, open_production_order, open_purchase_order, field1, field2,
field3, field4, field5, field6, field7, field8, field9, field10) values
( ?param0 , ?param1 , ?param2 , ?param3 , ?param4 , ?param5 , ?param6 , ?
param7 , ?param8 , ?param9 , ?param10 , ?param11 , ?param12 , ?param13
, 0, 0, ?param14 , NOW(), ?param15 , ?param16 , ?param17 , ?
param18 , ?param19 , ?param20 , ?param21 , ?param22 , ?param23 , ?param24 ,
?param25 , ?param26 , ?param27 , ?param28 , ?param29 );]
2018-03-15 10:55:08,829-Statement Id: [InsertTransaction.SelectKey] Prepared SQL:
[select last_insert_id() as value]
2018-03-15 10:55:08,829-Statement Id: [InsertTransactionComment] Prepared SQL:
[insert into transaction_comment (transaction_id, sku_id, node_id, comment,
reason, created_by, created_on) values ( ?param0 , ?param1 , ?
param2 , ?param3 , ?param4 , ?param5 , NOW());]
2018-03-15 10:55:08,829-Statement Id: [InsertTransactionComment.SelectKey] Prepared
SQL: [select last_insert_id() as value]
2018-03-15 10:55:08,829-Statement Id: [UpdateTransaction] Prepared SQL: [update
transaction set sku_id = ?param0 , node_id = ?param1 ,
supply_node_id = ?param2 , transaction_date = ?param3 , grn = ?
param4 , sales = ?param5 , closing_quantity = ?param6 ,
in_transit = ?param7 , inst_hold = ?param8 , quality_hold = ?
param9 , qa_hold = ?param10 , pending_orders = ?param11 ,
orders_in_hand = ?param12 , transport_mode = ?param13 , db_sync
= ?param14 , mongo_sync = ?param15 where transaction_id = ?
param16]
2018-03-15 10:55:08,829-Statement Id: [DeleteUpdatesTransaction] Prepared SQL:
[delete from update_transaction WHERE identifier = ?param0]
2018-03-15 10:55:08,829-Adding file [SKUCategoryHelper.xml] to list of watched
files.
2018-03-15 10:55:08,829-Statement Id: [SelectSKUCategoryBySKUCategory] Prepared
SQL: [select sku_category_id, sku_id, category_id, created_by, created_on
from sku_category where sku_id = ?param0 and category_id = ?param1]
2018-03-15 10:55:08,829-Statement Id: [InsertSKUCategory] Prepared SQL: [insert
into sku_category (sku_id, category_id, created_by, created_on)
values ( ?param0 , ?param1 , ?param2 , NOW());]
2018-03-15 10:55:08,829-Statement Id: [InsertSKUCategory.SelectKey] Prepared SQL:
[select last_insert_id() as value]
2018-03-15 10:55:08,829-Adding file [SKUChartHelper.xml] to list of watched files.
2018-03-15 10:55:08,829-Statement Id: [SelectSKUChart] Prepared SQL: [select
rpl.transaction_date, date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date,
sum(rpl.closing_quantity) as closing_quantity, sum(rpl.red_zone_qty) as
red_zone_qty, sum(rpl.yellow_zone_qty) as yellow_zone_qty,
sum(rpl.green_zone_qty) as green_zone_qty, sum(rpl.in_transit) as in_transit,
sum(rpl.sales) as sales, count(distinct(rpl.sku_id)) as total_sku_count,
(select count(distinct(sku_id)) from replenishment where closing_stock_zone_sort =
2 and transaction_date = rpl.transaction_date) as blue_sku_count, (select
count(distinct(sku_id)) from replenishment where (closing_stock_zone_sort = 1 or
closing_stock_zone_sort = 5) and transaction_date = rpl.transaction_date) as
rb_sku_count from replenishment rpl where rpl.transaction_date = ?
param0 group by rpl.transaction_date]
2018-03-15 10:55:08,829-Statement Id: [SelectSKUChartNode] Prepared SQL: [select
rpl.transaction_date, date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date, rpl.node_id,
sum(rpl.closing_quantity) as closing_quantity, sum(rpl.red_zone_qty) as
red_zone_qty, sum(rpl.yellow_zone_qty) as yellow_zone_qty,
sum(rpl.green_zone_qty) as green_zone_qty, sum(rpl.in_transit) as in_transit,
sum(rpl.sales) as sales, count(distinct(rpl.sku_id)) as total_sku_count,
ifnull((select count(distinct(sku_id)) from replenishment where
closing_stock_zone_sort = 2 and transaction_date = rpl.transaction_date and node_id
= rpl.node_id), 0) as blue_sku_count, ifnull((select count(distinct(sku_id))
from replenishment where (closing_stock_zone_sort = 1 or closing_stock_zone_sort =
5) and transaction_date = rpl.transaction_date and node_id = rpl.node_id), 0) as
rb_sku_count from replenishment rpl where rpl.transaction_date = ?
param0 group by rpl.transaction_date, rpl.node_id]
2018-03-15 10:55:08,829-Statement Id: [SelectSKUChartCategory] Prepared SQL:
[select rpl.transaction_date, date_format(rpl.transaction_date,'%d/%m/%Y') as
display_date, date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date,
rpl.category_id, sum(rpl.closing_quantity) as closing_quantity,
sum(rpl.red_zone_qty) as red_zone_qty, sum(rpl.yellow_zone_qty) as yellow_zone_qty,
sum(rpl.green_zone_qty) as green_zone_qty, sum(rpl.in_transit) as in_transit,
sum(rpl.sales) as sales, count(distinct(rpl.sku_id)) as total_sku_count,
ifnull((select count(distinct(sku_id)) from replenishment where
closing_stock_zone_sort = 2 and transaction_date = rpl.transaction_date and
category_id = rpl.category_id), 0) as blue_sku_count, ifnull((select
count(distinct(sku_id)) from replenishment where (closing_stock_zone_sort = 1 or
closing_stock_zone_sort = 5) and transaction_date = rpl.transaction_date and
category_id = rpl.category_id), 0) as rb_sku_count from replenishment rpl
where rpl.transaction_date = ?param0 and rpl.category_id is not null
group by rpl.transaction_date, rpl.category_id]
2018-03-15 10:55:08,829-Statement Id: [SelectSKUChartSKU] Prepared SQL: [select
rpl.transaction_date, date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date, rpl.sku_id,
sum(rpl.closing_quantity) as closing_quantity, sum(rpl.red_zone_qty) as
red_zone_qty, sum(rpl.yellow_zone_qty) as yellow_zone_qty,
sum(rpl.green_zone_qty) as green_zone_qty, sum(rpl.in_transit) as in_transit,
sum(rpl.sales) as sales, count(distinct(rpl.sku_id)) as total_sku_count,
ifnull((select count(distinct(sku_id)) from replenishment where
closing_stock_zone_sort = 2 and transaction_date = rpl.transaction_date and sku_id
= rpl.sku_id), 0) as blue_sku_count, ifnull((select count(distinct(sku_id))
from replenishment where (closing_stock_zone_sort = 1 or closing_stock_zone_sort =
5) and transaction_date = rpl.transaction_date and sku_id = rpl.sku_id), 0) as
rb_sku_count from replenishment rpl use index(inx_sku_chart_s) where
rpl.transaction_date = ?param0 group by rpl.transaction_date, rpl.sku_id]
2018-03-15 10:55:08,829-Adding file [ImportExportLogHelper.xml] to list of watched
files.
2018-03-15 10:55:08,829-Statement Id: [SelectImportExportLogByType] Prepared SQL:
[select import_export_log_id, reference_date, reference_type, reference_title,
type, log_file, status, status_text, comment, created_by, created_on from
import_export_log where type = ?param0 order by reference_date desc]
2018-03-15 10:55:08,829-Statement Id: [InsertImportExportLog] Prepared SQL: [insert
into import_export_log (reference_date, reference_type, reference_title,
type, log_file, status, status_text, comment, created_by, created_on) values
(date_format( ?param0 , "%Y-%c-%e %H:%i:%s"), ?param1 , ?param2 , ?param3 , ?
param4 , ?param5 , ?param6 , ?param7 , ?param8 , NOW() );]
2018-03-15 10:55:08,829-Statement Id: [InsertImportExportLog.SelectKey] Prepared
SQL: [select last_insert_id() as value]
2018-03-15 10:55:08,829-Statement Id: [UpdateImportExportLog] Prepared SQL: [update
import_export_log set reference_date = date_format( ?param0 , "%Y-%c-%e %H:
%i:%s"), reference_type = ?param1 , reference_title = ?param2 ,
type = ?param3 , log_file = ?param4 , status = ?param5 ,
status_text = ?param6 , comment = ?param7 where
import_export_log_id = ?param8]
2018-03-15 10:55:08,829-Statement Id: [DeleteImportExportLog] Prepared SQL: [delete
from import_export_log where import_export_log_id = ?param0]
2018-03-15 10:55:08,845-Adding file [DynamicBufferManagementHelper.xml] to list of
watched files.
2018-03-15 10:55:08,845-Statement Id: [InsertDynamicBufferManagement] Prepared SQL:
[insert into dynamic_buffer_management (activate_auto_dbm,
excess_inv_occ_count, excess_inv_decrease_per, excess_inv_wait_cycle,
stockout_inv_occ_count, stockout_inv_decrease_per, stockout_inv_wait_cycle,
override_sku_location_dbm, activate_auto_dcm, red_percentage,
yellow_percentage, green_percentage, created_by, created_on) values (
?param0 , ?param1 , ?param2 , ?param3 , ?param4 , ?param5 , ?param6 ,
?param7 , ?param8 , ?param9 , ?param10 , ?param11 , ?param12 , NOW());]
2018-03-15 10:55:08,845-Statement Id: [InsertDynamicBufferManagement.SelectKey]
Prepared SQL: [select last_insert_id() as value]
2018-03-15 10:55:08,846-Statement Id: [UpdateDynamicBufferManagement] Prepared SQL:
[update dynamic_buffer_management set activate_auto_dbm = ?param0 ,
excess_inv_occ_count = ?param1 , excess_inv_decrease_per = ?param2 ,
excess_inv_wait_cycle = ?param3 , stockout_inv_occ_count = ?param4 ,
stockout_inv_decrease_per = ?param5 , stockout_inv_wait_cycle = ?param6 ,
override_sku_location_dbm = ?param7 , activate_auto_dcm = ?param8 ,
red_percentage = ?param9 , yellow_percentage = ?param10 ,
green_percentage = ?param11 , modified_by = ?param12 , modified_on
= NOW() where dynamic_buffer_management_id = ?param13]
2018-03-15 10:55:08,846-Adding file [ReplenishmentHelper.xml] to list of watched
files.
2018-03-15 10:55:08,846-Statement Id: [SelectReplenishmentData] Prepared SQL:
[select transaction_id, transaction_date, display_date, transfilter_date, sku_id,
sku_code, sku_name, node_id, node_code, node_name, category_id,
category_code, category_name, buffer_norm, grn, closing_quantity, in_transit,
sales, inst_hold, quality_hold, qa_hold, pending_orders, orders_in_hand,
transport_mode, supply_node_id, supply_node_name, supply_node_code,
supplying_quantity, supplying_buffer_norm, green_zone_qty, yellow_zone_qty,
red_zone_qty, closing_stock_zone, closing_stock_zone_sort, in_transit_zone,
in_transit_zone_sort, supplying_node_zone, supplying_node_zone_sort,
replenishment_quantity, final_quantity, mrq, transaction_comment,
open_stock_transfer_order, open_planned_order, open_purchase_request,
open_production_order, open_purchase_order, field1, field2, field3, field4,
field5, field6, field7, field8, field9, field10, mtd_sales, mtd_grn from
replenishment where transaction_date = ?param0]
2018-03-15 10:55:08,846-Statement Id: [SelectReplenishmentBySKUNode] Prepared SQL:
[select transaction_id, transaction_date, display_date, transfilter_date, sku_id,
sku_code, sku_name, node_id, node_code, node_name, category_id,
category_code, category_name, buffer_norm, closing_quantity, grn, in_transit,
sales, inst_hold, quality_hold, qa_hold, pending_orders, orders_in_hand,
transport_mode, supply_node_id, supply_node_name, supply_node_code,
supplying_quantity, supplying_buffer_norm, green_zone_qty, yellow_zone_qty,
red_zone_qty, closing_stock_zone, closing_stock_zone_sort, in_transit_zone,
in_transit_zone_sort, supplying_node_zone, supplying_node_zone_sort,
replenishment_quantity, final_quantity, mrq, transaction_comment,
open_stock_transfer_order, open_planned_order, open_purchase_request,
open_production_order, open_purchase_order, field1, field2, field3, field4,
field5, field6, field7, field8, field9, field10, mtd_sales, mtd_grn from
replenishment where transaction_date = ?param0 and sku_id = ?
param1 and node_id = ?param2]
2018-03-15 10:55:08,846-Statement Id: [SelectReplenishmentDates] Prepared SQL:
[SELECT DATE_FORMAT(transaction_date,'%Y-%m-%d') AS transaction_date FROM
replenishment USE INDEX (transaction_date) WHERE (transaction_date
BETWEEN ?param0 and ?param1 ) GROUP BY transaction_date]
2018-03-15 10:55:08,848-Statement Id: [InsertReplenishmentList] Prepared SQL:
[insert into replenishment (transaction_id, transaction_date, display_date,
transfilter_date, sku_id, sku_code, sku_name, node_id, node_code, node_name,
category_id, category_code, category_name, buffer_norm, grn, in_transit,
sales, inst_hold, quality_hold, qa_hold, pending_orders, orders_in_hand,
transport_mode, supply_node_id, supply_node_name, supply_node_code,
supplying_quantity, supplying_buffer_norm, green_zone_qty, yellow_zone_qty,
red_zone_qty, closing_stock_zone, closing_stock_zone_sort, in_transit_zone,
in_transit_zone_sort, supplying_node_zone, supplying_node_zone_sort,
replenishment_quantity, final_quantity, mrq, transaction_comment, db_sync,
mongo_sync, open_stock_transfer_order, open_planned_order,
open_purchase_request, open_production_order, open_purchase_order, field1,
field2, field3, field4, field5, field6, field7, field8, field9, field10,
closing_quantity, mtd_sales, mtd_grn ) SELECT tmt.transaction_id,
tmt.transaction_date, tmt.display_date, tmt.transfilter_date, tmt.sku_id,
tmt.sku_code, tmt.sku_name, tmt.node_id, tmt.node_code, tmt.node_name,
tmt.category_id, tmt.category_code, tmt.category_name, tmt.buffer_norm,
tmt.grn, tmt.in_transit, tmt.sales, tmt.inst_hold, tmt.quality_hold,
tmt.qa_hold, tmt.pending_orders, tmt.orders_in_hand, tmt.transport_mode,
tmt.supply_node_id, tmt.supply_node_name, tmt.supply_node_code,
tmt.supplying_quantity, tmt.supplying_buffer_norm, tmt.green_zone_qty,
tmt.yellow_zone_qty, tmt.red_zone_qty, tmt.closing_stock_zone,
tmt.closing_stock_zone_sort, tmt.in_transit_zone, tmt.in_transit_zone_sort,
tmt.supplying_node_zone, tmt.supplying_node_zone_sort,
tmt.replenishment_quantity, tmt.final_quantity, tmt.mrq,
tmt.transaction_comment, tmt.db_sync, tmt.mongo_sync,
tmt.open_stock_transfer_order, tmt.open_planned_order, tmt.open_purchase_request,
tmt.open_production_order, tmt.open_purchase_order, tmt.field1, tmt.field2,
tmt.field3, tmt.field4, tmt.field5, tmt.field6, tmt.field7, tmt.field8, tmt.field9,
tmt.field10, CASE WHEN IFNULL(tmt.closing_quantity,0) > 0 THEN
tmt.closing_quantity ELSE IFNULL((SELECT tcl.closing_quantity FROM
TRANSACTION tcl WHERE tcl.transaction_date < tmt.transaction_date AND
tcl.sku_id = tmt.sku_id AND tcl.node_id = tmt.node_id ORDER BY
tcl.transaction_date DESC LIMIT 1), 0) END AS closing_quantity,
IFNULL((SELECT SUM(tms.sales) FROM TRANSACTION tms USE INDEX
(inx_tdt_sku_node_sales) WHERE tms.transaction_date <= tmt.transaction_date
AND tms.transaction_date >= DATE_FORMAT(tmt.transaction_date,'%Y-%m-01') AND
tms.sku_id = tmt.sku_id AND tms.node_id = tmt.node_id), 0) AS mtd_sales,
IFNULL((SELECT SUM(tmg.grn) FROM TRANSACTION tmg USE INDEX (inx_tdt_sku_node_grn)
WHERE tmg.transaction_date <= tmt.transaction_date AND tmg.transaction_date >=
DATE_FORMAT(tmt.transaction_date,'%Y-%m-01') AND tmg.sku_id = tmt.sku_id AND
tmg.node_id = tmt.node_id), 0) AS mtd_grn FROM (SELECT
tr.transaction_id, tr.transaction_date, DATE_FORMAT(tr.transaction_date,'%d/%m/%Y')
AS display_date, DATE_FORMAT(tr.transaction_date,'%Y%m%d') AS transfilter_date,
tr.sku_id, s.sku_code, s.sku_name, tr.node_id, n.node_code, n.node_name,
sc.category_id, cat.category_code, cat.category_name, IFNULL(bn.buffer_norm,
0) AS buffer_norm, IFNULL(tr.closing_quantity, 0) AS closing_quantity,
IFNULL(tr.grn,0) AS grn, IFNULL(tr.in_transit, 0) AS in_transit, IFNULL(tr.sales,
0) AS sales, IFNULL(tr.inst_hold, 0) AS inst_hold, IFNULL(tr.quality_hold,
0) AS quality_hold, IFNULL(tr.qa_hold, 0) AS qa_hold,
IFNULL(tr.pending_orders, 0) AS pending_orders, IFNULL(tr.orders_in_hand, 0) AS
orders_in_hand, IFNULL(tr.transport_mode, '') AS transport_mode, CASE WHEN
IFNULL(tr.supply_node_id,0) > 0 THEN IFNULL(tr.supply_node_id,0) ELSE
IFNULL(nsm.supplier_node_id,0) END AS supply_node_id, sn.node_name AS
supply_node_name, sn.node_code AS supply_node_code,
IFNULL(str.closing_quantity, 0) AS supplying_quantity,
IFNULL(sbn.buffer_norm, 0) AS supplying_buffer_norm,
ROUND(IFNULL(bn.buffer_norm, 0),2) AS 'green_zone_qty', CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2)
END AS 'yellow_zone_qty', CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END AS 'red_zone_qty', CASE
WHEN IFNULL(bn.buffer_norm, 0) = 0 THEN 'White' WHEN
(IFNULL(tr.closing_quantity, 0) <= 0 AND IFNULL(bn.buffer_norm, 0) > 0) THEN
'Black' WHEN (IFNULL(tr.closing_quantity, 0) > IFNULL(bn.buffer_norm, 0) AND
IFNULL(bn.buffer_norm, 0) > 0) THEN 'Blue' WHEN (IFNULL(tr.closing_quantity,
0) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(tr.closing_quantity,
0) <= IFNULL(bn.buffer_norm, 0) AND IFNULL(bn.buffer_norm, 0) > 0) THEN 'Green'
WHEN (IFNULL(tr.closing_quantity, 0) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(tr.closing_quantity, 0) <=
(CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(bn.buffer_norm, 0) >
0) THEN 'Yellow' WHEN (IFNULL(tr.closing_quantity, 0) > 0 AND
IFNULL(tr.closing_quantity, 0) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(bn.buffer_norm, 0) > 0) THEN
'Red' END AS 'closing_stock_zone', CASE WHEN
IFNULL(bn.buffer_norm, 0) = 0 THEN 6 WHEN (IFNULL(tr.closing_quantity, 0) <=
0 AND IFNULL(bn.buffer_norm, 0) > 0) THEN 1 WHEN
(IFNULL(tr.closing_quantity, 0) > IFNULL(bn.buffer_norm, 0) AND
IFNULL(bn.buffer_norm, 0) > 0) THEN 2 WHEN (IFNULL(tr.closing_quantity, 0) >
(CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(tr.closing_quantity,
0) <= IFNULL(bn.buffer_norm, 0) AND IFNULL(bn.buffer_norm, 0) > 0) THEN 4
WHEN (IFNULL(tr.closing_quantity, 0) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(tr.closing_quantity, 0) <=
(CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(bn.buffer_norm, 0) >
0) THEN 3 WHEN (IFNULL(tr.closing_quantity, 0) > 0 AND
IFNULL(tr.closing_quantity, 0) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(bn.buffer_norm, 0) > 0) THEN
5 END AS 'closing_stock_zone_sort', CASE WHEN
IFNULL(bn.buffer_norm, 0) = 0 THEN 'White' WHEN
((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) <= 0 AND IFNULL(bn.buffer_norm, 0) > 0) THEN 'Black'
WHEN ((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > IFNULL(bn.buffer_norm, 0) AND
IFNULL(bn.buffer_norm, 0) > 0) THEN 'Blue' WHEN
((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND
(IFNULL(tr.closing_quantity, 0) + tr.in_transit - tr.pending_orders) <=
IFNULL(bn.buffer_norm, 0) AND IFNULL(bn.buffer_norm, 0) > 0) THEN 'Green'
WHEN ((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND (tr.closing_quantity +
tr.in_transit - tr.pending_orders) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2)
ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(bn.buffer_norm,
0) > 0) THEN 'Yellow' WHEN ((IFNULL(tr.closing_quantity, 0) +
IFNULL(tr.in_transit, 0) - IFNULL(tr.pending_orders, 0)) > 0 AND
(IFNULL(tr.closing_quantity, 0) + tr.in_transit - tr.pending_orders) <= (CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND
IFNULL(bn.buffer_norm, 0) > 0) THEN 'Red' END AS 'in_transit_zone',
CASE WHEN IFNULL(bn.buffer_norm, 0) = 0 THEN 6 WHEN
((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) <= 0 AND IFNULL(bn.buffer_norm, 0) > 0) THEN 1
WHEN ((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > IFNULL(bn.buffer_norm, 0) AND
IFNULL(bn.buffer_norm,
0) > 0) THEN 2 WHEN ((IFNULL(tr.closing_quantity, 0) +
IFNULL(tr.in_transit, 0) - IFNULL(tr.pending_orders, 0)) > (CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2)
END) AND (IFNULL(tr.closing_quantity, 0) + tr.in_transit - tr.pending_orders) <=
IFNULL(bn.buffer_norm, 0) AND IFNULL(bn.buffer_norm, 0) > 0) THEN 4 WHEN
((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND (IFNULL(tr.closing_quantity, 0) +
tr.in_transit - tr.pending_orders) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2)
ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(bn.buffer_norm,
0) > 0) THEN 3 WHEN ((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit,
0) - IFNULL(tr.pending_orders, 0)) > 0 AND (IFNULL(tr.closing_quantity, 0) +
tr.in_transit - tr.pending_orders) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(bn.buffer_norm, 0) > 0) THEN
5 END AS 'in_transit_zone_sort', CASE WHEN
IFNULL(sbn.buffer_norm, 0) = 0 THEN 'White' WHEN
(IFNULL(str.closing_quantity, 0) <= 0 AND IFNULL(sbn.buffer_norm, 0) > 0) THEN
'Black' WHEN (IFNULL(str.closing_quantity, 0) > IFNULL(sbn.buffer_norm, 0)
AND IFNULL(sbn.buffer_norm, 0) > 0) THEN 'Blue' WHEN
(IFNULL(str.closing_quantity, 0) > (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) AND
IFNULL(str.closing_quantity, 0) <= IFNULL(sbn.buffer_norm, 0) AND
IFNULL(sbn.buffer_norm, 0) > 0) THEN 'Green' WHEN
(IFNULL(str.closing_quantity, 0) > (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) AND IFNULL(str.closing_quantity, 0) <=
(CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) AND IFNULL(sbn.buffer_norm, 0)
> 0) THEN 'Yellow' WHEN (IFNULL(str.closing_quantity, 0) > 0 AND
IFNULL(str.closing_quantity, 0) <= (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) AND IFNULL(sbn.buffer_norm, 0) > 0)
THEN 'Red' END AS 'supplying_node_zone', CASE WHEN
IFNULL(sbn.buffer_norm, 0) = 0 THEN 6 WHEN (IFNULL(str.closing_quantity, 0)
<= 0 AND IFNULL(sbn.buffer_norm, 0) > 0) THEN 1 WHEN
(IFNULL(str.closing_quantity, 0) > IFNULL(sbn.buffer_norm, 0) AND
IFNULL(sbn.buffer_norm, 0) > 0) THEN 2 WHEN (IFNULL(str.closing_quantity, 0)
> (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) AND
IFNULL(str.closing_quantity, 0) <= IFNULL(sbn.buffer_norm, 0) AND
IFNULL(sbn.buffer_norm, 0) > 0) THEN 4 WHEN (IFNULL(str.closing_quantity, 0)
> (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) AND IFNULL(str.closing_quantity, 0) <=
(CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) AND IFNULL(sbn.buffer_norm, 0)
> 0) THEN 3 WHEN (IFNULL(str.closing_quantity, 0) > 0 AND
IFNULL(str.closing_quantity, 0) <= (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) AND IFNULL(sbn.buffer_norm, 0) > 0)
THEN 5 END AS 'supplying_node_zone_sort', CASE WHEN
((IFNULL(bn.buffer_norm, 0) - IFNULL(tr.closing_quantity, 0) -
IFNULL(tr.in_transit, 0)) + IFNULL(tr.pending_orders, 0)) -
(IFNULL(tr.open_planned_order, 0) + IFNULL(tr.open_purchase_request, 0) +
IFNULL(tr.open_production_order, 0) + IFNULL(tr.open_purchase_order, 0)) <= 0 THEN
0 ELSE ((IFNULL(bn.buffer_norm, 0) - IFNULL(tr.closing_quantity, 0) -
IFNULL(tr.in_transit, 0)) + IFNULL(tr.pending_orders, 0)) -
(IFNULL(tr.open_planned_order, 0) + IFNULL(tr.open_purchase_request, 0) +
IFNULL(tr.open_production_order, 0) + IFNULL(tr.open_purchase_order, 0)) END
AS 'replenishment_quantity', CASE WHEN (IFNULL(tr.closing_quantity,
0) + IFNULL(tr.in_transit, 0) + IFNULL(tr.open_planned_order, 0) +
IFNULL(tr.open_purchase_request, 0) + IFNULL(tr.open_production_order, 0) +
IFNULL(tr.open_purchase_order, 0) ) - IFNULL(tr.pending_orders, 0) <= 0 THEN 0
ELSE (IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) +
IFNULL(tr.open_planned_order, 0) + IFNULL(tr.open_purchase_request, 0) +
IFNULL(tr.open_production_order, 0) + IFNULL(tr.open_purchase_order, 0) ) -
IFNULL(tr.pending_orders, 0) END AS 'final_quantity', CASE
WHEN IFNULL(bn.buffer_norm, 0) = 0 THEN 0 ELSE (CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END)
END AS 'mrq', (SELECT COUNT(1) FROM transaction_comment WHERE
transaction_id = tr.transaction_id) AS 'transaction_comment', 0 AS db_sync, 0 AS
mongo_sync, IFNULL(tr.open_stock_transfer_order, 0) AS
open_stock_transfer_order, IFNULL(tr.open_planned_order, 0) AS open_planned_order,
IFNULL(tr.open_purchase_request, 0) AS open_purchase_request,
IFNULL(tr.open_production_order, 0) AS open_production_order,
IFNULL(tr.open_purchase_order, 0) AS open_purchase_order, tr.field1,
tr.field2, tr.field3, tr.field4, tr.field5, tr.field6, tr.field7, tr.field8,
tr.field9, tr.field10 from ( select tt.transaction_id from
transaction tt use index (transaction_date) inner join update_transaction ut
use index (inx_transactionid) on ut.transaction_id = tt.transaction_id
where tt.transaction_date = ?param0 ORDER BY tt.sku_id limit ?
param1 , ?param2 ) otr join transaction tr on
tr.transaction_id = otr.transaction_id LEFT JOIN buffer_norm bn USE INDEX
(inx_sku_node_efdt) ON bn.sku_id = tr.sku_id AND bn.node_id =
tr.node_id AND bn.effective_from = ( SELECT MAX(effective_from) FROM
buffer_norm WHERE effective_from <= tr.transaction_date AND sku_id =
tr.sku_id AND node_id = tr.node_id) LEFT JOIN sku s ON
s.sku_id = tr.sku_id LEFT JOIN sku_category sc ON
sc.sku_category_id = (SELECT sku_category_id FROM sku_category WHERE sku_id =
tr.sku_id LIMIT 1) LEFT JOIN category cat ON cat.category_id =
sc.category_id LEFT JOIN node n ON n.node_id = tr.node_id
LEFT OUTER JOIN node_sku_mapping nsm USE INDEX (inx_sku_receiver_node_efdt)
ON nsm.receiver_node_id = tr.node_id AND nsm.sku_id = tr.sku_id AND
nsm.effective_date = ( SELECT MAX(effective_date) FROM node_sku_mapping
WHERE effective_date <= tr.transaction_date AND sku_id = tr.sku_id
AND receiver_node_id = tr.node_id) LEFT JOIN node sn ON CASE WHEN
IFNULL(tr.supply_node_id,0) > 0 THEN sn.node_id = tr.supply_node_id ELSE
sn.node_id = nsm.supplier_node_id END LEFT JOIN buffer_norm sbn USE INDEX
(inx_sku_node_efdt) ON sbn.sku_id = tr.sku_id AND CASE WHEN
IFNULL(tr.supply_node_id,0) > 0 THEN sbn.node_id = tr.supply_node_id ELSE
sbn.node_id = nsm.supplier_node_id END AND sbn.effective_from =
( SELECT MAX(effective_from) FROM buffer_norm WHERE effective_from <=
tr.transaction_date AND sku_id = tr.sku_id AND node_id = tr.node_id)
LEFT JOIN TRANSACTION str USE INDEX (inx_tdt_sku_node_snode) ON
str.transaction_date = tr.transaction_date AND str.sku_id = tr.sku_id
AND CASE WHEN IFNULL(tr.supply_node_id,0) > 0 THEN str.node_id =
IFNULL(tr.supply_node_id,0) ELSE str.node_id = nsm.supplier_node_id END
GROUP BY tr.transaction_id ORDER BY tr.transaction_id) tmt ON
DUPLICATE KEY UPDATE category_id=VALUES(category_id),
category_code=VALUES(category_code), category_name=VALUES(category_name),
buffer_norm=VALUES(buffer_norm), closing_quantity=VALUES(closing_quantity),
grn=VALUES(grn), in_transit=VALUES(in_transit), sales=VALUES(sales),
inst_hold=VALUES(inst_hold), quality_hold=VALUES(quality_hold),
qa_hold=VALUES(qa_hold), pending_orders=VALUES(pending_orders),
orders_in_hand=VALUES(orders_in_hand), mtd_sales=VALUES(mtd_sales),
mtd_grn=VALUES(mtd_grn), transport_mode=VALUES(transport_mode),
supply_node_id=VALUES(supply_node_id), supply_node_name=VALUES(supply_node_name),
supply_node_code=VALUES(supply_node_code),
supplying_quantity=VALUES(supplying_quantity),
supplying_buffer_norm=VALUES(supplying_buffer_norm),
green_zone_qty=VALUES(green_zone_qty), yellow_zone_qty=VALUES(yellow_zone_qty),
red_zone_qty=VALUES(red_zone_qty), closing_stock_zone=VALUES(closing_stock_zone),
closing_stock_zone_sort=VALUES(closing_stock_zone_sort),
in_transit_zone=VALUES(in_transit_zone),
in_transit_zone_sort=VALUES(in_transit_zone_sort),
supplying_node_zone=VALUES(supplying_node_zone),
supplying_node_zone_sort=VALUES(supplying_node_zone_sort),
replenishment_quantity=VALUES(replenishment_quantity),
final_quantity=VALUES(final_quantity), mrq=VALUES(mrq), db_sync=VALUES(db_sync),
mongo_sync=VALUES(mongo_sync),
open_stock_transfer_order=VALUES(open_stock_transfer_order),
open_planned_order=VALUES(open_planned_order),
open_purchase_request=VALUES(open_purchase_request),
open_production_order=VALUES(open_production_order),
open_purchase_order=VALUES(open_purchase_order), field1=VALUES(field1),
field2=VALUES(field2), field3=VALUES(field3), field4=VALUES(field4),
field5=VALUES(field5), field6=VALUES(field6), field7=VALUES(field7),
field8=VALUES(field8), field9=VALUES(field9), field10=VALUES(field10);]
2018-03-15 10:55:08,849-Statement Id: [InsertReplenishmentListFullSync] Prepared
SQL: [insert into replenishment (transaction_id, transaction_date,
display_date, transfilter_date, sku_id, sku_code, sku_name, node_id, node_code,
node_name, category_id, category_code, category_name, buffer_norm,
closing_quantity, in_transit, sales, inst_hold, quality_hold, qa_hold,
pending_orders, orders_in_hand, transport_mode, supply_node_id,
supply_node_name, supply_node_code, supplying_quantity, supplying_buffer_norm,
green_zone_qty, yellow_zone_qty, red_zone_qty, closing_stock_zone,
closing_stock_zone_sort, in_transit_zone, in_transit_zone_sort,
supplying_node_zone, supplying_node_zone_sort, replenishment_quantity,
final_quantity, mrq, transaction_comment, db_sync, mongo_sync,
open_stock_transfer_order, open_planned_order, open_purchase_request,
open_production_order, open_purchase_order, field1, field2, field3, field4, field5,
field6, field7, field8, field9, field10 ) SELECT tr.transaction_id,
tr.transaction_date, DATE_FORMAT(tr.transaction_date,'%d/%m/%Y') AS display_date,
DATE_FORMAT(tr.transaction_date,'%Y%m%d') AS transfilter_date, tr.sku_id,
s.sku_code, s.sku_name, tr.node_id, n.node_code, n.node_name, sc.category_id,
cat.category_code, cat.category_name, IFNULL(bn.buffer_norm, 0) AS
buffer_norm, IFNULL(tr.closing_quantity, 0) AS closing_quantity,
IFNULL(tr.in_transit, 0) AS in_transit, IFNULL(tr.sales, 0) AS sales,
IFNULL(tr.inst_hold, 0) AS inst_hold, IFNULL(tr.quality_hold, 0) AS quality_hold,
IFNULL(tr.qa_hold, 0) AS qa_hold, IFNULL(tr.pending_orders, 0) AS
pending_orders, IFNULL(tr.orders_in_hand, 0) AS orders_in_hand,
IFNULL(tr.transport_mode, '') AS transport_mode, CASE WHEN
IFNULL(tr.supply_node_id,0) > 0 THEN IFNULL(tr.supply_node_id,0) ELSE
IFNULL(nsm.supplier_node_id,0) END AS supply_node_id, sn.node_name AS
supply_node_name, sn.node_code AS supply_node_code,
IFNULL(str.closing_quantity, 0) AS supplying_quantity,
IFNULL(sbn.buffer_norm, 0) AS supplying_buffer_norm,
ROUND(IFNULL(bn.buffer_norm, 0),2) AS 'green_zone_qty', CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2)
END AS 'yellow_zone_qty', CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END AS 'red_zone_qty', CASE
WHEN IFNULL(bn.buffer_norm, 0) = 0 THEN 'White' WHEN
(IFNULL(tr.closing_quantity, 0) <= 0 AND IFNULL(bn.buffer_norm, 0) > 0) THEN
'Black' WHEN (IFNULL(tr.closing_quantity, 0) > IFNULL(bn.buffer_norm, 0) AND
IFNULL(bn.buffer_norm, 0) > 0) THEN 'Blue' WHEN (IFNULL(tr.closing_quantity,
0) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(tr.closing_quantity,
0) <= IFNULL(bn.buffer_norm, 0) AND IFNULL(bn.buffer_norm, 0) > 0) THEN 'Green'
WHEN (IFNULL(tr.closing_quantity, 0) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(tr.closing_quantity, 0) <=
(CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(bn.buffer_norm, 0) >
0) THEN 'Yellow' WHEN (IFNULL(tr.closing_quantity, 0) > 0 AND
IFNULL(tr.closing_quantity, 0) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(bn.buffer_norm, 0) > 0) THEN
'Red' END AS 'closing_stock_zone', CASE WHEN
IFNULL(bn.buffer_norm, 0) = 0 THEN 6 WHEN (IFNULL(tr.closing_quantity, 0) <=
0 AND IFNULL(bn.buffer_norm, 0) > 0) THEN 1 WHEN
(IFNULL(tr.closing_quantity, 0) > IFNULL(bn.buffer_norm, 0) AND
IFNULL(bn.buffer_norm, 0) > 0) THEN 2 WHEN (IFNULL(tr.closing_quantity, 0) >
(CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(tr.closing_quantity,
0) <= IFNULL(bn.buffer_norm, 0) AND IFNULL(bn.buffer_norm, 0) > 0) THEN 4
WHEN (IFNULL(tr.closing_quantity, 0) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(tr.closing_quantity, 0) <=
(CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(bn.buffer_norm, 0) >
0) THEN 3 WHEN (IFNULL(tr.closing_quantity, 0) > 0 AND
IFNULL(tr.closing_quantity, 0) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(bn.buffer_norm, 0) > 0) THEN
5 END AS 'closing_stock_zone_sort', CASE WHEN
IFNULL(bn.buffer_norm, 0) = 0 THEN 'White' WHEN
((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) <= 0 AND IFNULL(bn.buffer_norm, 0) > 0) THEN 'Black'
WHEN ((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > IFNULL(bn.buffer_norm, 0) AND
IFNULL(bn.buffer_norm, 0) > 0) THEN 'Blue' WHEN
((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND
(IFNULL(tr.closing_quantity, 0) + tr.in_transit - tr.pending_orders) <=
IFNULL(bn.buffer_norm, 0) AND IFNULL(bn.buffer_norm, 0) > 0) THEN 'Green'
WHEN ((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND (tr.closing_quantity +
tr.in_transit - tr.pending_orders) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2)
ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(bn.buffer_norm,
0) > 0) THEN 'Yellow' WHEN ((IFNULL(tr.closing_quantity, 0) +
IFNULL(tr.in_transit, 0) - IFNULL(tr.pending_orders, 0)) > 0 AND
(IFNULL(tr.closing_quantity, 0) + tr.in_transit - tr.pending_orders) <= (CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND
IFNULL(bn.buffer_norm, 0) > 0) THEN 'Red' END AS 'in_transit_zone',
CASE WHEN IFNULL(bn.buffer_norm, 0) = 0 THEN 6 WHEN
((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) <= 0 AND IFNULL(bn.buffer_norm, 0) > 0) THEN 1
WHEN ((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > IFNULL(bn.buffer_norm, 0) AND
IFNULL(bn.buffer_norm, 0) > 0) THEN 2 WHEN ((IFNULL(tr.closing_quantity, 0)
+ IFNULL(tr.in_transit, 0) - IFNULL(tr.pending_orders, 0)) > (CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2)
END) AND (IFNULL(tr.closing_quantity, 0) + tr.in_transit - tr.pending_orders) <=
IFNULL(bn.buffer_norm, 0) AND IFNULL(bn.buffer_norm, 0) > 0) THEN 4 WHEN
((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND (IFNULL(tr.closing_quantity, 0) +
tr.in_transit - tr.pending_orders) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2)
ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(bn.buffer_norm,
0) > 0) THEN 3 WHEN ((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit,
0) - IFNULL(tr.pending_orders, 0)) > 0 AND (IFNULL(tr.closing_quantity, 0) +
tr.in_transit - tr.pending_orders) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(bn.buffer_norm, 0) > 0) THEN
5 END AS 'in_transit_zone_sort', CASE WHEN
IFNULL(sbn.buffer_norm, 0) = 0 THEN 'White' WHEN
(IFNULL(str.closing_quantity, 0) <= 0 AND IFNULL(sbn.buffer_norm, 0) > 0) THEN
'Black' WHEN (IFNULL(str.closing_quantity, 0) > IFNULL(sbn.buffer_norm, 0)
AND IFNULL(sbn.buffer_norm, 0) > 0) THEN 'Blue' WHEN
(IFNULL(str.closing_quantity, 0) > (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) AND
IFNULL(str.closing_quantity, 0) <= IFNULL(sbn.buffer_norm, 0) AND
IFNULL(sbn.buffer_norm, 0) > 0) THEN 'Green' WHEN
(IFNULL(str.closing_quantity, 0) > (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.red_zone,0)
/ 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE ROUND(IFNULL(sbn.buffer_norm, 0) /
3,2) END) AND IFNULL(str.closing_quantity, 0) <= (CASE WHEN
IFNULL(sbn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(sbn.yellow_zone,0) / 100)
* IFNULL(sbn.buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(sbn.buffer_norm,
0)),2) END) AND IFNULL(sbn.buffer_norm, 0) > 0) THEN 'Yellow' WHEN
(IFNULL(str.closing_quantity, 0) > 0 AND IFNULL(str.closing_quantity, 0) <= (CASE
WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(sbn.red_zone,0) /
100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2)
END) AND IFNULL(sbn.buffer_norm, 0) > 0) THEN 'Red' END AS
'supplying_node_zone', CASE WHEN IFNULL(sbn.buffer_norm, 0) = 0
THEN 6 WHEN (IFNULL(str.closing_quantity, 0) <= 0 AND
IFNULL(sbn.buffer_norm, 0) > 0) THEN 1 WHEN (IFNULL(str.closing_quantity, 0)
> IFNULL(sbn.buffer_norm, 0) AND IFNULL(sbn.buffer_norm, 0) > 0) THEN 2 WHEN
(IFNULL(str.closing_quantity, 0) > (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) AND
IFNULL(str.closing_quantity, 0) <= IFNULL(sbn.buffer_norm, 0) AND
IFNULL(sbn.buffer_norm, 0) > 0) THEN 4 WHEN (IFNULL(str.closing_quantity, 0)
> (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) AND IFNULL(str.closing_quantity, 0) <=
(CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) AND IFNULL(sbn.buffer_norm, 0)
> 0) THEN 3 WHEN (IFNULL(str.closing_quantity, 0) > 0 AND
IFNULL(str.closing_quantity, 0) <= (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) AND IFNULL(sbn.buffer_norm, 0) > 0)
THEN 5 END AS 'supplying_node_zone_sort', CASE WHEN
((IFNULL(bn.buffer_norm, 0) - IFNULL(tr.closing_quantity, 0) -
IFNULL(tr.in_transit, 0)) + IFNULL(tr.pending_orders, 0)) -
(IFNULL(tr.open_planned_order, 0) + IFNULL(tr.open_purchase_request, 0) +
IFNULL(tr.open_production_order, 0) + IFNULL(tr.open_purchase_order, 0)) <= 0 THEN
0 ELSE ((IFNULL(bn.buffer_norm, 0) - IFNULL(tr.closing_quantity, 0) -
IFNULL(tr.in_transit, 0)) + IFNULL(tr.pending_orders, 0)) -
(IFNULL(tr.open_planned_order, 0) + IFNULL(tr.open_purchase_request, 0) +
IFNULL(tr.open_production_order, 0) + IFNULL(tr.open_purchase_order, 0)) END
AS 'replenishment_quantity', CASE WHEN (IFNULL(tr.closing_quantity,
0) + IFNULL(tr.in_transit, 0) + IFNULL(tr.open_planned_order, 0) +
IFNULL(tr.open_purchase_request, 0) + IFNULL(tr.open_production_order, 0) +
IFNULL(tr.open_purchase_order, 0) ) - IFNULL(tr.pending_orders, 0) <= 0 THEN 0
ELSE (IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) +
IFNULL(tr.open_planned_order, 0) + IFNULL(tr.open_purchase_request, 0) +
IFNULL(tr.open_production_order, 0) + IFNULL(tr.open_purchase_order, 0) ) -
IFNULL(tr.pending_orders, 0) END AS 'final_quantity', CASE
WHEN IFNULL(bn.buffer_norm, 0) = 0 THEN 0 ELSE (CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END)
END AS 'mrq', (SELECT COUNT(1) FROM transaction_comment WHERE
transaction_id = tr.transaction_id) AS 'transaction_comment', 0 AS db_sync, 0 AS
mongo_sync, IFNULL(tr.open_stock_transfer_order, 0),
IFNULL(tr.open_planned_order, 0), IFNULL(tr.open_purchase_request,
0),IFNULL(tr.open_production_order, 0), IFNULL(tr.open_purchase_order, 0),
tr.field1, tr.field2, tr.field3, tr.field4, tr.field5, tr.field6, tr.field7,
tr.field8, tr.field9, tr.field10 from ( select tt.transaction_id
from transaction tt use index (transaction_date) where
tt.transaction_date = ?param0 ORDER BY tt.sku_id limit ?
param1 , ?param2 ) otr join transaction tr on
tr.transaction_id = otr.transaction_id LEFT JOIN buffer_norm bn USE INDEX
(inx_sku_node_efdt) ON bn.sku_id = tr.sku_id AND bn.node_id =
tr.node_id AND bn.effective_from = ( SELECT MAX(effective_from) FROM
buffer_norm WHERE effective_from <= tr.transaction_date AND sku_id =
tr.sku_id AND node_id = tr.node_id) LEFT JOIN sku s ON
s.sku_id = tr.sku_id LEFT JOIN sku_category sc ON
sc.sku_category_id = (SELECT sku_category_id FROM sku_category WHERE sku_id =
tr.sku_id LIMIT 1) LEFT JOIN category cat ON cat.category_id =
sc.category_id LEFT JOIN node n ON n.node_id = tr.node_id
LEFT OUTER JOIN node_sku_mapping nsm USE INDEX (inx_sku_receiver_node_efdt)
ON nsm.receiver_node_id = tr.node_id AND nsm.sku_id = tr.sku_id AND
nsm.effective_date = ( SELECT MAX(effective_date) FROM node_sku_mapping
WHERE effective_date <= tr.transaction_date AND sku_id = tr.sku_id
AND receiver_node_id = tr.node_id) LEFT JOIN node sn ON CASE WHEN
IFNULL(tr.supply_node_id,0) > 0 THEN sn.node_id = tr.supply_node_id ELSE
sn.node_id = nsm.supplier_node_id END LEFT JOIN buffer_norm sbn USE INDEX
(inx_sku_node_efdt) ON sbn.sku_id = tr.sku_id AND CASE WHEN
IFNULL(tr.supply_node_id,0) > 0 THEN sbn.node_id = tr.supply_node_id ELSE
sbn.node_id = nsm.supplier_node_id END AND sbn.effective_from =
( SELECT MAX(effective_from) FROM buffer_norm WHERE effective_from <=
tr.transaction_date AND sku_id = tr.sku_id AND node_id = tr.node_id)
LEFT JOIN TRANSACTION str USE INDEX (inx_tdt_sku_node_snode) ON
str.transaction_date = tr.transaction_date AND str.sku_id = tr.sku_id
AND CASE WHEN IFNULL(tr.supply_node_id,0) > 0 THEN str.node_id =
IFNULL(tr.supply_node_id,0) ELSE str.node_id = nsm.supplier_node_id END
GROUP BY tr.transaction_id ORDER BY tr.transaction_id]
2018-03-15 10:55:08,849-Adding file [UserHelper.xml] to list of watched files.
2018-03-15 10:55:08,850-Statement Id: [SelectUserNameDuplicate] Prepared SQL:
[select user_id, user_name, first_name, middle_name, last_name, email, mobile,
description, password, status, approved, locked, role_id, region_id,
created_by, created_on, modified_by, modified_on from user where user_name =
?param0 and user_id != ?param1]
2018-03-15 10:55:08,850-Statement Id: [SelectUserMobileDuplicate] Prepared SQL:
[select user_id, user_name, first_name, middle_name, last_name, email, mobile,
description, password, status, approved, locked, role_id, region_id,
created_by, created_on, modified_by, modified_on from user where mobile = ?
param0 and user_id != ?param1]
2018-03-15 10:55:08,850-Statement Id: [SelectUserCheckAuthenticate] Prepared SQL:
[select user_id, user_name, first_name, middle_name, last_name, email, mobile,
description, password, status, approved, locked, role_id, region_id,
created_by, created_on, modified_by, modified_on from user where user_name =
?param0 and password = ?param1 and status = 1]
2018-03-15 10:55:08,850-Statement Id: [SelectUserCheckLocked] Prepared SQL: [select
user_id, user_name, first_name, middle_name, last_name, email, mobile, description,
password, status, approved, locked, role_id, region_id, created_by,
created_on, modified_by, modified_on from user where user_name = ?param0]
2018-03-15 10:55:08,850-Statement Id: [InsertUser] Prepared SQL: [insert into user
(user_name, first_name, middle_name, last_name, email, mobile, description,
password, status, approved, locked, role_id, region_id, created_by,
created_on) values ( ?param0 , ?param1 , ?param2 , ?param3 , ?
param4 , ?param5 , ?param6 , ?param7 , ?param8 , ?param9 , ?param10 ,
?param11 , ?param12 , ?param13 , NOW());]
2018-03-15 10:55:08,850-Statement Id: [InsertUser.SelectKey] Prepared SQL: [select
last_insert_id() as value]
2018-03-15 10:55:08,850-Statement Id: [UpdateUser] Prepared SQL: [update user set
user_name = ?param0 , first_name = ?param1 , middle_name = ?param2
, last_name = ?param3 , email = ?param4 , mobile = ?
param5 , description = ?param6 , password = ?param7 , status
= ?param8 , approved = ?param9 , locked = ?param10 ,
role_id = ?param11 , region_id = ?param12 , modified_by = ?param13
, modified_on = NOW() where user_id = ?param14]
2018-03-15 10:55:08,850-Statement Id: [DeleteUser] Prepared SQL: [delete from user
where user_id = ?param0]
2018-03-15 10:55:08,850-Adding file [UserModuleHelper.xml] to list of watched
files.
2018-03-15 10:55:08,850-Statement Id: [InsertUserModule] Prepared SQL: [insert into
user_module (role_id, module_id, created_by, created_on) values
( ?param0 , ?param1 , ?param2 , NOW());]
2018-03-15 10:55:08,850-Statement Id: [InsertUserModule.SelectKey] Prepared SQL:
[select last_insert_id() as value]
2018-03-15 10:55:08,850-Statement Id: [DeleteUserModule] Prepared SQL: [delete from
user_module where user_module_id = ?param0]
2018-03-15 10:55:08,850-Statement Id: [DeleteModuleByRole] Prepared SQL: [delete
from user_module where role_id = ?param0]
2018-03-15 10:55:08,850-Adding file [SKUGridHelper.xml] to list of watched files.
2018-03-15 10:55:08,869-Statement Id: [SelectSKUGrid] Prepared SQL: [select
s.sku_name, n.node_name, c.category_id, c.category_name, sku_grid.*, case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (1 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(1 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (1 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (1 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (1 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (1 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (1 * avg_sales)) > 0 and (closing_quantity - (1 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(red_zone,0) /
100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and
buffer_norm > 0) then 'Red' end as 'one', case when (closing_quantity
- (1 * avg_sales)) <= 0 then 0 else (closing_quantity - (1 * avg_sales)) end as
'one_qty', case when ifnull(buffer_norm, 0) = 0 then 'White'
when ((closing_quantity - (2 * avg_sales)) <= 0 and buffer_norm > 0) then 'Black'
when ((closing_quantity - (2 * avg_sales)) > buffer_norm and buffer_norm > 0) then
'Blue' when ((closing_quantity - (2 * avg_sales)) > (CASE WHEN
IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) *
IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END)
and (closing_quantity - (2 * avg_sales)) <= buffer_norm and buffer_norm > 0) then
'Green' when ((closing_quantity - (2 * avg_sales)) > (CASE WHEN
IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(red_zone,0) / 100) *
IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and
(closing_quantity - (2 * avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow'
when ((closing_quantity - (2 * avg_sales)) > 0 and (closing_quantity - (2 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'two', case when (closing_quantity - (2 * avg_sales)) <= 0 then 0 else
(closing_quantity - (2 * avg_sales)) end as 'two_qty', case when
ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (3 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(3 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (3 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (3 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (3 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (3 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (3 * avg_sales)) > 0 and (closing_quantity - (3 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(red_zone,0) /
100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and
buffer_norm > 0) then 'Red' end as 'three', case when
(closing_quantity - (3 * avg_sales)) <= 0 then 0 else (closing_quantity - (3 *
avg_sales)) end as 'three_qty', case when ifnull(buffer_norm, 0) = 0
then 'White' when ((closing_quantity - (4 * avg_sales)) <= 0 and buffer_norm
> 0) then 'Black' when ((closing_quantity - (4 * avg_sales)) > buffer_norm
and buffer_norm > 0) then 'Blue' when ((closing_quantity - (4 * avg_sales))
> (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(yellow_zone,0) /
100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2)
END) and (closing_quantity - (4 * avg_sales)) <= buffer_norm and buffer_norm > 0)
then 'Green' when ((closing_quantity - (4 * avg_sales)) > (CASE WHEN
IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(red_zone,0) / 100) *
IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and
(closing_quantity - (4 * avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow'
when ((closing_quantity - (4 * avg_sales)) > 0 and (closing_quantity - (4 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'four', case when (closing_quantity - (4 * avg_sales)) <= 0 then 0 else
(closing_quantity - (4 * avg_sales)) end as 'four_qty', case when
ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (5 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(5 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (5 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (5 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (5 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (5 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (5 * avg_sales)) > 0 and (closing_quantity - (5 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(red_zone,0) /
100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and
buffer_norm > 0) then 'Red' end as 'five', case when
(closing_quantity - (5 * avg_sales)) <= 0 then 0 else (closing_quantity - (5 *
avg_sales)) end as 'five_qty', case when ifnull(buffer_norm, 0) = 0
then 'White' when ((closing_quantity - (6 * avg_sales)) <= 0 and buffer_norm
> 0) then 'Black' when ((closing_quantity - (6 * avg_sales)) > buffer_norm
and buffer_norm > 0) then 'Blue' when ((closing_quantity - (6 * avg_sales))
> (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(yellow_zone,0) /
100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2)
END) and (closing_quantity - (6 * avg_sales)) <= buffer_norm and buffer_norm > 0)
then 'Green' when ((closing_quantity - (6 * avg_sales)) > (CASE WHEN
IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(red_zone,0) / 100) *
IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and
(closing_quantity - (6 * avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow'
when ((closing_quantity - (6 * avg_sales)) > 0 and (closing_quantity - (6 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'six', case when (closing_quantity - (6 * avg_sales)) <= 0 then 0 else
(closing_quantity - (6 * avg_sales)) end as 'six_qty', case when
ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (7 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(7 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (7 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (7 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (7 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (7 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm
> 0) then 'Yellow' when ((closing_quantity - (7 * avg_sales)) > 0 and
(closing_quantity - (7 * avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'seven', case when (closing_quantity - (7 * avg_sales)) <= 0 then 0 else
(closing_quantity - (7 * avg_sales)) end as 'seven_qty', case when
ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (8 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(8 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (8 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (8 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (8 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (8 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (8 * avg_sales)) > 0 and (closing_quantity - (8 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(red_zone,0) /
100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and
buffer_norm > 0) then 'Red' end as 'eight', case when
(closing_quantity - (8 * avg_sales)) <= 0 then 0 else (closing_quantity - (8 *
avg_sales)) end as 'eight_qty', case when ifnull(buffer_norm, 0) = 0
then 'White' when ((closing_quantity - (9 * avg_sales)) <= 0 and buffer_norm
> 0) then 'Black' when ((closing_quantity - (9 * avg_sales)) > buffer_norm
and buffer_norm > 0) then 'Blue' when ((closing_quantity - (9 * avg_sales))
> (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(yellow_zone,0) /
100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2)
END) and (closing_quantity - (9 * avg_sales)) <= buffer_norm and buffer_norm > 0)
then 'Green' when ((closing_quantity - (9 * avg_sales)) > (CASE WHEN
IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(red_zone,0) / 100) *
IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and
(closing_quantity - (9 * avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow'
when ((closing_quantity - (9 * avg_sales)) > 0 and (closing_quantity - (9 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'nine', case when (closing_quantity - (9 * avg_sales)) <= 0 then 0 else
(closing_quantity - (9 * avg_sales)) end as 'nine_qty', case when
ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (10 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(10 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (10 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (10 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (10 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (10 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (10 * avg_sales)) > 0 and (closing_quantity - (10 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'ten', case when (closing_quantity - (10 * avg_sales)) <= 0 then 0 else
(closing_quantity - (10 * avg_sales)) end as 'ten_qty', case when
ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (11 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(11 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (11 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (11 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (11 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (11 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (11 * avg_sales)) > 0 and (closing_quantity - (11 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'eleven', case when (closing_quantity - (11 * avg_sales)) <= 0 then 0
else (closing_quantity - (11 * avg_sales)) end as 'eleven_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (12 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(12 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (12 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (12 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (12 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (12 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (12 * avg_sales)) > 0 and (closing_quantity - (12 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twelve', case when (closing_quantity - (12 * avg_sales)) <= 0 then 0
else (closing_quantity - (12 * avg_sales)) end as 'twelve_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (13 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(13 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (13 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (13 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (13 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (13 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (13 * avg_sales)) > 0 and (closing_quantity - (13 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'thirteen', case when (closing_quantity - (13 * avg_sales)) <= 0 then 0
else (closing_quantity - (13 * avg_sales)) end as 'thirteen_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (14 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(14 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (14 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (14 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (14 * avg_sales)) > (CASE
WHEN IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(red_zone,0) / 100) *
IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and
(closing_quantity - (14 * avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow'
when ((closing_quantity - (14 * avg_sales)) > 0 and (closing_quantity - (14 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'fourteen', case when (closing_quantity - (14 * avg_sales)) <= 0 then 0
else (closing_quantity - (14 * avg_sales)) end as 'fourteen_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (15 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(15 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (15 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (15 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (15 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (15 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (15 * avg_sales)) > 0 and (closing_quantity - (15 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'fifteen', case when (closing_quantity - (15 * avg_sales)) <= 0 then 0
else (closing_quantity - (15 * avg_sales)) end as 'fifteen_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (16 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(16 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (16 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (16 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (16 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (16 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (16 * avg_sales)) > 0 and (closing_quantity - (16 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'sixteen', case when (closing_quantity - (16 * avg_sales)) <= 0 then 0
else (closing_quantity - (16 * avg_sales)) end as 'sixteen_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (17 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(17 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (17 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (17 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (17 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (17 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (17 * avg_sales)) > 0 and (closing_quantity - (17 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'seventeen', case when (closing_quantity - (17 * avg_sales)) <= 0 then 0
else (closing_quantity - (17 * avg_sales)) end as 'seventeen_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (18 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(18 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (18 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (18 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (18 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (18 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (18 * avg_sales)) > 0 and (closing_quantity - (18 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'eighteen', case when (closing_quantity - (18 * avg_sales)) <= 0 then 0
else (closing_quantity - (18 * avg_sales)) end as 'eighteen_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (19 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(19 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (19 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (19 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (19 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (19 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (19 * avg_sales)) > 0 and (closing_quantity - (19 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'nineteen', case when (closing_quantity - (19 * avg_sales)) <= 0 then 0
else (closing_quantity - (19 * avg_sales)) end as 'nineteen_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (20 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(20 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (20 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (20 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (20 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (20 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (20 * avg_sales)) > 0 and (closing_quantity - (20 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twenty', case when (closing_quantity - (20 * avg_sales)) <= 0 then 0
else (closing_quantity - (20 * avg_sales)) end as 'twenty_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (21 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity
- (21 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (21 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (21 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (21 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (21 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (21 * avg_sales)) > 0 and (closing_quantity - (21 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twentyone', case when (closing_quantity - (21 * avg_sales)) <= 0 then 0
else (closing_quantity - (21 * avg_sales)) end as 'twentyone_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (22 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(22 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (22 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (22 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (22 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (22 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (22 * avg_sales)) > 0 and (closing_quantity - (22 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twentytwo', case when (closing_quantity - (22 * avg_sales)) <= 0 then 0
else (closing_quantity - (22 * avg_sales)) end as 'twentytwo_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (23 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(23 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (23 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (23 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (23 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (23 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (23 * avg_sales)) > 0 and (closing_quantity - (23 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twentythree', case when (closing_quantity - (23 * avg_sales)) <= 0 then
0 else (closing_quantity - (23 * avg_sales)) end as 'twentythree_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (24 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(24 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (24 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (24 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (24 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (24 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (24 * avg_sales)) > 0 and (closing_quantity - (24 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twentyfour', case when (closing_quantity - (24 * avg_sales)) <= 0 then 0
else (closing_quantity - (24 * avg_sales)) end as 'twentyfour_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (25 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(25 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (25 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (25 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (25 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (25 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (25 * avg_sales)) > 0 and (closing_quantity - (25 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twentyfive', case when (closing_quantity - (25 * avg_sales)) <= 0 then 0
else (closing_quantity - (25 * avg_sales)) end as 'twentyfive_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (26 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(26 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (26 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (26 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (26 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (26 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (26 * avg_sales)) > 0 and (closing_quantity - (26 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twentysix', case when (closing_quantity - (26 * avg_sales)) <= 0 then 0
else (closing_quantity - (26 * avg_sales)) end as 'twentysix_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (27 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(27 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (27 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (27 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (27 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (27 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (27 * avg_sales)) > 0 and (closing_quantity - (27 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0)
/ 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END)
and buffer_norm > 0) then 'Red' end as 'twentyseven', case when
(closing_quantity - (27 * avg_sales)) <= 0 then 0 else (closing_quantity - (27 *
avg_sales)) end as 'twentyseven_qty', case when ifnull(buffer_norm,
0) = 0 then 'White' when ((closing_quantity - (28 * avg_sales)) <= 0 and
buffer_norm > 0) then 'Black' when ((closing_quantity - (28 * avg_sales)) >
buffer_norm and buffer_norm > 0) then 'Blue' when ((closing_quantity - (28 *
avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (28 * avg_sales)) <=
buffer_norm and buffer_norm > 0) then 'Green' when ((closing_quantity - (28
* avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (28 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (28 * avg_sales)) > 0 and (closing_quantity - (28 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twentyeight', case when (closing_quantity - (28 * avg_sales)) <= 0 then
0 else (closing_quantity - (28 * avg_sales)) end as 'twentyeight_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (29 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(29 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (29 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (29 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (29 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (29 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (29 * avg_sales)) > 0 and (closing_quantity - (29 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twentynine', case when (closing_quantity - (29 * avg_sales)) <= 0 then 0
else (closing_quantity - (29 * avg_sales)) end as 'twentynine_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (30 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(30 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (30 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (30 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (30 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (30 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (30 * avg_sales)) > 0 and (closing_quantity - (30 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'thirty', case when (closing_quantity - (30 * avg_sales)) <= 0 then 0
else (closing_quantity - (30 * avg_sales)) end as 'thirty_qty' from (
select tr.sku_id, tr.node_id, round(sum(tr.sales) / 15, 2) as avg_sales,
t.closing_quantity, ifnull(bn.buffer_norm, (select buffer_norm from
buffer_norm use index(inx_sku_node_efdt) where effective_from < tr.transaction_date
and sku_id = tr.sku_id and node_id = tr.node_id order by effective_from desc limit
1)) as buffer_norm, ifnull(bn.is_default_zone,'Y') as is_default_zone,
ifnull(bn.yellow_zone,0) as yellow_zone, ifnull(bn.red_zone,0) as red_zone,
case when (t.closing_quantity + t.in_transit - t.pending_orders) <= 0 then 0
else (t.closing_quantity + t.in_transit - t.pending_orders) end as
'final_quantity' from transaction tr inner join transaction t
on t.transaction_date = ?param0 and t.sku_id = tr.sku_id and
t.node_id = tr.node_id left join buffer_norm bn use
index(inx_sku_node_efdt) on bn.sku_id = tr.sku_id and bn.node_id =
tr.node_id and bn.effective_from = ?param0 where tr.sku_id = ?
param1 and tr.node_id = ?param2 and tr.transaction_date > ?param3 group
by tr.sku_id, tr.node_id ) as sku_grid inner join sku s on
s.sku_id = sku_grid.sku_id inner join node n on n.node_id =
sku_grid.node_id inner join sku_category sc on sc.sku_category_id =
(select sku_category_id from sku_category where sku_id = sku_grid.sku_id limit 1)
inner join category c on c.category_id = sc.category_id]
2018-03-15 10:55:08,869-Adding file [ExcessInventoryHelper.xml] to list of watched
files.
2018-03-15 10:55:08,877-Adding file [StockoutAvailabilityChartHelper.xml] to list
of watched files.
2018-03-15 10:55:08,878-Adding file [InventoryTurnsHelper.xml] to list of watched
files.
2018-03-15 10:55:08,879-Statement Id: [SelectInventoryTurns] Prepared SQL: [select
rpl.transaction_date, rpl.category_id, rpl.category_name,
date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date, sum(1) as
count, sum(rpl.closing_quantity) as closing_quantity, sum(rpl.sales) as sales
from replenishment rpl where rpl.category_id is not null and
rpl.transaction_date = ?param0 group by rpl.transaction_date,
rpl.category_id]
2018-03-15 10:55:08,879-Statement Id: [SelectInventoryTurnsSKU] Prepared SQL:
[select rpl.transaction_date, rpl.category_id, rpl.sku_id, rpl.category_name,
date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date, sum(1) as
count, sum(rpl.closing_quantity) as closing_quantity, sum(rpl.sales) as sales
from replenishment rpl where rpl.category_id is not null and
rpl.transaction_date = ?param0 group by rpl.transaction_date,
rpl.category_id, rpl.sku_id]
2018-03-15 10:55:08,879-Adding file [CntQtyFillRateChartHelper.xml] to list of
watched files.
2018-03-15 10:55:08,880-Statement Id: [SelectCntQtyFillRateChart] Prepared SQL:
[select rpl.transaction_date, rpl.closing_stock_zone,
group_concat(distinct(rpl.sku_id) SEPARATOR ',') as str_sku_ids,
date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date,
sum(rpl.closing_quantity) as closing_quantity, sum(rpl.buffer_norm) as buffer_norm
from replenishment rpl where rpl.closing_stock_zone != "White" and
rpl.transaction_date = ?param0 group by rpl.transaction_date,
rpl.closing_stock_zone]
2018-03-15 10:55:08,880-Statement Id: [SelectCntQtyFillRateChartNode] Prepared SQL:
[select rpl.transaction_date, rpl.closing_stock_zone, rpl.node_id,
group_concat(distinct(rpl.sku_id) SEPARATOR ',') as str_sku_ids,
date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date,
sum(rpl.closing_quantity) as closing_quantity, sum(rpl.buffer_norm) as buffer_norm
from replenishment rpl where rpl.closing_stock_zone != "White" and
rpl.transaction_date = ?param0 group by rpl.transaction_date,
rpl.closing_stock_zone, rpl.node_id]
2018-03-15 10:55:08,880-Statement Id: [SelectCntQtyFillRateChartCategory] Prepared
SQL: [select rpl.transaction_date, rpl.closing_stock_zone, rpl.category_id,
group_concat(distinct(rpl.sku_id) SEPARATOR ',') as str_sku_ids,
date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date,
sum(rpl.closing_quantity) as closing_quantity, sum(rpl.buffer_norm) as buffer_norm
from replenishment rpl where rpl.closing_stock_zone != "White" and
rpl.transaction_date = ?param0 group by rpl.transaction_date,
rpl.closing_stock_zone, rpl.category_id]
2018-03-15 10:55:08,880-Statement Id: [SelectCntQtyFillRateChartSKU] Prepared SQL:
[select rpl.transaction_date, rpl.closing_stock_zone, rpl.sku_id,
group_concat(distinct(rpl.sku_id) SEPARATOR ',') as str_sku_ids,
date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date,
sum(rpl.closing_quantity) as closing_quantity, sum(rpl.buffer_norm) as buffer_norm
from replenishment rpl where rpl.closing_stock_zone != "White" and
rpl.transaction_date = ?param0 group by rpl.transaction_date,
rpl.closing_stock_zone, rpl.sku_id]
2018-03-15 10:55:08,880-Adding file [UserDataPermissionHelper.xml] to list of
watched files.
2018-03-15 10:55:08,881-Statement Id: [SelectDataPermissionByRole] Prepared SQL:
[select user_data_id, role_id, object_type, object_id, chk_state, created_by,
created_on from user_data_permissions WHERE role_id = ?param0 AND
object_type = ?param1]
2018-03-15 10:55:08,881-Statement Id: [InsertUserDataPermission] Prepared SQL:
[insert into user_data_permissions (role_id, object_type, object_id,
chk_state, created_by, created_on) values ( ?param0 , ?param1 , ?
param2 , ?param3 , ?param4 , NOW());]
2018-03-15 10:55:08,881-Statement Id: [InsertUserDataPermission.SelectKey] Prepared
SQL: [select last_insert_id() as value]
2018-03-15 10:55:08,881-Statement Id: [DeleteDataPermissionByRole] Prepared SQL:
[delete from user_data_permissions where role_id = ?param0]
2018-03-15 10:55:08,881-Adding file [RoleHelper.xml] to list of watched files.
2018-03-15 10:55:08,882-Statement Id: [SelectRoleNameDuplicate] Prepared SQL:
[select role_id,role_name,status,created_by,created_on,modified_by,modified_on
from role where role_name = ?param0 and role_id != ?param1]
2018-03-15 10:55:08,882-Statement Id: [InsertRole] Prepared SQL: [insert into role
(role_name,status,created_by,created_on) values ( ?param0 , ?
param1 , ?param2 , NOW());]
2018-03-15 10:55:08,882-Statement Id: [InsertRole.SelectKey] Prepared SQL: [select
last_insert_id() as value]
2018-03-15 10:55:08,882-Statement Id: [UpdateRole] Prepared SQL: [update role set
role_name = ?param0 , status = ?param1 , modified_by = ?param2 ,
modified_on = NOW() where role_id = ?param3]
2018-03-15 10:55:08,882-Adding file [BOMHelper.xml] to list of watched files.
2018-03-15 10:55:08,882-Statement Id: [SelectBOMDictionary] Prepared SQL: [SELECT
DISTINCT sk.sku_code, bm.sku_id FROM sku sk INNER JOIN bom bm ON bm.sku_id =
sk.sku_id]
2018-03-15 10:55:08,882-Adding file [Matrix1Helper.xml] to list of watched files.
2018-03-15 10:55:08,889-Statement Id: [UpdateImportExportLog] PreparedStatement :
[update import_export_log set
reference_date = date_format( ?param0 , "%Y-%c-%e %H:%i:%s"), reference_type
= ?param1 , reference_title = ?param2 , type = ?param3 ,
log_file = ?param4 , status = ?param5 , status_text = ?param6 ,

comment = ?param7 where import_export_log_id = ?param8]

2018-03-15 10:55:08,891-Statement Id: [UpdateImportExportLog] Parameters: [


?param0=[reference_date,15/03/2018 10:55:08],
?param1=[reference_type,Node SKU Mapping],
?param2=[reference_title,TMPL_NodeSKU_Mapping1_2018_03_15_10_55_08.xlsx],
?param3=[type,Import],
?
param4=[log_file,Logs/NodeSkuMapping/NodeSkuMapping_Logfile_2018_03_15_10_55_08.txt
],
?param5=[status,-1],
?param6=[status_text,An error occurred during file processing.],
?param7=[comment,{message:'An error occurred during file processing.', error:' at
System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles
styles)

at System.Convert.ToDateTime(String value)
at SCMPLUS.Upload.<>c__DisplayClass9a.<UploadNodeSkuMapping>b__8c(DataRow drow)
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at SCMPLUS.Upload.UploadNodeSkuMapping(Object parameter)', details:'String was
not recognized as a valid DateTime.'}],
?param8=[import_export_log_id,207]]

2018-03-15 10:55:08,891-Statement Id: [UpdateImportExportLog] Types: [?


param0=[DateTime, System.DateTime], ?param1=[String, System.String], ?
param2=[String, System.String], ?param3=[String, System.String], ?param4=[String,
System.String], ?param5=[Int32, System.Int32], ?param6=[String, System.String], ?
param7=[String, System.String], ?param8=[Int64, System.Int64]]
2018-03-15 10:55:08,891-Open Connection "13002009" to "MySQL, MySQL provider ver
6:5:4:0".
2018-03-15 10:55:08,927-Close Connection "13002009" to "MySQL, MySQL provider ver
6:5:4:0".
2018-03-15 10:55:09,794-Adding file [SqlMap.config] to list of watched files.
2018-03-15 10:55:09,796-Add property "provider" value "MySql6"
2018-03-15 10:55:09,796-Add property "datasource" value "localhost"
2018-03-15 10:55:09,796-Add property "database" value "scmplus"
2018-03-15 10:55:09,796-Add property "port" value "3306"
2018-03-15 10:55:09,796-Add property "userid" value "root"
2018-03-15 10:55:09,796-Add property "password" value "root"
2018-03-15 10:55:09,796-Add property "mapperResources" value
"./bin/iBatis/SqlMapper/"
2018-03-15 10:55:09,799-Adding file [CategoryHelper.xml] to list of watched files.
2018-03-15 10:55:09,805-Statement Id: [SelectCategoryByCode] Prepared SQL: [select
category_id, category_code, category_name, parent_id, status, created_by,
created_on, modified_by, modified_on from category where category_code = ?
param0]
2018-03-15 10:55:09,806-Statement Id: [SelectCategoryForDuplicate] Prepared SQL:
[select category_id, category_code, category_name, parent_id, status, created_by,
created_on, modified_by, modified_on from category where category_code = ?
param0 and category_name = ?param1 and parent_id = ?param2]
2018-03-15 10:55:09,806-Statement Id: [SelectCategoryBy] Prepared SQL: [select
category_id, parent_id, category_name, category_code, status, created_by,
created_on, modified_by, modified_on from category where ?param0 = ?
param1]
2018-03-15 10:55:09,806-Statement Id: [InsertCategory] Prepared SQL: [insert into
category (category_code, category_name, parent_id, status, created_by,
created_on) values ( ?param0 , ?param1 , ?param2 , ?param3 , ?
param4 , NOW());]
2018-03-15 10:55:09,806-Statement Id: [InsertCategory.SelectKey] Prepared SQL:
[select last_insert_id() as value]
2018-03-15 10:55:09,806-Statement Id: [UpdateCategory] Prepared SQL: [update
category set category_name = ?param0 , parent_id = ?param1 ,
status = ?param2 , modified_by = ?param3 , modified_on = NOW()
where category_code = ?param4]
2018-03-15 10:55:09,806-Statement Id: [DeleteCategory] Prepared SQL: [delete from
category where category_id = ?param0]
2018-03-15 10:55:09,806-Adding file [NodeHelper.xml] to list of watched files.
2018-03-15 10:55:09,806-Statement Id: [MapNode] Prepared SQL: [select node_id,
node_code, node_name, address_line1, address_line2, status from node where node_id
= ?param0 union all select '' as node_id, '' as node_code, '' as
node_name, '' as address_line1, '' as address_line2, null as status limit 1]
2018-03-15 10:55:09,806-Statement Id: [SelectNodeByCode] Prepared SQL: [select
node_id, node_code, node_name, parent_id, location_id, address_line1,
address_line2, latitude, longitude, status, created_by, created_on,
modified_by, modified_on from node where node_code = ?param0]
2018-03-15 10:55:09,806-Statement Id: [SelectNodeForDuplicate] Prepared SQL:
[select node_id, node_code, node_name, parent_id, location_id, address_line1,
address_line2, latitude, longitude, status, created_by, created_on,
modified_by, modified_on from node where node_code = ?param0 and node_name
= ?param1 and parent_id = ?param2]
2018-03-15 10:55:09,806-Statement Id: [InsertNode] Prepared SQL: [insert into node
(node_code, node_name, parent_id, location_id, address_line1, address_line2,
latitude, longitude, status, created_by, created_on) values
( ?param0 , ?param1 , ?param2 , ?param3 , ?param4 , ?param5 , ?param6 , ?
param7 , ?param8 , ?param9 , NOW());]
2018-03-15 10:55:09,806-Statement Id: [InsertNode.SelectKey] Prepared SQL: [select
last_insert_id() as value]
2018-03-15 10:55:09,806-Statement Id: [UpdateNode] Prepared SQL: [update node set
node_name = ?param0 , parent_id = ?param1 , location_id = ?
param2 , address_line1 = ?param3 , address_line2 = ?param4 ,
latitude = ?param5 , longitude = ?param6 , status = ?param7 ,
modified_by = ?param8 , modified_on = NOW() where node_code = ?
param9]
2018-03-15 10:55:09,806-Statement Id: [DeleteNode] Prepared SQL: [delete from node
where node_id = ?param0]
2018-03-15 10:55:09,806-Adding file [AttributeHelper.xml] to list of watched files.
2018-03-15 10:55:09,811-Statement Id: [SelectAttributeByCode] Prepared SQL: [select
attribute_id, attribute_code, attribute_name, data_type, optional, status,
created_by, created_on, modified_by, modified_on from attribute where
attribute_code = ?param0]
2018-03-15 10:55:09,811-Statement Id: [InsertAttribute] Prepared SQL: [insert into
attribute (attribute_code, attribute_name, data_type, optional, status,
created_by, created_on) values ( ?param0 , ?param1 , ?param2 , ?
param3 , ?param4 , ?param5 , NOW());]
2018-03-15 10:55:09,811-Statement Id: [InsertAttribute.SelectKey] Prepared SQL:
[select last_insert_id() as value]
2018-03-15 10:55:09,811-Statement Id: [UpdateAttribute] Prepared SQL: [update
attribute set attribute_name = ?param0 , data_type = ?param1 ,
optional = ?param2 , status = ?param3 , modified_by = ?param4 ,
modified_on = NOW() where attribute_id = ?param5]
2018-03-15 10:55:09,811-Statement Id: [DeleteAttribute] Prepared SQL: [delete from
attribute where attribute_id = ?param0]
2018-03-15 10:55:09,811-Adding file [SKUHelper.xml] to list of watched files.
2018-03-15 10:55:09,812-Statement Id: [MapSKU] Prepared SQL: [select * from sku
where sku_id = ?param0]
2018-03-15 10:55:09,813-Statement Id: [SelectSKUByCode] Prepared SQL: [select
sku_id, sku_code, sku_name, sku_description, status, created_by, created_on,
modified_by, modified_on from sku where sku_code = ?param0]
2018-03-15 10:55:09,813-Statement Id: [SelectSKUForDuplicate] Prepared SQL: [select
sku_id, sku_code, sku_name, sku_description, status, created_by, created_on,
modified_by, modified_on from sku where sku_code = ?param0 and sku_name =
?param1 and sku_description = ?param2]
2018-03-15 10:55:09,813-Statement Id: [SelectBatchInsertedSKU] Prepared SQL:
[select sku_id, sku_code, sku_name, sku_description, status, created_by,
created_on, modified_by, modified_on from sku where sku_id >= (SELECT
(AUTO_INCREMENT - ?param0 ) FROM information_schema.`TABLES` WHERE TABLE_NAME =
'sku' LIMIT 1)]
2018-03-15 10:55:09,813-Statement Id: [InsertSKU] Prepared SQL: [insert into sku
(sku_code, sku_name, sku_description, status, created_by, created_on) values
( ?param0 , ?param1 , ?param2 , ?param3 , ?param4 , NOW());]
2018-03-15 10:55:09,813-Statement Id: [InsertSKU.SelectKey] Prepared SQL: [select
last_insert_id() as value]
2018-03-15 10:55:09,813-Statement Id: [UpdateSKU] Prepared SQL: [update sku set
sku_name = ?param0 , sku_description = ?param1 , status = ?
param2 , modified_by = ?param3 , modified_on = NOW() where
sku_id = ?param4]
2018-03-15 10:55:09,813-Statement Id: [DeleteSKU] Prepared SQL: [delete from sku
where sku_id = ?param0]
2018-03-15 10:55:09,813-Adding file [SKUAttributeHelper.xml] to list of watched
files.
2018-03-15 10:55:09,813-Statement Id: [SelectSKUAttributeMappingBySKUAttribute]
Prepared SQL: [select sku_attribute_mapping_id, sku_id, attribute_id, value,
created_by, created_on from sku_attribute_mapping where sku_id = ?param0
and attribute_id = ?param1]
2018-03-15 10:55:09,813-Statement Id: [SelectSKUAttributeMappingBySKU] Prepared
SQL: [select sku_attribute_mapping_id, sku_id, attribute_id, value, created_by,
created_on from sku_attribute_mapping where sku_id = ?param0]
2018-03-15 10:55:09,813-Statement Id: [InsertSKUAttributeMapping] Prepared SQL:
[insert into sku_attribute_mapping (sku_id, attribute_id, value, created_by,
created_on) values ( ?param0 , ?param1 , ?param2 , ?param3 ,
NOW());]
2018-03-15 10:55:09,813-Statement Id: [InsertSKUAttributeMapping.SelectKey]
Prepared SQL: [select last_insert_id() as value]
2018-03-15 10:55:09,813-Statement Id: [UpdateSKUAttributeMapping] Prepared SQL:
[update sku_attribute_mapping set value = ?param0 , where
sku_attribute_mapping_id = ?param1]
2018-03-15 10:55:09,813-Statement Id: [DeleteSKUAttributeMapping] Prepared SQL:
[delete from sku_attribute_mapping where sku_id = ?param0 and attribute_id
= ?param1]
2018-03-15 10:55:09,813-Adding file [NodeSKUHelper.xml] to list of watched files.
2018-03-15 10:55:09,819-Statement Id: [SelectNodeSKUMappingByNodeSKU] Prepared SQL:
[select node_sku_mapping_id, receiver_node_id, sku_id, supplier_node_id,
effective_date, created_by, created_on from node_sku_mapping where sku_id =
?param0 and receiver_node_id = ?param1 and supplier_node_id = ?param2 and
effective_date = ?param3]
2018-03-15 10:55:09,819-Statement Id: [selectSKU] Prepared SQL: [select * from sku
where sku_id = ?param0]
2018-03-15 10:55:09,819-Statement Id: [selectNode] Prepared SQL: [select * from
node where node_id = ?param0]
2018-03-15 10:55:09,819-Statement Id: [InsertNodeSKUMapping] Prepared SQL: [insert
into node_sku_mapping (receiver_node_id, sku_id, supplier_node_id,
effective_date, created_by, created_on) values ( ?param0 , ?param1 ,
?param2 , date_format( ?param3 , "%Y-%c-%e %H:%i:%s"), ?param4 , NOW());]
2018-03-15 10:55:09,820-Statement Id: [InsertNodeSKUMapping.SelectKey] Prepared
SQL: [select last_insert_id() as value]
2018-03-15 10:55:09,820-Statement Id: [DeleteNodeSKUMapping] Prepared SQL: [delete
from node_sku_mapping where node_sku_mapping_id = ?param0]
2018-03-15 10:55:09,820-Adding file [BufferNormHelper.xml] to list of watched
files.
2018-03-15 10:55:09,823-Statement Id: [MapBufferNorm] Prepared SQL: [select
buffer_norm_id, sku_id, node_id, buffer_norm, olt, plt, tlt, rlt,
max_sales_per_day, safety_factor, unit_selling_price, unit_purchase_price,
moq, eoq, effective_from, created_by, created_on, modified_by, modified_on
from buffer_norm where buffer_norm_id = ?param0 union all select '' as
buffer_norm_id, '' as sku_id, '' as node_id, 0 as buffer_norm, 0 as olt, 0 as plt,
0 as tlt, 0 as rlt, 0 as max_sales_per_day, 0 as safety_factor, 0 as
unit_selling_price, 0 as unit_purchase_price, 0 as moq, 0 as eoq, '' as
effective_from, null as created_by, null as created_on, null as modified_by, null
as modified_on limit 1]
2018-03-15 10:55:09,823-Statement Id: [SelectBufferNormBySKUNode] Prepared SQL:
[select buffer_norm_id, sku_id, node_id, buffer_norm, olt, plt, tlt, rlt,
max_sales_per_day, safety_factor, unit_selling_price, unit_purchase_price,
moq, eoq, effective_from, created_by, created_on, modified_by,
modified_on,IFNULL(is_default_zone,'Y') AS is_default_zone, IFNULL(red_zone,0) AS
red_zone, IFNULL(yellow_zone,0) AS yellow_zone from buffer_norm where sku_id
= ?param0 and node_id = ?param1 and effective_from = ?param2]
2018-03-15 10:55:09,824-Statement Id: [SelectBatchInsertedBufferNorm] Prepared SQL:
[select b.buffer_norm_id, b.sku_id, b.node_id, b.buffer_norm, b.olt, b.plt, b.tlt,
b.rlt, b.max_sales_per_day, b.safety_factor, b.unit_selling_price,
b.unit_purchase_price, b.moq, b.eoq, b.effective_from, b.created_by, b.created_on,
b.modified_by, b.modified_on, b.identifier, b.is_default_zone, b.red_zone,
b.yellow_zone from buffer_norm b where identifier = ?param0]
2018-03-15 10:55:09,827-Statement Id: [InsertBufferNorm] Prepared SQL: [insert into
buffer_norm (sku_id, node_id, buffer_norm, olt, plt, tlt, rlt,
max_sales_per_day, safety_factor, unit_selling_price, unit_purchase_price,
moq, eoq, effective_from, created_by, created_on) values ( ?param0 ,
?param1 , ?param2 , ?param3 , ?param4 , ?param5 , ?param6 , ?param7 , ?
param8 , ?param9 , ?param10 , ?param11 , ?param12 , date_format( ?
param13 , "%Y-%c-%e %H:%i:%s"), ?param14 , NOW());]
2018-03-15 10:55:09,827-Statement Id: [InsertBufferNorm.SelectKey] Prepared SQL:
[select last_insert_id() as value]
2018-03-15 10:55:09,828-Statement Id: [UpdateBufferNorm] Prepared SQL: [update
buffer_norm set sku_id = ?param0 , node_id = ?param1 ,
buffer_norm = ?param2 , olt = ?param3 , plt = ?param4 , tlt
= ?param5 , rlt = ?param6 , max_sales_per_day = ?param7 ,
safety_factor = ?param8 , unit_selling_price = ?param9 ,
unit_purchase_price = ?param10 , moq = ?param11 , eoq = ?param12 ,
effective_from = date_format( ?param13 , "%Y-%c-%e %H:%i:%s"), modified_by =
?param14 , modified_on = NOW() where buffer_norm_id = ?param15]
2018-03-15 10:55:09,828-Statement Id: [DeleteBufferNorm] Prepared SQL: [delete from
buffer_norm where buffer_norm_id = ?param0]
2018-03-15 10:55:09,828-Adding file [TransactionHelper.xml] to list of watched
files.
2018-03-15 10:55:09,833-Statement Id: [SelectTransactionForDuplicate] Prepared SQL:
[select transaction_id, sku_id, node_id, supply_node_id, transaction_date, grn,
sales, closing_quantity, in_transit, inst_hold, quality_hold, qa_hold,
pending_orders, orders_in_hand, transport_mode, db_sync, mongo_sync, created_by,
created_on, open_stock_transfer_order, open_planned_order,
open_purchase_request, open_production_order, open_purchase_order, field1, field2,
field3, field4, field5, field6, field7, field8, field9, field10 from
transaction where sku_id = ?param0 and node_id = ?param1 and transaction_date =
?param2]
2018-03-15 10:55:09,834-Statement Id: [SelectReplenishmentList] Prepared SQL:
[select tr.transaction_id, tr.transaction_date,
date_format(tr.transaction_date,'%d/%m/%Y') as display_date,
date_format(tr.transaction_date,'%Y%m%d') as transfilter_date, tr.sku_id,
s.sku_code, s.sku_name, tr.node_id, n.node_code, n.node_name, sc.category_id,
cat.category_code, cat.category_name, ifnull(bn.buffer_norm, 0) as
buffer_norm, ifnull(tr.closing_quantity, 0) as closing_quantity,
ifnull(tr.in_transit, 0) as in_transit, ifnull(tr.sales, 0) as sales,
ifnull(tr.inst_hold, 0) as inst_hold, ifnull(tr.quality_hold, 0) as quality_hold,
ifnull(tr.qa_hold, 0) as qa_hold, ifnull(tr.pending_orders, 0) as
pending_orders, ifnull(tr.orders_in_hand, 0) as orders_in_hand,
ifnull(tr.transport_mode, '') as transport_mode, nsm.supplier_node_id as
supply_node_id, sn.node_name as supply_node_name, sn.node_code as
supply_node_code, ifnull(str.closing_quantity, 0) as supplying_quantity,
ifnull(sbn.buffer_norm, 0) as supplying_buffer_norm,
round(ifnull(bn.buffer_norm, 0),2) as 'green_zone_qty', CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2)
END AS 'yellow_zone_qty', CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END as 'red_zone_qty', case
when ifnull(bn.buffer_norm, 0) = 0 then 'White' when
(ifnull(tr.closing_quantity, 0) <= 0 and ifnull(bn.buffer_norm, 0) > 0) then
'Black' when (ifnull(tr.closing_quantity, 0) > ifnull(bn.buffer_norm, 0) and
ifnull(bn.buffer_norm, 0) > 0) then 'Blue' when (ifnull(tr.closing_quantity,
0) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) and ifnull(tr.closing_quantity,
0) <= ifnull(bn.buffer_norm, 0) and ifnull(bn.buffer_norm, 0) > 0) then 'Green'
when (ifnull(tr.closing_quantity, 0) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) and ifnull(tr.closing_quantity, 0) <=
(CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) and ifnull(bn.buffer_norm, 0) >
0) then 'Yellow' when (ifnull(tr.closing_quantity, 0) > 0 and
ifnull(tr.closing_quantity, 0) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) and ifnull(bn.buffer_norm, 0) > 0) then
'Red' end as 'closing_stock_zone', case when
ifnull(bn.buffer_norm, 0) = 0 then 6 when (ifnull(tr.closing_quantity, 0) <=
0 and ifnull(bn.buffer_norm, 0) > 0) then 1 when
(ifnull(tr.closing_quantity, 0) > ifnull(bn.buffer_norm, 0) and
ifnull(bn.buffer_norm, 0) > 0) then 2 when (ifnull(tr.closing_quantity, 0) >
(CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) and ifnull(tr.closing_quantity,
0) <= ifnull(bn.buffer_norm, 0) and ifnull(bn.buffer_norm, 0) > 0) then 4
when (ifnull(tr.closing_quantity, 0) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) and ifnull(tr.closing_quantity, 0) <=
(CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) and ifnull(bn.buffer_norm, 0) >
0) then 3 when (ifnull(tr.closing_quantity, 0) > 0 and
ifnull(tr.closing_quantity, 0) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) and ifnull(bn.buffer_norm, 0) > 0) then
5 end as 'closing_stock_zone_sort', case when
ifnull(bn.buffer_norm, 0) = 0 then 'White' when
((ifnull(tr.closing_quantity, 0) + ifnull(tr.in_transit, 0) -
ifnull(tr.pending_orders, 0)) <= 0 and ifnull(bn.buffer_norm, 0) > 0) then 'Black'
when ((ifnull(tr.closing_quantity, 0) + ifnull(tr.in_transit, 0) -
ifnull(tr.pending_orders, 0)) > ifnull(bn.buffer_norm, 0) and
ifnull(bn.buffer_norm, 0) > 0) then 'Blue' when
((ifnull(tr.closing_quantity, 0) + ifnull(tr.in_transit, 0) -
ifnull(tr.pending_orders, 0)) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) and
(ifnull(tr.closing_quantity, 0) + tr.in_transit - tr.pending_orders) <=
ifnull(bn.buffer_norm, 0) and ifnull(bn.buffer_norm, 0) > 0) then 'Green'
when ((ifnull(tr.closing_quantity, 0) + ifnull(tr.in_transit, 0) -
ifnull(tr.pending_orders, 0)) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) and (tr.closing_quantity +
tr.in_transit - tr.pending_orders) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2)
ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) and ifnull(bn.buffer_norm,
0) > 0) then 'Yellow' when ((ifnull(tr.closing_quantity, 0) +
ifnull(tr.in_transit, 0) - ifnull(tr.pending_orders, 0)) > 0 and
(ifnull(tr.closing_quantity, 0) + tr.in_transit - tr.pending_orders) <= (CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) and
ifnull(bn.buffer_norm, 0) > 0) then 'Red' end as 'in_transit_zone',
case when ifnull(bn.buffer_norm, 0) = 0 then 6 when
((ifnull(tr.closing_quantity, 0) + ifnull(tr.in_transit, 0) -
ifnull(tr.pending_orders, 0)) <= 0 and ifnull(bn.buffer_norm, 0) > 0) then 1
when ((ifnull(tr.closing_quantity, 0) + ifnull(tr.in_transit, 0) -
ifnull(tr.pending_orders, 0)) > ifnull(bn.buffer_norm, 0) and
ifnull(bn.buffer_norm, 0) > 0) then 2 when ((ifnull(tr.closing_quantity, 0)
+ ifnull(tr.in_transit, 0) - ifnull(tr.pending_orders, 0)) > (CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2)
END) and (ifnull(tr.closing_quantity, 0) + tr.in_transit - tr.pending_orders) <=
ifnull(bn.buffer_norm, 0) and ifnull(bn.buffer_norm, 0) > 0) then 4 when
((ifnull(tr.closing_quantity, 0) + ifnull(tr.in_transit, 0) -
ifnull(tr.pending_orders, 0)) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) and (ifnull(tr.closing_quantity, 0) +
tr.in_transit - tr.pending_orders) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2)
ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) and ifnull(bn.buffer_norm,
0) > 0) then 3 when ((ifnull(tr.closing_quantity, 0) + ifnull(tr.in_transit,
0) - ifnull(tr.pending_orders, 0)) > 0 and (ifnull(tr.closing_quantity, 0) +
tr.in_transit - tr.pending_orders) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) and ifnull(bn.buffer_norm, 0) > 0) then
5 end as 'in_transit_zone_sort', case when
ifnull(sbn.buffer_norm, 0) = 0 then 'White' when
(ifnull(str.closing_quantity, 0) <= 0 and ifnull(sbn.buffer_norm, 0) > 0) then
'Black' when (ifnull(str.closing_quantity, 0) > ifnull(sbn.buffer_norm, 0)
and ifnull(sbn.buffer_norm, 0) > 0) then 'Blue' when
(ifnull(str.closing_quantity, 0) > (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) and
ifnull(str.closing_quantity, 0) <= ifnull(sbn.buffer_norm, 0) and
ifnull(sbn.buffer_norm, 0) > 0) then 'Green' when
(ifnull(str.closing_quantity, 0) > (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) and ifnull(str.closing_quantity, 0) <=
(CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) and ifnull(sbn.buffer_norm, 0)
> 0) then 'Yellow' when (ifnull(str.closing_quantity, 0) > 0 and
ifnull(str.closing_quantity, 0) <= (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) and ifnull(sbn.buffer_norm, 0) > 0)
then 'Red' end as 'supplying_node_zone', case when
ifnull(sbn.buffer_norm, 0) = 0 then 6 when (ifnull(str.closing_quantity, 0)
<= 0 and ifnull(sbn.buffer_norm, 0) > 0) then 1 when
(ifnull(str.closing_quantity, 0) > ifnull(sbn.buffer_norm, 0) and
ifnull(sbn.buffer_norm, 0) > 0) then 2 when (ifnull(str.closing_quantity,
0) > (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) and
ifnull(str.closing_quantity, 0) <= ifnull(sbn.buffer_norm, 0) and
ifnull(sbn.buffer_norm, 0) > 0) then 4 when (ifnull(str.closing_quantity, 0)
> (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) and ifnull(str.closing_quantity, 0) <=
(CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) and ifnull(sbn.buffer_norm, 0)
> 0) then 3 when (ifnull(str.closing_quantity, 0) > 0 and
ifnull(str.closing_quantity, 0) <= (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) and ifnull(sbn.buffer_norm, 0) > 0)
then 5 end as 'supplying_node_zone_sort', case when
((ifnull(bn.buffer_norm, 0) - ifnull(tr.closing_quantity, 0) -
ifnull(tr.in_transit, 0)) + ifnull(tr.pending_orders, 0)) -
(ifnull(tr.open_planned_order, 0) + ifnull(tr.open_purchase_request, 0) +
ifnull(tr.open_production_order, 0) + ifnull(tr.open_purchase_order, 0)) <= 0 then
0 else ((ifnull(bn.buffer_norm, 0) - ifnull(tr.closing_quantity, 0) -
ifnull(tr.in_transit, 0)) + ifnull(tr.pending_orders, 0)) -
(ifnull(tr.open_planned_order, 0) + ifnull(tr.open_purchase_request, 0) +
ifnull(tr.open_production_order, 0) + ifnull(tr.open_purchase_order, 0)) end
as 'replenishment_quantity', case when (ifnull(tr.closing_quantity,
0) + ifnull(tr.in_transit, 0) + ifnull(tr.open_planned_order, 0) +
ifnull(tr.open_purchase_request, 0) + ifnull(tr.open_production_order, 0) +
ifnull(tr.open_purchase_order, 0) ) - ifnull(tr.pending_orders, 0) <= 0 then 0
else (ifnull(tr.closing_quantity, 0) + ifnull(tr.in_transit, 0) +
ifnull(tr.open_planned_order, 0) + ifnull(tr.open_purchase_request, 0) +
ifnull(tr.open_production_order, 0) + ifnull(tr.open_purchase_order, 0) ) -
ifnull(tr.pending_orders, 0) end as 'final_quantity', case
when ifnull(bn.buffer_norm, 0) = 0 then 0 else (CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END)
end as 'mrq', (select count(1) from transaction_comment where
transaction_id = tr.transaction_id) as 'transaction_comment',
ifnull(tr.open_stock_transfer_order, 0) as open_stock_transfer_order,
ifnull(tr.open_planned_order, 0) as open_planned_order,
ifnull(tr.open_purchase_request, 0) as open_purchase_request,
ifnull(tr.open_production_order, 0) as open_production_order,
ifnull(tr.open_purchase_order, 0) as open_purchase_order, tr.field1,
tr.field2, tr.field3, tr.field4, tr.field5, tr.field6, tr.field7, tr.field8,
tr.field9, tr.field10 from ( select transaction_id from
transaction where transaction_date = ?param0 limit ?param1 , ?
param2 ) otr join transaction tr on tr.transaction_id
= otr.transaction_id left join buffer_norm bn on bn.sku_id =
tr.sku_id and bn.node_id = tr.node_id and bn.effective_from = (
select max(effective_from) from buffer_norm where effective_from <=
tr.transaction_date and sku_id = tr.sku_id and node_id = tr.node_id)
left join sku s on s.sku_id = tr.sku_id left join sku_category sc
on sc.sku_id = tr.sku_id left join category cat on cat.category_id
= sc.category_id left join node n on n.node_id = tr.node_id
left join node_sku_mapping nsm on nsm.receiver_node_id = tr.node_id
and nsm.sku_id = tr.sku_id and nsm.effective_date = ( select
max(effective_date) from node_sku_mapping where effective_date <=
tr.transaction_date and sku_id = tr.sku_id and receiver_node_id =
tr.node_id) left join node sn on sn.node_id = nsm.supplier_node_id
left join buffer_norm sbn on sbn.sku_id = nsm.sku_id and sbn.node_id
= nsm.supplier_node_id and sbn.effective_from = ( select
max(effective_from) from buffer_norm where effective_from <=
tr.transaction_date and sku_id = tr.sku_id and node_id = tr.node_id)
left join ( select transaction_id, sku_id, node_id, closing_quantity
from transaction where transaction_date = ?param0 ) str
on str.sku_id = nsm.sku_id and str.node_id = nsm.supplier_node_id and
str.transaction_id = otr.transaction_id order by tr.transaction_id]
2018-03-15 10:55:09,834-Statement Id: [MapTransaction] Prepared SQL: [select * from
transaction where transaction_id = ?param0]
2018-03-15 10:55:09,834-Statement Id: [SelectMaxTransactionDate] Prepared SQL:
[select date_sub(max(transaction_date), interval 15 day) as avg_date,
max(transaction_date) as transaction_date from transaction]
2018-03-15 10:55:09,834-Statement Id: [SelectSKUNodeGroup] Prepared SQL: [select
sku_id, node_id from transaction group by sku_id, node_id]
2018-03-15 10:55:09,834-Statement Id: [SelectTransactionBySKUNode] Prepared SQL:
[select transaction_id, sku_id, node_id, supply_node_id, transaction_date, grn,
sales, closing_quantity, in_transit, inst_hold, quality_hold, qa_hold,
pending_orders, orders_in_hand, transport_mode, db_sync, mongo_sync, created_by,
created_on, open_stock_transfer_order, open_planned_order,
open_purchase_request, open_production_order, open_purchase_order, field1, field2,
field3, field4, field5, field6, field7, field8, field9, field10 from
transaction where sku_id = ?param0 and node_id = ?param1]
2018-03-15 10:55:09,834-Statement Id: [SelectTransactionByDate] Prepared SQL:
[select transaction_id, sku_id, node_id, supply_node_id, transaction_date, grn,
sales, closing_quantity, in_transit, inst_hold, quality_hold, qa_hold,
pending_orders, orders_in_hand, transport_mode, db_sync, mongo_sync, created_by,
created_on, open_stock_transfer_order, open_planned_order,
open_purchase_request, open_production_order, open_purchase_order, field1, field2,
field3, field4, field5, field6, field7, field8, field9, field10 from
transaction where transaction_date = ?param0]
2018-03-15 10:55:09,835-Statement Id: [SelectTransactionDates] Prepared SQL:
[select DATE_FORMAT(transaction_date, '%Y-%m-%d %H:%i:%s') as transaction_date from
transaction group by transaction_date asc limit ?param0]
2018-03-15 10:55:09,836-Statement Id: [SelectBNCalculationTransactionDates]
Prepared SQL: [select DATE_FORMAT(transaction_date, '%Y-%m-%d %H:%i:%s') as
transaction_date from transaction where transaction_date >= ?param0
group by transaction_date asc]
2018-03-15 10:55:09,836-Statement Id: [SelectTransactionIdsForBNCalculation]
Prepared SQL: [select transaction_id from transaction where transaction_date
= ?param0 and sku_id = ?param1 and node_id = ?param2]
2018-03-15 10:55:09,836-Statement Id: [SelectBatchInsertedTransactionID] Prepared
SQL: [select transaction_id, identifier from transaction where identifier = ?
param0]
2018-03-15 10:55:09,836-Statement Id: [SelectUpdateTransactionImport] Prepared SQL:
[select DISTINCT transaction_id from update_transaction WHERE identifier = ?
param0]
2018-03-15 10:55:09,840-Statement Id: [SelectClosingStockForTransactionDate]
Prepared SQL: [SELECT transaction_date, closing_quantity, sales, grn from
transaction WHERE transaction_date < ?param0 AND sku_id = ?param1
AND node_id = ?param2 ORDER BY transaction_date DESC LIMIT 1]
2018-03-15 10:55:09,841-Statement Id: [InsertTransaction] Prepared SQL: [insert
into transaction (sku_id, node_id, supply_node_id, transaction_date, grn,
sales, closing_quantity, in_transit, inst_hold, quality_hold, qa_hold,
pending_orders, orders_in_hand, transport_mode, db_sync, mongo_sync, created_by,
created_on, open_stock_transfer_order, open_planned_order,
open_purchase_request, open_production_order, open_purchase_order, field1, field2,
field3, field4, field5, field6, field7, field8, field9, field10) values
( ?param0 , ?param1 , ?param2 , ?param3 , ?param4 , ?param5 , ?param6 , ?
param7 , ?param8 , ?param9 , ?param10 , ?param11 , ?param12 , ?param13
, 0, 0, ?param14 , NOW(), ?param15 , ?param16 , ?param17 , ?
param18 , ?param19 , ?param20 , ?param21 , ?param22 , ?param23 , ?param24 ,
?param25 , ?param26 , ?param27 , ?param28 , ?param29 );]
2018-03-15 10:55:09,841-Statement Id: [InsertTransaction.SelectKey] Prepared SQL:
[select last_insert_id() as value]
2018-03-15 10:55:09,841-Statement Id: [InsertTransactionComment] Prepared SQL:
[insert into transaction_comment (transaction_id, sku_id, node_id, comment,
reason, created_by, created_on) values ( ?param0 , ?param1 , ?
param2 , ?param3 , ?param4 , ?param5 , NOW());]
2018-03-15 10:55:09,841-Statement Id: [InsertTransactionComment.SelectKey] Prepared
SQL: [select last_insert_id() as value]
2018-03-15 10:55:09,841-Statement Id: [UpdateTransaction] Prepared SQL: [update
transaction set sku_id = ?param0 , node_id = ?param1 ,
supply_node_id = ?param2 , transaction_date = ?param3 , grn = ?
param4 , sales = ?param5 , closing_quantity = ?param6 ,
in_transit = ?param7 , inst_hold = ?param8 , quality_hold = ?
param9 , qa_hold = ?param10 , pending_orders = ?param11 ,
orders_in_hand = ?param12 , transport_mode = ?param13 , db_sync
= ?param14 , mongo_sync = ?param15 where transaction_id = ?
param16]
2018-03-15 10:55:09,841-Statement Id: [DeleteUpdatesTransaction] Prepared SQL:
[delete from update_transaction WHERE identifier = ?param0]
2018-03-15 10:55:09,842-Adding file [SKUCategoryHelper.xml] to list of watched
files.
2018-03-15 10:55:09,842-Statement Id: [SelectSKUCategoryBySKUCategory] Prepared
SQL: [select sku_category_id, sku_id, category_id, created_by, created_on
from sku_category where sku_id = ?param0 and category_id = ?param1]
2018-03-15 10:55:09,842-Statement Id: [InsertSKUCategory] Prepared SQL: [insert
into sku_category (sku_id, category_id, created_by, created_on)
values ( ?param0 , ?param1 , ?param2 , NOW());]
2018-03-15 10:55:09,842-Statement Id: [InsertSKUCategory.SelectKey] Prepared SQL:
[select last_insert_id() as value]
2018-03-15 10:55:09,843-Adding file [SKUChartHelper.xml] to list of watched files.
2018-03-15 10:55:09,843-Statement Id: [SelectSKUChart] Prepared SQL: [select
rpl.transaction_date, date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date,
sum(rpl.closing_quantity) as closing_quantity, sum(rpl.red_zone_qty) as
red_zone_qty, sum(rpl.yellow_zone_qty) as yellow_zone_qty,
sum(rpl.green_zone_qty) as green_zone_qty, sum(rpl.in_transit) as in_transit,
sum(rpl.sales) as sales, count(distinct(rpl.sku_id)) as total_sku_count,
(select count(distinct(sku_id)) from replenishment where closing_stock_zone_sort =
2 and transaction_date = rpl.transaction_date) as blue_sku_count, (select
count(distinct(sku_id)) from replenishment where (closing_stock_zone_sort = 1 or
closing_stock_zone_sort = 5) and transaction_date = rpl.transaction_date) as
rb_sku_count from replenishment rpl where rpl.transaction_date = ?
param0 group by rpl.transaction_date]
2018-03-15 10:55:09,843-Statement Id: [SelectSKUChartNode] Prepared SQL: [select
rpl.transaction_date, date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date, rpl.node_id,
sum(rpl.closing_quantity) as closing_quantity, sum(rpl.red_zone_qty) as
red_zone_qty, sum(rpl.yellow_zone_qty) as yellow_zone_qty,
sum(rpl.green_zone_qty) as green_zone_qty, sum(rpl.in_transit) as in_transit,
sum(rpl.sales) as sales, count(distinct(rpl.sku_id)) as total_sku_count,
ifnull((select count(distinct(sku_id)) from replenishment where
closing_stock_zone_sort = 2 and transaction_date = rpl.transaction_date and node_id
= rpl.node_id), 0) as blue_sku_count, ifnull((select count(distinct(sku_id))
from replenishment where (closing_stock_zone_sort = 1 or closing_stock_zone_sort =
5) and transaction_date = rpl.transaction_date and node_id = rpl.node_id), 0) as
rb_sku_count from replenishment rpl where rpl.transaction_date = ?
param0 group by rpl.transaction_date, rpl.node_id]
2018-03-15 10:55:09,843-Statement Id: [SelectSKUChartCategory] Prepared SQL:
[select rpl.transaction_date, date_format(rpl.transaction_date,'%d/%m/%Y') as
display_date, date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date,
rpl.category_id, sum(rpl.closing_quantity) as closing_quantity,
sum(rpl.red_zone_qty) as red_zone_qty, sum(rpl.yellow_zone_qty) as yellow_zone_qty,
sum(rpl.green_zone_qty) as green_zone_qty, sum(rpl.in_transit) as in_transit,
sum(rpl.sales) as sales, count(distinct(rpl.sku_id)) as total_sku_count,
ifnull((select count(distinct(sku_id)) from replenishment where
closing_stock_zone_sort = 2 and transaction_date = rpl.transaction_date and
category_id = rpl.category_id), 0) as blue_sku_count, ifnull((select
count(distinct(sku_id)) from replenishment where (closing_stock_zone_sort = 1 or
closing_stock_zone_sort = 5) and transaction_date = rpl.transaction_date and
category_id = rpl.category_id), 0) as rb_sku_count from replenishment rpl
where rpl.transaction_date = ?param0 and rpl.category_id is not null
group by rpl.transaction_date, rpl.category_id]
2018-03-15 10:55:09,843-Statement Id: [SelectSKUChartSKU] Prepared SQL: [select
rpl.transaction_date, date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date, rpl.sku_id,
sum(rpl.closing_quantity) as closing_quantity, sum(rpl.red_zone_qty) as
red_zone_qty, sum(rpl.yellow_zone_qty) as yellow_zone_qty,
sum(rpl.green_zone_qty) as green_zone_qty, sum(rpl.in_transit) as in_transit,
sum(rpl.sales) as sales, count(distinct(rpl.sku_id)) as total_sku_count,
ifnull((select count(distinct(sku_id)) from replenishment where
closing_stock_zone_sort = 2 and transaction_date = rpl.transaction_date and sku_id
= rpl.sku_id), 0) as blue_sku_count, ifnull((select count(distinct(sku_id))
from replenishment where (closing_stock_zone_sort = 1 or closing_stock_zone_sort =
5) and transaction_date = rpl.transaction_date and sku_id = rpl.sku_id), 0) as
rb_sku_count from replenishment rpl use index(inx_sku_chart_s) where
rpl.transaction_date = ?param0 group by rpl.transaction_date, rpl.sku_id]
2018-03-15 10:55:09,844-Adding file [ImportExportLogHelper.xml] to list of watched
files.
2018-03-15 10:55:09,844-Statement Id: [SelectImportExportLogByType] Prepared SQL:
[select import_export_log_id, reference_date, reference_type, reference_title,
type, log_file, status, status_text, comment, created_by, created_on from
import_export_log where type = ?param0 order by reference_date desc]
2018-03-15 10:55:09,845-Statement Id: [InsertImportExportLog] Prepared SQL: [insert
into import_export_log (reference_date, reference_type, reference_title,
type, log_file, status, status_text, comment, created_by, created_on) values
(date_format( ?param0 , "%Y-%c-%e %H:%i:%s"), ?param1 , ?param2 , ?param3 , ?
param4 , ?param5 , ?param6 , ?param7 , ?param8 , NOW() );]
2018-03-15 10:55:09,845-Statement Id: [InsertImportExportLog.SelectKey] Prepared
SQL: [select last_insert_id() as value]
2018-03-15 10:55:09,845-Statement Id: [UpdateImportExportLog] Prepared SQL: [update
import_export_log set reference_date = date_format( ?param0 , "%Y-%c-%e %H:
%i:%s"), reference_type = ?param1 , reference_title = ?param2 ,
type = ?param3 , log_file = ?param4 , status = ?param5 ,
status_text = ?param6 , comment = ?param7 where
import_export_log_id = ?param8]
2018-03-15 10:55:09,845-Statement Id: [DeleteImportExportLog] Prepared SQL: [delete
from import_export_log where import_export_log_id = ?param0]
2018-03-15 10:55:09,845-Adding file [DynamicBufferManagementHelper.xml] to list of
watched files.
2018-03-15 10:55:09,846-Statement Id: [InsertDynamicBufferManagement] Prepared SQL:
[insert into dynamic_buffer_management (activate_auto_dbm,
excess_inv_occ_count, excess_inv_decrease_per, excess_inv_wait_cycle,
stockout_inv_occ_count, stockout_inv_decrease_per, stockout_inv_wait_cycle,
override_sku_location_dbm, activate_auto_dcm, red_percentage,
yellow_percentage, green_percentage, created_by, created_on) values (
?param0 , ?param1 , ?param2 , ?param3 , ?param4 , ?param5 , ?param6 ,
?param7 , ?param8 , ?param9 , ?param10 , ?param11 , ?param12 , NOW());]
2018-03-15 10:55:09,846-Statement Id: [InsertDynamicBufferManagement.SelectKey]
Prepared SQL: [select last_insert_id() as value]
2018-03-15 10:55:09,847-Statement Id: [UpdateDynamicBufferManagement] Prepared SQL:
[update dynamic_buffer_management set activate_auto_dbm = ?param0 ,
excess_inv_occ_count = ?param1 , excess_inv_decrease_per = ?param2 ,
excess_inv_wait_cycle = ?param3 , stockout_inv_occ_count = ?param4 ,
stockout_inv_decrease_per = ?param5 , stockout_inv_wait_cycle = ?param6 ,
override_sku_location_dbm = ?param7 , activate_auto_dcm = ?param8 ,
red_percentage = ?param9 , yellow_percentage = ?param10 ,
green_percentage = ?param11 , modified_by = ?param12 , modified_on
= NOW() where dynamic_buffer_management_id = ?param13]
2018-03-15 10:55:09,847-Adding file [ReplenishmentHelper.xml] to list of watched
files.
2018-03-15 10:55:09,850-Statement Id: [SelectReplenishmentData] Prepared SQL:
[select transaction_id, transaction_date, display_date, transfilter_date, sku_id,
sku_code, sku_name, node_id, node_code, node_name, category_id,
category_code, category_name, buffer_norm, grn, closing_quantity, in_transit,
sales, inst_hold, quality_hold, qa_hold, pending_orders, orders_in_hand,
transport_mode, supply_node_id, supply_node_name, supply_node_code,
supplying_quantity, supplying_buffer_norm, green_zone_qty, yellow_zone_qty,
red_zone_qty, closing_stock_zone, closing_stock_zone_sort, in_transit_zone,
in_transit_zone_sort, supplying_node_zone, supplying_node_zone_sort,
replenishment_quantity, final_quantity, mrq, transaction_comment,
open_stock_transfer_order, open_planned_order, open_purchase_request,
open_production_order, open_purchase_order, field1, field2, field3, field4,
field5, field6, field7, field8, field9, field10, mtd_sales, mtd_grn from
replenishment where transaction_date = ?param0]
2018-03-15 10:55:09,851-Statement Id: [SelectReplenishmentBySKUNode] Prepared SQL:
[select transaction_id, transaction_date, display_date, transfilter_date, sku_id,
sku_code, sku_name, node_id, node_code, node_name, category_id,
category_code, category_name, buffer_norm, closing_quantity, grn, in_transit,
sales, inst_hold, quality_hold, qa_hold, pending_orders, orders_in_hand,
transport_mode, supply_node_id, supply_node_name, supply_node_code,
supplying_quantity, supplying_buffer_norm, green_zone_qty, yellow_zone_qty,
red_zone_qty, closing_stock_zone, closing_stock_zone_sort, in_transit_zone,
in_transit_zone_sort, supplying_node_zone, supplying_node_zone_sort,
replenishment_quantity, final_quantity, mrq, transaction_comment,
open_stock_transfer_order, open_planned_order, open_purchase_request,
open_production_order, open_purchase_order, field1, field2, field3, field4,
field5, field6, field7, field8, field9, field10, mtd_sales, mtd_grn from
replenishment where transaction_date = ?param0 and sku_id = ?
param1 and node_id = ?param2]
2018-03-15 10:55:09,851-Statement Id: [SelectReplenishmentDates] Prepared SQL:
[SELECT DATE_FORMAT(transaction_date,'%Y-%m-%d') AS transaction_date FROM
replenishment USE INDEX (transaction_date) WHERE (transaction_date
BETWEEN ?param0 and ?param1 ) GROUP BY transaction_date]
2018-03-15 10:55:09,852-Statement Id: [InsertReplenishmentList] Prepared SQL:
[insert into replenishment (transaction_id, transaction_date, display_date,
transfilter_date, sku_id, sku_code, sku_name, node_id, node_code, node_name,
category_id, category_code, category_name, buffer_norm, grn, in_transit,
sales, inst_hold, quality_hold, qa_hold, pending_orders, orders_in_hand,
transport_mode, supply_node_id, supply_node_name, supply_node_code,
supplying_quantity, supplying_buffer_norm, green_zone_qty, yellow_zone_qty,
red_zone_qty, closing_stock_zone, closing_stock_zone_sort, in_transit_zone,
in_transit_zone_sort, supplying_node_zone, supplying_node_zone_sort,
replenishment_quantity, final_quantity, mrq, transaction_comment, db_sync,
mongo_sync, open_stock_transfer_order, open_planned_order,
open_purchase_request, open_production_order, open_purchase_order, field1,
field2, field3, field4, field5, field6, field7, field8, field9, field10,
closing_quantity, mtd_sales, mtd_grn ) SELECT tmt.transaction_id,
tmt.transaction_date, tmt.display_date, tmt.transfilter_date, tmt.sku_id,
tmt.sku_code, tmt.sku_name, tmt.node_id, tmt.node_code, tmt.node_name,
tmt.category_id, tmt.category_code, tmt.category_name, tmt.buffer_norm,
tmt.grn, tmt.in_transit, tmt.sales, tmt.inst_hold, tmt.quality_hold,
tmt.qa_hold, tmt.pending_orders, tmt.orders_in_hand, tmt.transport_mode,
tmt.supply_node_id, tmt.supply_node_name, tmt.supply_node_code,
tmt.supplying_quantity, tmt.supplying_buffer_norm, tmt.green_zone_qty,
tmt.yellow_zone_qty, tmt.red_zone_qty, tmt.closing_stock_zone,
tmt.closing_stock_zone_sort, tmt.in_transit_zone, tmt.in_transit_zone_sort,
tmt.supplying_node_zone, tmt.supplying_node_zone_sort,
tmt.replenishment_quantity, tmt.final_quantity, tmt.mrq,
tmt.transaction_comment, tmt.db_sync, tmt.mongo_sync,
tmt.open_stock_transfer_order, tmt.open_planned_order, tmt.open_purchase_request,
tmt.open_production_order, tmt.open_purchase_order, tmt.field1, tmt.field2,
tmt.field3, tmt.field4, tmt.field5, tmt.field6, tmt.field7, tmt.field8, tmt.field9,
tmt.field10, CASE WHEN IFNULL(tmt.closing_quantity,0) > 0 THEN
tmt.closing_quantity ELSE IFNULL((SELECT tcl.closing_quantity FROM
TRANSACTION tcl WHERE tcl.transaction_date < tmt.transaction_date AND
tcl.sku_id = tmt.sku_id AND tcl.node_id = tmt.node_id ORDER BY
tcl.transaction_date DESC LIMIT 1), 0) END AS closing_quantity,
IFNULL((SELECT SUM(tms.sales) FROM TRANSACTION tms USE INDEX
(inx_tdt_sku_node_sales) WHERE tms.transaction_date <= tmt.transaction_date
AND tms.transaction_date >= DATE_FORMAT(tmt.transaction_date,'%Y-%m-01') AND
tms.sku_id = tmt.sku_id AND tms.node_id = tmt.node_id), 0) AS mtd_sales,
IFNULL((SELECT SUM(tmg.grn) FROM TRANSACTION tmg USE INDEX (inx_tdt_sku_node_grn)
WHERE tmg.transaction_date <= tmt.transaction_date AND tmg.transaction_date >=
DATE_FORMAT(tmt.transaction_date,'%Y-%m-01') AND tmg.sku_id = tmt.sku_id AND
tmg.node_id = tmt.node_id), 0) AS mtd_grn FROM (SELECT
tr.transaction_id, tr.transaction_date, DATE_FORMAT(tr.transaction_date,'%d/%m/%Y')
AS display_date, DATE_FORMAT(tr.transaction_date,'%Y%m%d') AS transfilter_date,
tr.sku_id, s.sku_code, s.sku_name, tr.node_id, n.node_code, n.node_name,
sc.category_id, cat.category_code, cat.category_name, IFNULL(bn.buffer_norm,
0) AS buffer_norm, IFNULL(tr.closing_quantity, 0) AS closing_quantity,
IFNULL(tr.grn,0) AS grn, IFNULL(tr.in_transit, 0) AS in_transit, IFNULL(tr.sales,
0) AS sales, IFNULL(tr.inst_hold, 0) AS inst_hold, IFNULL(tr.quality_hold,
0) AS quality_hold, IFNULL(tr.qa_hold, 0) AS qa_hold,
IFNULL(tr.pending_orders, 0) AS pending_orders, IFNULL(tr.orders_in_hand, 0) AS
orders_in_hand, IFNULL(tr.transport_mode, '') AS transport_mode, CASE WHEN
IFNULL(tr.supply_node_id,0) > 0 THEN IFNULL(tr.supply_node_id,0) ELSE
IFNULL(nsm.supplier_node_id,0) END AS supply_node_id, sn.node_name AS
supply_node_name, sn.node_code AS supply_node_code,
IFNULL(str.closing_quantity, 0) AS supplying_quantity,
IFNULL(sbn.buffer_norm, 0) AS supplying_buffer_norm,
ROUND(IFNULL(bn.buffer_norm, 0),2) AS 'green_zone_qty', CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2)
END AS 'yellow_zone_qty', CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END AS 'red_zone_qty', CASE
WHEN IFNULL(bn.buffer_norm, 0) = 0 THEN 'White' WHEN
(IFNULL(tr.closing_quantity, 0) <= 0 AND IFNULL(bn.buffer_norm, 0) > 0) THEN
'Black' WHEN (IFNULL(tr.closing_quantity, 0) > IFNULL(bn.buffer_norm, 0) AND
IFNULL(bn.buffer_norm, 0) > 0) THEN 'Blue' WHEN (IFNULL(tr.closing_quantity,
0) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(tr.closing_quantity,
0) <= IFNULL(bn.buffer_norm, 0) AND IFNULL(bn.buffer_norm, 0) > 0) THEN 'Green'
WHEN (IFNULL(tr.closing_quantity, 0) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(tr.closing_quantity, 0) <=
(CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(bn.buffer_norm, 0) >
0) THEN 'Yellow' WHEN (IFNULL(tr.closing_quantity, 0) > 0 AND
IFNULL(tr.closing_quantity, 0) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(bn.buffer_norm, 0) > 0) THEN
'Red' END AS 'closing_stock_zone', CASE WHEN
IFNULL(bn.buffer_norm, 0) = 0 THEN 6 WHEN (IFNULL(tr.closing_quantity, 0) <=
0 AND IFNULL(bn.buffer_norm, 0) > 0) THEN 1 WHEN
(IFNULL(tr.closing_quantity, 0) > IFNULL(bn.buffer_norm, 0) AND
IFNULL(bn.buffer_norm, 0) > 0) THEN 2 WHEN (IFNULL(tr.closing_quantity, 0) >
(CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(tr.closing_quantity,
0) <= IFNULL(bn.buffer_norm, 0) AND IFNULL(bn.buffer_norm, 0) > 0) THEN 4
WHEN (IFNULL(tr.closing_quantity, 0) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(tr.closing_quantity, 0) <=
(CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(bn.buffer_norm, 0) >
0) THEN 3 WHEN (IFNULL(tr.closing_quantity, 0) > 0 AND
IFNULL(tr.closing_quantity, 0) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(bn.buffer_norm, 0) > 0) THEN
5 END AS 'closing_stock_zone_sort', CASE WHEN
IFNULL(bn.buffer_norm, 0) = 0 THEN 'White' WHEN
((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) <= 0 AND IFNULL(bn.buffer_norm, 0) > 0) THEN 'Black'
WHEN ((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > IFNULL(bn.buffer_norm, 0) AND
IFNULL(bn.buffer_norm, 0) > 0) THEN 'Blue' WHEN
((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND
(IFNULL(tr.closing_quantity, 0) + tr.in_transit - tr.pending_orders) <=
IFNULL(bn.buffer_norm, 0) AND IFNULL(bn.buffer_norm, 0) > 0) THEN 'Green'
WHEN ((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND (tr.closing_quantity +
tr.in_transit - tr.pending_orders) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2)
ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(bn.buffer_norm,
0) > 0) THEN 'Yellow' WHEN ((IFNULL(tr.closing_quantity, 0) +
IFNULL(tr.in_transit, 0) - IFNULL(tr.pending_orders, 0)) > 0 AND
(IFNULL(tr.closing_quantity, 0) + tr.in_transit - tr.pending_orders) <= (CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND
IFNULL(bn.buffer_norm, 0) > 0) THEN 'Red' END AS 'in_transit_zone',
CASE WHEN IFNULL(bn.buffer_norm, 0) = 0 THEN 6 WHEN
((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) <= 0 AND IFNULL(bn.buffer_norm, 0) > 0) THEN 1
WHEN ((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > IFNULL(bn.buffer_norm, 0) AND
IFNULL(bn.buffer_norm,
0) > 0) THEN 2 WHEN ((IFNULL(tr.closing_quantity, 0) +
IFNULL(tr.in_transit, 0) - IFNULL(tr.pending_orders, 0)) > (CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2)
END) AND (IFNULL(tr.closing_quantity, 0) + tr.in_transit - tr.pending_orders) <=
IFNULL(bn.buffer_norm, 0) AND IFNULL(bn.buffer_norm, 0) > 0) THEN 4 WHEN
((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND (IFNULL(tr.closing_quantity, 0) +
tr.in_transit - tr.pending_orders) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2)
ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(bn.buffer_norm,
0) > 0) THEN 3 WHEN ((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit,
0) - IFNULL(tr.pending_orders, 0)) > 0 AND (IFNULL(tr.closing_quantity, 0) +
tr.in_transit - tr.pending_orders) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(bn.buffer_norm, 0) > 0) THEN
5 END AS 'in_transit_zone_sort', CASE WHEN
IFNULL(sbn.buffer_norm, 0) = 0 THEN 'White' WHEN
(IFNULL(str.closing_quantity, 0) <= 0 AND IFNULL(sbn.buffer_norm, 0) > 0) THEN
'Black' WHEN (IFNULL(str.closing_quantity, 0) > IFNULL(sbn.buffer_norm, 0)
AND IFNULL(sbn.buffer_norm, 0) > 0) THEN 'Blue' WHEN
(IFNULL(str.closing_quantity, 0) > (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) AND
IFNULL(str.closing_quantity, 0) <= IFNULL(sbn.buffer_norm, 0) AND
IFNULL(sbn.buffer_norm, 0) > 0) THEN 'Green' WHEN
(IFNULL(str.closing_quantity, 0) > (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) AND IFNULL(str.closing_quantity, 0) <=
(CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) AND IFNULL(sbn.buffer_norm, 0)
> 0) THEN 'Yellow' WHEN (IFNULL(str.closing_quantity, 0) > 0 AND
IFNULL(str.closing_quantity, 0) <= (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) AND IFNULL(sbn.buffer_norm, 0) > 0)
THEN 'Red' END AS 'supplying_node_zone', CASE WHEN
IFNULL(sbn.buffer_norm, 0) = 0 THEN 6 WHEN (IFNULL(str.closing_quantity, 0)
<= 0 AND IFNULL(sbn.buffer_norm, 0) > 0) THEN 1 WHEN
(IFNULL(str.closing_quantity, 0) > IFNULL(sbn.buffer_norm, 0) AND
IFNULL(sbn.buffer_norm, 0) > 0) THEN 2 WHEN (IFNULL(str.closing_quantity, 0)
> (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) AND
IFNULL(str.closing_quantity, 0) <= IFNULL(sbn.buffer_norm, 0) AND
IFNULL(sbn.buffer_norm, 0) > 0) THEN 4 WHEN (IFNULL(str.closing_quantity, 0)
> (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) AND IFNULL(str.closing_quantity, 0) <=
(CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) AND IFNULL(sbn.buffer_norm, 0)
> 0) THEN 3 WHEN (IFNULL(str.closing_quantity, 0) > 0 AND
IFNULL(str.closing_quantity, 0) <= (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) AND IFNULL(sbn.buffer_norm, 0) > 0)
THEN 5 END AS 'supplying_node_zone_sort', CASE WHEN
((IFNULL(bn.buffer_norm, 0) - IFNULL(tr.closing_quantity, 0) -
IFNULL(tr.in_transit, 0)) + IFNULL(tr.pending_orders, 0)) -
(IFNULL(tr.open_planned_order, 0) + IFNULL(tr.open_purchase_request, 0) +
IFNULL(tr.open_production_order, 0) + IFNULL(tr.open_purchase_order, 0)) <= 0 THEN
0 ELSE ((IFNULL(bn.buffer_norm, 0) - IFNULL(tr.closing_quantity, 0) -
IFNULL(tr.in_transit, 0)) + IFNULL(tr.pending_orders, 0)) -
(IFNULL(tr.open_planned_order, 0) + IFNULL(tr.open_purchase_request, 0) +
IFNULL(tr.open_production_order, 0) + IFNULL(tr.open_purchase_order, 0)) END
AS 'replenishment_quantity', CASE WHEN (IFNULL(tr.closing_quantity,
0) + IFNULL(tr.in_transit, 0) + IFNULL(tr.open_planned_order, 0) +
IFNULL(tr.open_purchase_request, 0) + IFNULL(tr.open_production_order, 0) +
IFNULL(tr.open_purchase_order, 0) ) - IFNULL(tr.pending_orders, 0) <= 0 THEN 0
ELSE (IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) +
IFNULL(tr.open_planned_order, 0) + IFNULL(tr.open_purchase_request, 0) +
IFNULL(tr.open_production_order, 0) + IFNULL(tr.open_purchase_order, 0) ) -
IFNULL(tr.pending_orders, 0) END AS 'final_quantity', CASE
WHEN IFNULL(bn.buffer_norm, 0) = 0 THEN 0 ELSE (CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END)
END AS 'mrq', (SELECT COUNT(1) FROM transaction_comment WHERE
transaction_id = tr.transaction_id) AS 'transaction_comment', 0 AS db_sync, 0 AS
mongo_sync, IFNULL(tr.open_stock_transfer_order, 0) AS
open_stock_transfer_order, IFNULL(tr.open_planned_order, 0) AS open_planned_order,
IFNULL(tr.open_purchase_request, 0) AS open_purchase_request,
IFNULL(tr.open_production_order, 0) AS open_production_order,
IFNULL(tr.open_purchase_order, 0) AS open_purchase_order, tr.field1,
tr.field2, tr.field3, tr.field4, tr.field5, tr.field6, tr.field7, tr.field8,
tr.field9, tr.field10 from ( select tt.transaction_id from
transaction tt use index (transaction_date) inner join update_transaction ut
use index (inx_transactionid) on ut.transaction_id = tt.transaction_id
where tt.transaction_date = ?param0 ORDER BY tt.sku_id limit ?
param1 , ?param2 ) otr join transaction tr on
tr.transaction_id = otr.transaction_id LEFT JOIN buffer_norm bn USE INDEX
(inx_sku_node_efdt) ON bn.sku_id = tr.sku_id AND bn.node_id =
tr.node_id AND bn.effective_from = ( SELECT MAX(effective_from) FROM
buffer_norm WHERE effective_from <= tr.transaction_date AND sku_id =
tr.sku_id AND node_id = tr.node_id) LEFT JOIN sku s ON
s.sku_id = tr.sku_id LEFT JOIN sku_category sc ON
sc.sku_category_id = (SELECT sku_category_id FROM sku_category WHERE sku_id =
tr.sku_id LIMIT 1) LEFT JOIN category cat ON cat.category_id =
sc.category_id LEFT JOIN node n ON n.node_id = tr.node_id
LEFT OUTER JOIN node_sku_mapping nsm USE INDEX (inx_sku_receiver_node_efdt)
ON nsm.receiver_node_id = tr.node_id AND nsm.sku_id = tr.sku_id AND
nsm.effective_date = ( SELECT MAX(effective_date) FROM node_sku_mapping
WHERE effective_date <= tr.transaction_date AND sku_id = tr.sku_id
AND receiver_node_id = tr.node_id) LEFT JOIN node sn ON CASE WHEN
IFNULL(tr.supply_node_id,0) > 0 THEN sn.node_id = tr.supply_node_id ELSE
sn.node_id = nsm.supplier_node_id END LEFT JOIN buffer_norm sbn USE INDEX
(inx_sku_node_efdt) ON sbn.sku_id = tr.sku_id AND CASE WHEN
IFNULL(tr.supply_node_id,0) > 0 THEN sbn.node_id = tr.supply_node_id ELSE
sbn.node_id = nsm.supplier_node_id END AND sbn.effective_from =
( SELECT MAX(effective_from) FROM buffer_norm WHERE effective_from <=
tr.transaction_date AND sku_id = tr.sku_id AND node_id = tr.node_id)
LEFT JOIN TRANSACTION str USE INDEX (inx_tdt_sku_node_snode) ON
str.transaction_date = tr.transaction_date AND str.sku_id = tr.sku_id
AND CASE WHEN IFNULL(tr.supply_node_id,0) > 0 THEN str.node_id =
IFNULL(tr.supply_node_id,0) ELSE str.node_id = nsm.supplier_node_id END
GROUP BY tr.transaction_id ORDER BY tr.transaction_id) tmt ON
DUPLICATE KEY UPDATE category_id=VALUES(category_id),
category_code=VALUES(category_code), category_name=VALUES(category_name),
buffer_norm=VALUES(buffer_norm), closing_quantity=VALUES(closing_quantity),
grn=VALUES(grn), in_transit=VALUES(in_transit), sales=VALUES(sales),
inst_hold=VALUES(inst_hold), quality_hold=VALUES(quality_hold),
qa_hold=VALUES(qa_hold), pending_orders=VALUES(pending_orders),
orders_in_hand=VALUES(orders_in_hand), mtd_sales=VALUES(mtd_sales),
mtd_grn=VALUES(mtd_grn), transport_mode=VALUES(transport_mode),
supply_node_id=VALUES(supply_node_id), supply_node_name=VALUES(supply_node_name),
supply_node_code=VALUES(supply_node_code),
supplying_quantity=VALUES(supplying_quantity),
supplying_buffer_norm=VALUES(supplying_buffer_norm),
green_zone_qty=VALUES(green_zone_qty), yellow_zone_qty=VALUES(yellow_zone_qty),
red_zone_qty=VALUES(red_zone_qty), closing_stock_zone=VALUES(closing_stock_zone),
closing_stock_zone_sort=VALUES(closing_stock_zone_sort),
in_transit_zone=VALUES(in_transit_zone),
in_transit_zone_sort=VALUES(in_transit_zone_sort),
supplying_node_zone=VALUES(supplying_node_zone),
supplying_node_zone_sort=VALUES(supplying_node_zone_sort),
replenishment_quantity=VALUES(replenishment_quantity),
final_quantity=VALUES(final_quantity), mrq=VALUES(mrq), db_sync=VALUES(db_sync),
mongo_sync=VALUES(mongo_sync),
open_stock_transfer_order=VALUES(open_stock_transfer_order),
open_planned_order=VALUES(open_planned_order),
open_purchase_request=VALUES(open_purchase_request),
open_production_order=VALUES(open_production_order),
open_purchase_order=VALUES(open_purchase_order), field1=VALUES(field1),
field2=VALUES(field2), field3=VALUES(field3), field4=VALUES(field4),
field5=VALUES(field5), field6=VALUES(field6), field7=VALUES(field7),
field8=VALUES(field8), field9=VALUES(field9), field10=VALUES(field10);]
2018-03-15 10:55:09,853-Statement Id: [InsertReplenishmentListFullSync] Prepared
SQL: [insert into replenishment (transaction_id, transaction_date,
display_date, transfilter_date, sku_id, sku_code, sku_name, node_id, node_code,
node_name, category_id, category_code, category_name, buffer_norm,
closing_quantity, in_transit, sales, inst_hold, quality_hold, qa_hold,
pending_orders, orders_in_hand, transport_mode, supply_node_id,
supply_node_name, supply_node_code, supplying_quantity, supplying_buffer_norm,
green_zone_qty, yellow_zone_qty, red_zone_qty, closing_stock_zone,
closing_stock_zone_sort, in_transit_zone, in_transit_zone_sort,
supplying_node_zone, supplying_node_zone_sort, replenishment_quantity,
final_quantity, mrq, transaction_comment, db_sync, mongo_sync,
open_stock_transfer_order, open_planned_order, open_purchase_request,
open_production_order, open_purchase_order, field1, field2, field3, field4, field5,
field6, field7, field8, field9, field10 ) SELECT tr.transaction_id,
tr.transaction_date, DATE_FORMAT(tr.transaction_date,'%d/%m/%Y') AS display_date,
DATE_FORMAT(tr.transaction_date,'%Y%m%d') AS transfilter_date, tr.sku_id,
s.sku_code, s.sku_name, tr.node_id, n.node_code, n.node_name, sc.category_id,
cat.category_code, cat.category_name, IFNULL(bn.buffer_norm, 0) AS
buffer_norm, IFNULL(tr.closing_quantity, 0) AS closing_quantity,
IFNULL(tr.in_transit, 0) AS in_transit, IFNULL(tr.sales, 0) AS sales,
IFNULL(tr.inst_hold, 0) AS inst_hold, IFNULL(tr.quality_hold, 0) AS quality_hold,
IFNULL(tr.qa_hold, 0) AS qa_hold, IFNULL(tr.pending_orders, 0) AS
pending_orders, IFNULL(tr.orders_in_hand, 0) AS orders_in_hand,
IFNULL(tr.transport_mode, '') AS transport_mode, CASE WHEN
IFNULL(tr.supply_node_id,0) > 0 THEN IFNULL(tr.supply_node_id,0) ELSE
IFNULL(nsm.supplier_node_id,0) END AS supply_node_id, sn.node_name AS
supply_node_name, sn.node_code AS supply_node_code,
IFNULL(str.closing_quantity, 0) AS supplying_quantity,
IFNULL(sbn.buffer_norm, 0) AS supplying_buffer_norm,
ROUND(IFNULL(bn.buffer_norm, 0),2) AS 'green_zone_qty', CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2)
END AS 'yellow_zone_qty', CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END AS 'red_zone_qty', CASE
WHEN IFNULL(bn.buffer_norm, 0) = 0 THEN 'White' WHEN
(IFNULL(tr.closing_quantity, 0) <= 0 AND IFNULL(bn.buffer_norm, 0) > 0) THEN
'Black' WHEN (IFNULL(tr.closing_quantity, 0) > IFNULL(bn.buffer_norm, 0) AND
IFNULL(bn.buffer_norm, 0) > 0) THEN 'Blue' WHEN (IFNULL(tr.closing_quantity,
0) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(tr.closing_quantity,
0) <= IFNULL(bn.buffer_norm, 0) AND IFNULL(bn.buffer_norm, 0) > 0) THEN 'Green'
WHEN (IFNULL(tr.closing_quantity, 0) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(tr.closing_quantity, 0) <=
(CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(bn.buffer_norm, 0) >
0) THEN 'Yellow' WHEN (IFNULL(tr.closing_quantity, 0) > 0 AND
IFNULL(tr.closing_quantity, 0) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(bn.buffer_norm, 0) > 0) THEN
'Red' END AS 'closing_stock_zone', CASE WHEN
IFNULL(bn.buffer_norm, 0) = 0 THEN 6 WHEN (IFNULL(tr.closing_quantity, 0) <=
0 AND IFNULL(bn.buffer_norm, 0) > 0) THEN 1 WHEN
(IFNULL(tr.closing_quantity, 0) > IFNULL(bn.buffer_norm, 0) AND
IFNULL(bn.buffer_norm, 0) > 0) THEN 2 WHEN (IFNULL(tr.closing_quantity, 0) >
(CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(tr.closing_quantity,
0) <= IFNULL(bn.buffer_norm, 0) AND IFNULL(bn.buffer_norm, 0) > 0) THEN 4
WHEN (IFNULL(tr.closing_quantity, 0) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(tr.closing_quantity, 0) <=
(CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(bn.buffer_norm, 0) >
0) THEN 3 WHEN (IFNULL(tr.closing_quantity, 0) > 0 AND
IFNULL(tr.closing_quantity, 0) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(bn.buffer_norm, 0) > 0) THEN
5 END AS 'closing_stock_zone_sort', CASE WHEN
IFNULL(bn.buffer_norm, 0) = 0 THEN 'White' WHEN
((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) <= 0 AND IFNULL(bn.buffer_norm, 0) > 0) THEN 'Black'
WHEN ((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > IFNULL(bn.buffer_norm, 0) AND
IFNULL(bn.buffer_norm, 0) > 0) THEN 'Blue' WHEN
((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND
(IFNULL(tr.closing_quantity, 0) + tr.in_transit - tr.pending_orders) <=
IFNULL(bn.buffer_norm, 0) AND IFNULL(bn.buffer_norm, 0) > 0) THEN 'Green'
WHEN ((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND (tr.closing_quantity +
tr.in_transit - tr.pending_orders) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2)
ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(bn.buffer_norm,
0) > 0) THEN 'Yellow' WHEN ((IFNULL(tr.closing_quantity, 0) +
IFNULL(tr.in_transit, 0) - IFNULL(tr.pending_orders, 0)) > 0 AND
(IFNULL(tr.closing_quantity, 0) + tr.in_transit - tr.pending_orders) <= (CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND
IFNULL(bn.buffer_norm, 0) > 0) THEN 'Red' END AS 'in_transit_zone',
CASE WHEN IFNULL(bn.buffer_norm, 0) = 0 THEN 6 WHEN
((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) <= 0 AND IFNULL(bn.buffer_norm, 0) > 0) THEN 1
WHEN ((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > IFNULL(bn.buffer_norm, 0) AND
IFNULL(bn.buffer_norm, 0) > 0) THEN 2 WHEN ((IFNULL(tr.closing_quantity, 0)
+ IFNULL(tr.in_transit, 0) - IFNULL(tr.pending_orders, 0)) > (CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2)
END) AND (IFNULL(tr.closing_quantity, 0) + tr.in_transit - tr.pending_orders) <=
IFNULL(bn.buffer_norm, 0) AND IFNULL(bn.buffer_norm, 0) > 0) THEN 4 WHEN
((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND (IFNULL(tr.closing_quantity, 0) +
tr.in_transit - tr.pending_orders) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2)
ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(bn.buffer_norm,
0) > 0) THEN 3 WHEN ((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit,
0) - IFNULL(tr.pending_orders, 0)) > 0 AND (IFNULL(tr.closing_quantity, 0) +
tr.in_transit - tr.pending_orders) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(bn.buffer_norm, 0) > 0) THEN
5 END AS 'in_transit_zone_sort', CASE WHEN
IFNULL(sbn.buffer_norm, 0) = 0 THEN 'White' WHEN
(IFNULL(str.closing_quantity, 0) <= 0 AND IFNULL(sbn.buffer_norm, 0) > 0) THEN
'Black' WHEN (IFNULL(str.closing_quantity, 0) > IFNULL(sbn.buffer_norm, 0)
AND IFNULL(sbn.buffer_norm, 0) > 0) THEN 'Blue' WHEN
(IFNULL(str.closing_quantity, 0) > (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) AND
IFNULL(str.closing_quantity, 0) <= IFNULL(sbn.buffer_norm, 0) AND
IFNULL(sbn.buffer_norm, 0) > 0) THEN 'Green' WHEN
(IFNULL(str.closing_quantity, 0) > (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.red_zone,0)
/ 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE ROUND(IFNULL(sbn.buffer_norm, 0) /
3,2) END) AND IFNULL(str.closing_quantity, 0) <= (CASE WHEN
IFNULL(sbn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(sbn.yellow_zone,0) / 100)
* IFNULL(sbn.buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(sbn.buffer_norm,
0)),2) END) AND IFNULL(sbn.buffer_norm, 0) > 0) THEN 'Yellow' WHEN
(IFNULL(str.closing_quantity, 0) > 0 AND IFNULL(str.closing_quantity, 0) <= (CASE
WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(sbn.red_zone,0) /
100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2)
END) AND IFNULL(sbn.buffer_norm, 0) > 0) THEN 'Red' END AS
'supplying_node_zone', CASE WHEN IFNULL(sbn.buffer_norm, 0) = 0
THEN 6 WHEN (IFNULL(str.closing_quantity, 0) <= 0 AND
IFNULL(sbn.buffer_norm, 0) > 0) THEN 1 WHEN (IFNULL(str.closing_quantity, 0)
> IFNULL(sbn.buffer_norm, 0) AND IFNULL(sbn.buffer_norm, 0) > 0) THEN 2 WHEN
(IFNULL(str.closing_quantity, 0) > (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) AND
IFNULL(str.closing_quantity, 0) <= IFNULL(sbn.buffer_norm, 0) AND
IFNULL(sbn.buffer_norm, 0) > 0) THEN 4 WHEN (IFNULL(str.closing_quantity, 0)
> (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) AND IFNULL(str.closing_quantity, 0) <=
(CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) AND IFNULL(sbn.buffer_norm, 0)
> 0) THEN 3 WHEN (IFNULL(str.closing_quantity, 0) > 0 AND
IFNULL(str.closing_quantity, 0) <= (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) AND IFNULL(sbn.buffer_norm, 0) > 0)
THEN 5 END AS 'supplying_node_zone_sort', CASE WHEN
((IFNULL(bn.buffer_norm, 0) - IFNULL(tr.closing_quantity, 0) -
IFNULL(tr.in_transit, 0)) + IFNULL(tr.pending_orders, 0)) -
(IFNULL(tr.open_planned_order, 0) + IFNULL(tr.open_purchase_request, 0) +
IFNULL(tr.open_production_order, 0) + IFNULL(tr.open_purchase_order, 0)) <= 0 THEN
0 ELSE ((IFNULL(bn.buffer_norm, 0) - IFNULL(tr.closing_quantity, 0) -
IFNULL(tr.in_transit, 0)) + IFNULL(tr.pending_orders, 0)) -
(IFNULL(tr.open_planned_order, 0) + IFNULL(tr.open_purchase_request, 0) +
IFNULL(tr.open_production_order, 0) + IFNULL(tr.open_purchase_order, 0)) END
AS 'replenishment_quantity', CASE WHEN (IFNULL(tr.closing_quantity,
0) + IFNULL(tr.in_transit, 0) + IFNULL(tr.open_planned_order, 0) +
IFNULL(tr.open_purchase_request, 0) + IFNULL(tr.open_production_order, 0) +
IFNULL(tr.open_purchase_order, 0) ) - IFNULL(tr.pending_orders, 0) <= 0 THEN 0
ELSE (IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) +
IFNULL(tr.open_planned_order, 0) + IFNULL(tr.open_purchase_request, 0) +
IFNULL(tr.open_production_order, 0) + IFNULL(tr.open_purchase_order, 0) ) -
IFNULL(tr.pending_orders, 0) END AS 'final_quantity', CASE
WHEN IFNULL(bn.buffer_norm, 0) = 0 THEN 0 ELSE (CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END)
END AS 'mrq', (SELECT COUNT(1) FROM transaction_comment WHERE
transaction_id = tr.transaction_id) AS 'transaction_comment', 0 AS db_sync, 0 AS
mongo_sync, IFNULL(tr.open_stock_transfer_order, 0),
IFNULL(tr.open_planned_order, 0), IFNULL(tr.open_purchase_request,
0),IFNULL(tr.open_production_order, 0), IFNULL(tr.open_purchase_order, 0),
tr.field1, tr.field2, tr.field3, tr.field4, tr.field5, tr.field6, tr.field7,
tr.field8, tr.field9, tr.field10 from ( select tt.transaction_id
from transaction tt use index (transaction_date) where
tt.transaction_date = ?param0 ORDER BY tt.sku_id limit ?
param1 , ?param2 ) otr join transaction tr on
tr.transaction_id = otr.transaction_id LEFT JOIN buffer_norm bn USE INDEX
(inx_sku_node_efdt) ON bn.sku_id = tr.sku_id AND bn.node_id =
tr.node_id AND bn.effective_from = ( SELECT MAX(effective_from) FROM
buffer_norm WHERE effective_from <= tr.transaction_date AND sku_id =
tr.sku_id AND node_id = tr.node_id) LEFT JOIN sku s ON
s.sku_id = tr.sku_id LEFT JOIN sku_category sc ON
sc.sku_category_id = (SELECT sku_category_id FROM sku_category WHERE sku_id =
tr.sku_id LIMIT 1) LEFT JOIN category cat ON cat.category_id =
sc.category_id LEFT JOIN node n ON n.node_id = tr.node_id
LEFT OUTER JOIN node_sku_mapping nsm USE INDEX (inx_sku_receiver_node_efdt)
ON nsm.receiver_node_id = tr.node_id AND nsm.sku_id = tr.sku_id AND
nsm.effective_date = ( SELECT MAX(effective_date) FROM node_sku_mapping
WHERE effective_date <= tr.transaction_date AND sku_id = tr.sku_id
AND receiver_node_id = tr.node_id) LEFT JOIN node sn ON CASE WHEN
IFNULL(tr.supply_node_id,0) > 0 THEN sn.node_id = tr.supply_node_id ELSE
sn.node_id = nsm.supplier_node_id END LEFT JOIN buffer_norm sbn USE INDEX
(inx_sku_node_efdt) ON sbn.sku_id = tr.sku_id AND CASE WHEN
IFNULL(tr.supply_node_id,0) > 0 THEN sbn.node_id = tr.supply_node_id ELSE
sbn.node_id = nsm.supplier_node_id END AND sbn.effective_from =
( SELECT MAX(effective_from) FROM buffer_norm WHERE effective_from <=
tr.transaction_date AND sku_id = tr.sku_id AND node_id = tr.node_id)
LEFT JOIN TRANSACTION str USE INDEX (inx_tdt_sku_node_snode) ON
str.transaction_date = tr.transaction_date AND str.sku_id = tr.sku_id
AND CASE WHEN IFNULL(tr.supply_node_id,0) > 0 THEN str.node_id =
IFNULL(tr.supply_node_id,0) ELSE str.node_id = nsm.supplier_node_id END
GROUP BY tr.transaction_id ORDER BY tr.transaction_id]
2018-03-15 10:55:09,854-Adding file [UserHelper.xml] to list of watched files.
2018-03-15 10:55:09,854-Statement Id: [SelectUserNameDuplicate] Prepared SQL:
[select user_id, user_name, first_name, middle_name, last_name, email, mobile,
description, password, status, approved, locked, role_id, region_id,
created_by, created_on, modified_by, modified_on from user where user_name =
?param0 and user_id != ?param1]
2018-03-15 10:55:09,854-Statement Id: [SelectUserMobileDuplicate] Prepared SQL:
[select user_id, user_name, first_name, middle_name, last_name, email, mobile,
description, password, status, approved, locked, role_id, region_id,
created_by, created_on, modified_by, modified_on from user where mobile = ?
param0 and user_id != ?param1]
2018-03-15 10:55:09,854-Statement Id: [SelectUserCheckAuthenticate] Prepared SQL:
[select user_id, user_name, first_name, middle_name, last_name, email, mobile,
description, password, status, approved, locked, role_id, region_id,
created_by, created_on, modified_by, modified_on from user where user_name =
?param0 and password = ?param1 and status = 1]
2018-03-15 10:55:09,854-Statement Id: [SelectUserCheckLocked] Prepared SQL: [select
user_id, user_name, first_name, middle_name, last_name, email, mobile, description,
password, status, approved, locked, role_id, region_id, created_by,
created_on, modified_by, modified_on from user where user_name = ?param0]
2018-03-15 10:55:09,855-Statement Id: [InsertUser] Prepared SQL: [insert into user
(user_name, first_name, middle_name, last_name, email, mobile, description,
password, status, approved, locked, role_id, region_id, created_by,
created_on) values ( ?param0 , ?param1 , ?param2 , ?param3 , ?
param4 , ?param5 , ?param6 , ?param7 , ?param8 , ?param9 , ?param10 ,
?param11 , ?param12 , ?param13 , NOW());]
2018-03-15 10:55:09,855-Statement Id: [InsertUser.SelectKey] Prepared SQL: [select
last_insert_id() as value]
2018-03-15 10:55:09,855-Statement Id: [UpdateUser] Prepared SQL: [update user set
user_name = ?param0 , first_name = ?param1 , middle_name = ?param2
, last_name = ?param3 , email = ?param4 , mobile = ?
param5 , description = ?param6 , password = ?param7 , status
= ?param8 , approved = ?param9 , locked = ?param10 ,
role_id = ?param11 , region_id = ?param12 , modified_by = ?param13
, modified_on = NOW() where user_id = ?param14]
2018-03-15 10:55:09,855-Statement Id: [DeleteUser] Prepared SQL: [delete from user
where user_id = ?param0]
2018-03-15 10:55:09,855-Adding file [UserModuleHelper.xml] to list of watched
files.
2018-03-15 10:55:09,855-Statement Id: [InsertUserModule] Prepared SQL: [insert into
user_module (role_id, module_id, created_by, created_on) values
( ?param0 , ?param1 , ?param2 , NOW());]
2018-03-15 10:55:09,855-Statement Id: [InsertUserModule.SelectKey] Prepared SQL:
[select last_insert_id() as value]
2018-03-15 10:55:09,855-Statement Id: [DeleteUserModule] Prepared SQL: [delete from
user_module where user_module_id = ?param0]
2018-03-15 10:55:09,855-Statement Id: [DeleteModuleByRole] Prepared SQL: [delete
from user_module where role_id = ?param0]
2018-03-15 10:55:09,855-Adding file [SKUGridHelper.xml] to list of watched files.
2018-03-15 10:55:09,860-Statement Id: [SelectSKUGrid] Prepared SQL: [select
s.sku_name, n.node_name, c.category_id, c.category_name, sku_grid.*, case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (1 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(1 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (1 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (1 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (1 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (1 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (1 * avg_sales)) > 0 and (closing_quantity - (1 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(red_zone,0) /
100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and
buffer_norm > 0) then 'Red' end as 'one', case when (closing_quantity
- (1 * avg_sales)) <= 0 then 0 else (closing_quantity - (1 * avg_sales)) end as
'one_qty', case when ifnull(buffer_norm, 0) = 0 then 'White'
when ((closing_quantity - (2 * avg_sales)) <= 0 and buffer_norm > 0) then 'Black'
when ((closing_quantity - (2 * avg_sales)) > buffer_norm and buffer_norm > 0) then
'Blue' when ((closing_quantity - (2 * avg_sales)) > (CASE WHEN
IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) *
IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END)
and (closing_quantity - (2 * avg_sales)) <= buffer_norm and buffer_norm > 0) then
'Green' when ((closing_quantity - (2 * avg_sales)) > (CASE WHEN
IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(red_zone,0) / 100) *
IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and
(closing_quantity - (2 * avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow'
when ((closing_quantity - (2 * avg_sales)) > 0 and (closing_quantity - (2 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'two', case when (closing_quantity - (2 * avg_sales)) <= 0 then 0 else
(closing_quantity - (2 * avg_sales)) end as 'two_qty', case when
ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (3 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(3 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (3 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (3 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (3 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (3 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (3 * avg_sales)) > 0 and (closing_quantity - (3 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(red_zone,0) /
100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and
buffer_norm > 0) then 'Red' end as 'three', case when
(closing_quantity - (3 * avg_sales)) <= 0 then 0 else (closing_quantity - (3 *
avg_sales)) end as 'three_qty', case when ifnull(buffer_norm, 0) = 0
then 'White' when ((closing_quantity - (4 * avg_sales)) <= 0 and buffer_norm
> 0) then 'Black' when ((closing_quantity - (4 * avg_sales)) > buffer_norm
and buffer_norm > 0) then 'Blue' when ((closing_quantity - (4 * avg_sales))
> (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(yellow_zone,0) /
100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2)
END) and (closing_quantity - (4 * avg_sales)) <= buffer_norm and buffer_norm > 0)
then 'Green' when ((closing_quantity - (4 * avg_sales)) > (CASE WHEN
IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(red_zone,0) / 100) *
IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and
(closing_quantity - (4 * avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow'
when ((closing_quantity - (4 * avg_sales)) > 0 and (closing_quantity - (4 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'four', case when (closing_quantity - (4 * avg_sales)) <= 0 then 0 else
(closing_quantity - (4 * avg_sales)) end as 'four_qty', case when
ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (5 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(5 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (5 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (5 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (5 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (5 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (5 * avg_sales)) > 0 and (closing_quantity - (5 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(red_zone,0) /
100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and
buffer_norm > 0) then 'Red' end as 'five', case when
(closing_quantity - (5 * avg_sales)) <= 0 then 0 else (closing_quantity - (5 *
avg_sales)) end as 'five_qty', case when ifnull(buffer_norm, 0) = 0
then 'White' when ((closing_quantity - (6 * avg_sales)) <= 0 and buffer_norm
> 0) then 'Black' when ((closing_quantity - (6 * avg_sales)) > buffer_norm
and buffer_norm > 0) then 'Blue' when ((closing_quantity - (6 * avg_sales))
> (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(yellow_zone,0) /
100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2)
END) and (closing_quantity - (6 * avg_sales)) <= buffer_norm and buffer_norm > 0)
then 'Green' when ((closing_quantity - (6 * avg_sales)) > (CASE WHEN
IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(red_zone,0) / 100) *
IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and
(closing_quantity - (6 * avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow'
when ((closing_quantity - (6 * avg_sales)) > 0 and (closing_quantity - (6 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'six', case when (closing_quantity - (6 * avg_sales)) <= 0 then 0 else
(closing_quantity - (6 * avg_sales)) end as 'six_qty', case when
ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (7 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(7 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (7 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (7 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (7 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (7 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm
> 0) then 'Yellow' when ((closing_quantity - (7 * avg_sales)) > 0 and
(closing_quantity - (7 * avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'seven', case when (closing_quantity - (7 * avg_sales)) <= 0 then 0 else
(closing_quantity - (7 * avg_sales)) end as 'seven_qty', case when
ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (8 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(8 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (8 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (8 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (8 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (8 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (8 * avg_sales)) > 0 and (closing_quantity - (8 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(red_zone,0) /
100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and
buffer_norm > 0) then 'Red' end as 'eight', case when
(closing_quantity - (8 * avg_sales)) <= 0 then 0 else (closing_quantity - (8 *
avg_sales)) end as 'eight_qty', case when ifnull(buffer_norm, 0) = 0
then 'White' when ((closing_quantity - (9 * avg_sales)) <= 0 and buffer_norm
> 0) then 'Black' when ((closing_quantity - (9 * avg_sales)) > buffer_norm
and buffer_norm > 0) then 'Blue' when ((closing_quantity - (9 * avg_sales))
> (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(yellow_zone,0) /
100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2)
END) and (closing_quantity - (9 * avg_sales)) <= buffer_norm and buffer_norm > 0)
then 'Green' when ((closing_quantity - (9 * avg_sales)) > (CASE WHEN
IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(red_zone,0) / 100) *
IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and
(closing_quantity - (9 * avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow'
when ((closing_quantity - (9 * avg_sales)) > 0 and (closing_quantity - (9 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'nine', case when (closing_quantity - (9 * avg_sales)) <= 0 then 0 else
(closing_quantity - (9 * avg_sales)) end as 'nine_qty', case when
ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (10 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(10 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (10 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (10 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (10 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (10 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (10 * avg_sales)) > 0 and (closing_quantity - (10 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'ten', case when (closing_quantity - (10 * avg_sales)) <= 0 then 0 else
(closing_quantity - (10 * avg_sales)) end as 'ten_qty', case when
ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (11 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(11 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (11 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (11 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (11 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (11 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (11 * avg_sales)) > 0 and (closing_quantity - (11 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'eleven', case when (closing_quantity - (11 * avg_sales)) <= 0 then 0
else (closing_quantity - (11 * avg_sales)) end as 'eleven_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (12 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(12 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (12 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (12 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (12 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (12 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (12 * avg_sales)) > 0 and (closing_quantity - (12 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twelve', case when (closing_quantity - (12 * avg_sales)) <= 0 then 0
else (closing_quantity - (12 * avg_sales)) end as 'twelve_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (13 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(13 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (13 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (13 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (13 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (13 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (13 * avg_sales)) > 0 and (closing_quantity - (13 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'thirteen', case when (closing_quantity - (13 * avg_sales)) <= 0 then 0
else (closing_quantity - (13 * avg_sales)) end as 'thirteen_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (14 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(14 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (14 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (14 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (14 * avg_sales)) > (CASE
WHEN IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(red_zone,0) / 100) *
IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and
(closing_quantity - (14 * avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow'
when ((closing_quantity - (14 * avg_sales)) > 0 and (closing_quantity - (14 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'fourteen', case when (closing_quantity - (14 * avg_sales)) <= 0 then 0
else (closing_quantity - (14 * avg_sales)) end as 'fourteen_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (15 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(15 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (15 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (15 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (15 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (15 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (15 * avg_sales)) > 0 and (closing_quantity - (15 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'fifteen', case when (closing_quantity - (15 * avg_sales)) <= 0 then 0
else (closing_quantity - (15 * avg_sales)) end as 'fifteen_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (16 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(16 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (16 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (16 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (16 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (16 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (16 * avg_sales)) > 0 and (closing_quantity - (16 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'sixteen', case when (closing_quantity - (16 * avg_sales)) <= 0 then 0
else (closing_quantity - (16 * avg_sales)) end as 'sixteen_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (17 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(17 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (17 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (17 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (17 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (17 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (17 * avg_sales)) > 0 and (closing_quantity - (17 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'seventeen', case when (closing_quantity - (17 * avg_sales)) <= 0 then 0
else (closing_quantity - (17 * avg_sales)) end as 'seventeen_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (18 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(18 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (18 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (18 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (18 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (18 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (18 * avg_sales)) > 0 and (closing_quantity - (18 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'eighteen', case when (closing_quantity - (18 * avg_sales)) <= 0 then 0
else (closing_quantity - (18 * avg_sales)) end as 'eighteen_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (19 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(19 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (19 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (19 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (19 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (19 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (19 * avg_sales)) > 0 and (closing_quantity - (19 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'nineteen', case when (closing_quantity - (19 * avg_sales)) <= 0 then 0
else (closing_quantity - (19 * avg_sales)) end as 'nineteen_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (20 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(20 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (20 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (20 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (20 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (20 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (20 * avg_sales)) > 0 and (closing_quantity - (20 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twenty', case when (closing_quantity - (20 * avg_sales)) <= 0 then 0
else (closing_quantity - (20 * avg_sales)) end as 'twenty_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (21 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity
- (21 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (21 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (21 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (21 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (21 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (21 * avg_sales)) > 0 and (closing_quantity - (21 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twentyone', case when (closing_quantity - (21 * avg_sales)) <= 0 then 0
else (closing_quantity - (21 * avg_sales)) end as 'twentyone_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (22 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(22 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (22 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (22 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (22 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (22 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (22 * avg_sales)) > 0 and (closing_quantity - (22 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twentytwo', case when (closing_quantity - (22 * avg_sales)) <= 0 then 0
else (closing_quantity - (22 * avg_sales)) end as 'twentytwo_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (23 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(23 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (23 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (23 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (23 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (23 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (23 * avg_sales)) > 0 and (closing_quantity - (23 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twentythree', case when (closing_quantity - (23 * avg_sales)) <= 0 then
0 else (closing_quantity - (23 * avg_sales)) end as 'twentythree_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (24 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(24 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (24 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (24 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (24 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (24 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (24 * avg_sales)) > 0 and (closing_quantity - (24 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twentyfour', case when (closing_quantity - (24 * avg_sales)) <= 0 then 0
else (closing_quantity - (24 * avg_sales)) end as 'twentyfour_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (25 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(25 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (25 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (25 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (25 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (25 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (25 * avg_sales)) > 0 and (closing_quantity - (25 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twentyfive', case when (closing_quantity - (25 * avg_sales)) <= 0 then 0
else (closing_quantity - (25 * avg_sales)) end as 'twentyfive_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (26 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(26 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (26 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (26 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (26 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (26 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (26 * avg_sales)) > 0 and (closing_quantity - (26 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twentysix', case when (closing_quantity - (26 * avg_sales)) <= 0 then 0
else (closing_quantity - (26 * avg_sales)) end as 'twentysix_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (27 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(27 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (27 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (27 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (27 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (27 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (27 * avg_sales)) > 0 and (closing_quantity - (27 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0)
/ 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END)
and buffer_norm > 0) then 'Red' end as 'twentyseven', case when
(closing_quantity - (27 * avg_sales)) <= 0 then 0 else (closing_quantity - (27 *
avg_sales)) end as 'twentyseven_qty', case when ifnull(buffer_norm,
0) = 0 then 'White' when ((closing_quantity - (28 * avg_sales)) <= 0 and
buffer_norm > 0) then 'Black' when ((closing_quantity - (28 * avg_sales)) >
buffer_norm and buffer_norm > 0) then 'Blue' when ((closing_quantity - (28 *
avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (28 * avg_sales)) <=
buffer_norm and buffer_norm > 0) then 'Green' when ((closing_quantity - (28
* avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (28 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (28 * avg_sales)) > 0 and (closing_quantity - (28 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twentyeight', case when (closing_quantity - (28 * avg_sales)) <= 0 then
0 else (closing_quantity - (28 * avg_sales)) end as 'twentyeight_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (29 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(29 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (29 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (29 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (29 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (29 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (29 * avg_sales)) > 0 and (closing_quantity - (29 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twentynine', case when (closing_quantity - (29 * avg_sales)) <= 0 then 0
else (closing_quantity - (29 * avg_sales)) end as 'twentynine_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (30 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(30 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (30 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (30 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (30 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (30 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (30 * avg_sales)) > 0 and (closing_quantity - (30 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'thirty', case when (closing_quantity - (30 * avg_sales)) <= 0 then 0
else (closing_quantity - (30 * avg_sales)) end as 'thirty_qty' from (
select tr.sku_id, tr.node_id, round(sum(tr.sales) / 15, 2) as avg_sales,
t.closing_quantity, ifnull(bn.buffer_norm, (select buffer_norm from
buffer_norm use index(inx_sku_node_efdt) where effective_from < tr.transaction_date
and sku_id = tr.sku_id and node_id = tr.node_id order by effective_from desc limit
1)) as buffer_norm, ifnull(bn.is_default_zone,'Y') as is_default_zone,
ifnull(bn.yellow_zone,0) as yellow_zone, ifnull(bn.red_zone,0) as red_zone,
case when (t.closing_quantity + t.in_transit - t.pending_orders) <= 0 then 0
else (t.closing_quantity + t.in_transit - t.pending_orders) end as
'final_quantity' from transaction tr inner join transaction t
on t.transaction_date = ?param0 and t.sku_id = tr.sku_id and
t.node_id = tr.node_id left join buffer_norm bn use
index(inx_sku_node_efdt) on bn.sku_id = tr.sku_id and bn.node_id =
tr.node_id and bn.effective_from = ?param0 where tr.sku_id = ?
param1 and tr.node_id = ?param2 and tr.transaction_date > ?param3 group
by tr.sku_id, tr.node_id ) as sku_grid inner join sku s on
s.sku_id = sku_grid.sku_id inner join node n on n.node_id =
sku_grid.node_id inner join sku_category sc on sc.sku_category_id =
(select sku_category_id from sku_category where sku_id = sku_grid.sku_id limit 1)
inner join category c on c.category_id = sc.category_id]
2018-03-15 10:55:09,862-Adding file [ExcessInventoryHelper.xml] to list of watched
files.
2018-03-15 10:55:09,865-Adding file [StockoutAvailabilityChartHelper.xml] to list
of watched files.
2018-03-15 10:55:09,866-Adding file [InventoryTurnsHelper.xml] to list of watched
files.
2018-03-15 10:55:09,867-Statement Id: [SelectInventoryTurns] Prepared SQL: [select
rpl.transaction_date, rpl.category_id, rpl.category_name,
date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date, sum(1) as
count, sum(rpl.closing_quantity) as closing_quantity, sum(rpl.sales) as sales
from replenishment rpl where rpl.category_id is not null and
rpl.transaction_date = ?param0 group by rpl.transaction_date,
rpl.category_id]
2018-03-15 10:55:09,867-Statement Id: [SelectInventoryTurnsSKU] Prepared SQL:
[select rpl.transaction_date, rpl.category_id, rpl.sku_id, rpl.category_name,
date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date, sum(1) as
count, sum(rpl.closing_quantity) as closing_quantity, sum(rpl.sales) as sales
from replenishment rpl where rpl.category_id is not null and
rpl.transaction_date = ?param0 group by rpl.transaction_date,
rpl.category_id, rpl.sku_id]
2018-03-15 10:55:09,868-Adding file [CntQtyFillRateChartHelper.xml] to list of
watched files.
2018-03-15 10:55:09,868-Statement Id: [SelectCntQtyFillRateChart] Prepared SQL:
[select rpl.transaction_date, rpl.closing_stock_zone,
group_concat(distinct(rpl.sku_id) SEPARATOR ',') as str_sku_ids,
date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date,
sum(rpl.closing_quantity) as closing_quantity, sum(rpl.buffer_norm) as buffer_norm
from replenishment rpl where rpl.closing_stock_zone != "White" and
rpl.transaction_date = ?param0 group by rpl.transaction_date,
rpl.closing_stock_zone]
2018-03-15 10:55:09,868-Statement Id: [SelectCntQtyFillRateChartNode] Prepared SQL:
[select rpl.transaction_date, rpl.closing_stock_zone, rpl.node_id,
group_concat(distinct(rpl.sku_id) SEPARATOR ',') as str_sku_ids,
date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date,
sum(rpl.closing_quantity) as closing_quantity, sum(rpl.buffer_norm) as buffer_norm
from replenishment rpl where rpl.closing_stock_zone != "White" and
rpl.transaction_date = ?param0 group by rpl.transaction_date,
rpl.closing_stock_zone, rpl.node_id]
2018-03-15 10:55:09,868-Statement Id: [SelectCntQtyFillRateChartCategory] Prepared
SQL: [select rpl.transaction_date, rpl.closing_stock_zone, rpl.category_id,
group_concat(distinct(rpl.sku_id) SEPARATOR ',') as str_sku_ids,
date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date,
sum(rpl.closing_quantity) as closing_quantity, sum(rpl.buffer_norm) as buffer_norm
from replenishment rpl where rpl.closing_stock_zone != "White" and
rpl.transaction_date = ?param0 group by rpl.transaction_date,
rpl.closing_stock_zone, rpl.category_id]
2018-03-15 10:55:09,868-Statement Id: [SelectCntQtyFillRateChartSKU] Prepared SQL:
[select rpl.transaction_date, rpl.closing_stock_zone, rpl.sku_id,
group_concat(distinct(rpl.sku_id) SEPARATOR ',') as str_sku_ids,
date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date,
sum(rpl.closing_quantity) as closing_quantity, sum(rpl.buffer_norm) as buffer_norm
from replenishment rpl where rpl.closing_stock_zone != "White" and
rpl.transaction_date = ?param0 group by rpl.transaction_date,
rpl.closing_stock_zone, rpl.sku_id]
2018-03-15 10:55:09,869-Adding file [UserDataPermissionHelper.xml] to list of
watched files.
2018-03-15 10:55:09,869-Statement Id: [SelectDataPermissionByRole] Prepared SQL:
[select user_data_id, role_id, object_type, object_id, chk_state, created_by,
created_on from user_data_permissions WHERE role_id = ?param0 AND
object_type = ?param1]
2018-03-15 10:55:09,869-Statement Id: [InsertUserDataPermission] Prepared SQL:
[insert into user_data_permissions (role_id, object_type, object_id,
chk_state, created_by, created_on) values ( ?param0 , ?param1 , ?
param2 , ?param3 , ?param4 , NOW());]
2018-03-15 10:55:09,869-Statement Id: [InsertUserDataPermission.SelectKey] Prepared
SQL: [select last_insert_id() as value]
2018-03-15 10:55:09,869-Statement Id: [DeleteDataPermissionByRole] Prepared SQL:
[delete from user_data_permissions where role_id = ?param0]
2018-03-15 10:55:09,869-Adding file [RoleHelper.xml] to list of watched files.
2018-03-15 10:55:09,869-Statement Id: [SelectRoleNameDuplicate] Prepared SQL:
[select role_id,role_name,status,created_by,created_on,modified_by,modified_on
from role where role_name = ?param0 and role_id != ?param1]
2018-03-15 10:55:09,869-Statement Id: [InsertRole] Prepared SQL: [insert into role
(role_name,status,created_by,created_on) values ( ?param0 , ?
param1 , ?param2 , NOW());]
2018-03-15 10:55:09,869-Statement Id: [InsertRole.SelectKey] Prepared SQL: [select
last_insert_id() as value]
2018-03-15 10:55:09,869-Statement Id: [UpdateRole] Prepared SQL: [update role set
role_name = ?param0 , status = ?param1 , modified_by = ?param2 ,
modified_on = NOW() where role_id = ?param3]
2018-03-15 10:55:09,869-Adding file [BOMHelper.xml] to list of watched files.
2018-03-15 10:55:09,869-Statement Id: [SelectBOMDictionary] Prepared SQL: [SELECT
DISTINCT sk.sku_code, bm.sku_id FROM sku sk INNER JOIN bom bm ON bm.sku_id =
sk.sku_id]
2018-03-15 10:55:09,873-Adding file [Matrix1Helper.xml] to list of watched files.
2018-03-15 10:55:09,881-Statement Id: [SelectUserCheckAuthenticate]
PreparedStatement : [select user_id, user_name, first_name, middle_name,
last_name, email, mobile, description, password, status, approved, locked,
role_id, region_id, created_by, created_on, modified_by, modified_on from
user where user_name = ?param0 and password = ?param1 and status = 1]
2018-03-15 10:55:09,881-Statement Id: [SelectUserCheckAuthenticate] Parameters: [?
param0=[user_name,Admin], ?param1=[password,Ennovate789]]
2018-03-15 10:55:09,881-Statement Id: [SelectUserCheckAuthenticate] Types: [?
param0=[String, System.String], ?param1=[String, System.String]]
2018-03-15 10:55:09,882-Open Connection "17444050" to "MySQL, MySQL provider ver
6:5:4:0".
2018-03-15 10:55:09,885-Close Connection "17444050" to "MySQL, MySQL provider ver
6:5:4:0".
2018-03-15 10:55:09,890-Adding file [SqlMap.config] to list of watched files.
2018-03-15 10:55:09,891-Add property "provider" value "MySql6"
2018-03-15 10:55:09,891-Add property "datasource" value "localhost"
2018-03-15 10:55:09,891-Add property "database" value "scmplus"
2018-03-15 10:55:09,891-Add property "port" value "3306"
2018-03-15 10:55:09,891-Add property "userid" value "root"
2018-03-15 10:55:09,891-Add property "password" value "root"
2018-03-15 10:55:09,891-Add property "mapperResources" value
"./bin/iBatis/SqlMapper/"
2018-03-15 10:55:09,893-Adding file [CategoryHelper.xml] to list of watched files.
2018-03-15 10:55:09,894-Statement Id: [SelectCategoryByCode] Prepared SQL: [select
category_id, category_code, category_name, parent_id, status, created_by,
created_on, modified_by, modified_on from category where category_code = ?
param0]
2018-03-15 10:55:09,894-Statement Id: [SelectCategoryForDuplicate] Prepared SQL:
[select category_id, category_code, category_name, parent_id, status, created_by,
created_on, modified_by, modified_on from category where category_code = ?
param0 and category_name = ?param1 and parent_id = ?param2]
2018-03-15 10:55:09,894-Statement Id: [SelectCategoryBy] Prepared SQL: [select
category_id, parent_id, category_name, category_code, status, created_by,
created_on, modified_by, modified_on from category where ?param0 = ?
param1]
2018-03-15 10:55:09,894-Statement Id: [InsertCategory] Prepared SQL: [insert into
category (category_code, category_name, parent_id, status, created_by,
created_on) values ( ?param0 , ?param1 , ?param2 , ?param3 , ?
param4 , NOW());]
2018-03-15 10:55:09,894-Statement Id: [InsertCategory.SelectKey] Prepared SQL:
[select last_insert_id() as value]
2018-03-15 10:55:09,894-Statement Id: [UpdateCategory] Prepared SQL: [update
category set category_name = ?param0 , parent_id = ?param1 ,
status = ?param2 , modified_by = ?param3 , modified_on = NOW()
where category_code = ?param4]
2018-03-15 10:55:09,894-Statement Id: [DeleteCategory] Prepared SQL: [delete from
category where category_id = ?param0]
2018-03-15 10:55:09,894-Adding file [NodeHelper.xml] to list of watched files.
2018-03-15 10:55:09,894-Statement Id: [MapNode] Prepared SQL: [select node_id,
node_code, node_name, address_line1, address_line2, status from node where node_id
= ?param0 union all select '' as node_id, '' as node_code, '' as
node_name, '' as address_line1, '' as address_line2, null as status limit 1]
2018-03-15 10:55:09,894-Statement Id: [SelectNodeByCode] Prepared SQL: [select
node_id, node_code, node_name, parent_id, location_id, address_line1,
address_line2, latitude, longitude, status, created_by, created_on,
modified_by, modified_on from node where node_code = ?param0]
2018-03-15 10:55:09,894-Statement Id: [SelectNodeForDuplicate] Prepared SQL:
[select node_id, node_code, node_name, parent_id, location_id, address_line1,
address_line2, latitude, longitude, status, created_by, created_on,
modified_by, modified_on from node where node_code = ?param0 and node_name
= ?param1 and parent_id = ?param2]
2018-03-15 10:55:09,895-Statement Id: [InsertNode] Prepared SQL: [insert into node
(node_code, node_name, parent_id, location_id, address_line1, address_line2,
latitude, longitude, status, created_by, created_on) values
( ?param0 , ?param1 , ?param2 , ?param3 , ?param4 , ?param5 , ?param6 , ?
param7 , ?param8 , ?param9 , NOW());]
2018-03-15 10:55:09,895-Statement Id: [InsertNode.SelectKey] Prepared SQL: [select
last_insert_id() as value]
2018-03-15 10:55:09,895-Statement Id: [UpdateNode] Prepared SQL: [update node set
node_name = ?param0 , parent_id = ?param1 , location_id = ?
param2 , address_line1 = ?param3 , address_line2 = ?param4 ,
latitude = ?param5 , longitude = ?param6 , status = ?param7 ,
modified_by = ?param8 , modified_on = NOW() where node_code = ?
param9]
2018-03-15 10:55:09,895-Statement Id: [DeleteNode] Prepared SQL: [delete from node
where node_id = ?param0]
2018-03-15 10:55:09,895-Adding file [AttributeHelper.xml] to list of watched files.
2018-03-15 10:55:09,896-Statement Id: [SelectAttributeByCode] Prepared SQL: [select
attribute_id, attribute_code, attribute_name, data_type, optional, status,
created_by, created_on, modified_by, modified_on from attribute where
attribute_code = ?param0]
2018-03-15 10:55:09,896-Statement Id: [InsertAttribute] Prepared SQL: [insert into
attribute (attribute_code, attribute_name, data_type, optional, status,
created_by, created_on) values ( ?param0 , ?param1 , ?param2 , ?
param3 , ?param4 , ?param5 , NOW());]
2018-03-15 10:55:09,896-Statement Id: [InsertAttribute.SelectKey] Prepared SQL:
[select last_insert_id() as value]
2018-03-15 10:55:09,896-Statement Id: [UpdateAttribute] Prepared SQL: [update
attribute set attribute_name = ?param0 , data_type = ?param1 ,
optional = ?param2 , status = ?param3 , modified_by = ?param4 ,
modified_on = NOW() where attribute_id = ?param5]
2018-03-15 10:55:09,896-Statement Id: [DeleteAttribute] Prepared SQL: [delete from
attribute where attribute_id = ?param0]
2018-03-15 10:55:09,897-Adding file [SKUHelper.xml] to list of watched files.
2018-03-15 10:55:09,898-Statement Id: [MapSKU] Prepared SQL: [select * from sku
where sku_id = ?param0]
2018-03-15 10:55:09,898-Statement Id: [SelectSKUByCode] Prepared SQL: [select
sku_id, sku_code, sku_name, sku_description, status, created_by, created_on,
modified_by, modified_on from sku where sku_code = ?param0]
2018-03-15 10:55:09,898-Statement Id: [SelectSKUForDuplicate] Prepared SQL: [select
sku_id, sku_code, sku_name, sku_description, status, created_by, created_on,
modified_by, modified_on from sku where sku_code = ?param0 and sku_name =
?param1 and sku_description = ?param2]
2018-03-15 10:55:09,898-Statement Id: [SelectBatchInsertedSKU] Prepared SQL:
[select sku_id, sku_code, sku_name, sku_description, status, created_by,
created_on, modified_by, modified_on from sku where sku_id >= (SELECT
(AUTO_INCREMENT - ?param0 ) FROM information_schema.`TABLES` WHERE TABLE_NAME =
'sku' LIMIT 1)]
2018-03-15 10:55:09,898-Statement Id: [InsertSKU] Prepared SQL: [insert into sku
(sku_code, sku_name, sku_description, status, created_by, created_on) values
( ?param0 , ?param1 , ?param2 , ?param3 , ?param4 , NOW());]
2018-03-15 10:55:09,898-Statement Id: [InsertSKU.SelectKey] Prepared SQL: [select
last_insert_id() as value]
2018-03-15 10:55:09,898-Statement Id: [UpdateSKU] Prepared SQL: [update sku set
sku_name = ?param0 , sku_description = ?param1 , status = ?
param2 , modified_by = ?param3 , modified_on = NOW() where
sku_id = ?param4]
2018-03-15 10:55:09,898-Statement Id: [DeleteSKU] Prepared SQL: [delete from sku
where sku_id = ?param0]
2018-03-15 10:55:09,898-Adding file [SKUAttributeHelper.xml] to list of watched
files.
2018-03-15 10:55:09,899-Statement Id: [SelectSKUAttributeMappingBySKUAttribute]
Prepared SQL: [select sku_attribute_mapping_id, sku_id, attribute_id, value,
created_by, created_on from sku_attribute_mapping where sku_id = ?param0
and attribute_id = ?param1]
2018-03-15 10:55:09,899-Statement Id: [SelectSKUAttributeMappingBySKU] Prepared
SQL: [select sku_attribute_mapping_id, sku_id, attribute_id, value, created_by,
created_on from sku_attribute_mapping where sku_id = ?param0]
2018-03-15 10:55:09,899-Statement Id: [InsertSKUAttributeMapping] Prepared SQL:
[insert into sku_attribute_mapping (sku_id, attribute_id, value, created_by,
created_on) values ( ?param0 , ?param1 , ?param2 , ?param3 ,
NOW());]
2018-03-15 10:55:09,899-Statement Id: [InsertSKUAttributeMapping.SelectKey]
Prepared SQL: [select last_insert_id() as value]
2018-03-15 10:55:09,899-Statement Id: [UpdateSKUAttributeMapping] Prepared SQL:
[update sku_attribute_mapping set value = ?param0 , where
sku_attribute_mapping_id = ?param1]
2018-03-15 10:55:09,899-Statement Id: [DeleteSKUAttributeMapping] Prepared SQL:
[delete from sku_attribute_mapping where sku_id = ?param0 and attribute_id
= ?param1]
2018-03-15 10:55:09,899-Adding file [NodeSKUHelper.xml] to list of watched files.
2018-03-15 10:55:09,900-Statement Id: [SelectNodeSKUMappingByNodeSKU] Prepared SQL:
[select node_sku_mapping_id, receiver_node_id, sku_id, supplier_node_id,
effective_date, created_by, created_on from node_sku_mapping where sku_id =
?param0 and receiver_node_id = ?param1 and supplier_node_id = ?param2 and
effective_date = ?param3]
2018-03-15 10:55:09,900-Statement Id: [selectSKU] Prepared SQL: [select * from sku
where sku_id = ?param0]
2018-03-15 10:55:09,900-Statement Id: [selectNode] Prepared SQL: [select * from
node where node_id = ?param0]
2018-03-15 10:55:09,900-Statement Id: [InsertNodeSKUMapping] Prepared SQL: [insert
into node_sku_mapping (receiver_node_id, sku_id, supplier_node_id,
effective_date, created_by, created_on) values ( ?param0 , ?param1 ,
?param2 , date_format( ?param3 , "%Y-%c-%e %H:%i:%s"), ?param4 , NOW());]
2018-03-15 10:55:09,900-Statement Id: [InsertNodeSKUMapping.SelectKey] Prepared
SQL: [select last_insert_id() as value]
2018-03-15 10:55:09,900-Statement Id: [DeleteNodeSKUMapping] Prepared SQL: [delete
from node_sku_mapping where node_sku_mapping_id = ?param0]
2018-03-15 10:55:09,900-Adding file [BufferNormHelper.xml] to list of watched
files.
2018-03-15 10:55:09,901-Statement Id: [MapBufferNorm] Prepared SQL: [select
buffer_norm_id, sku_id, node_id, buffer_norm, olt, plt, tlt, rlt,
max_sales_per_day, safety_factor, unit_selling_price, unit_purchase_price,
moq, eoq, effective_from, created_by, created_on, modified_by, modified_on
from buffer_norm where buffer_norm_id = ?param0 union all select '' as
buffer_norm_id, '' as sku_id, '' as node_id, 0 as buffer_norm, 0 as olt, 0 as plt,
0 as tlt, 0 as rlt, 0 as max_sales_per_day, 0 as safety_factor, 0 as
unit_selling_price, 0 as unit_purchase_price, 0 as moq, 0 as eoq, '' as
effective_from, null as created_by, null as created_on, null as modified_by, null
as modified_on limit 1]
2018-03-15 10:55:09,902-Statement Id: [SelectBufferNormBySKUNode] Prepared SQL:
[select buffer_norm_id, sku_id, node_id, buffer_norm, olt, plt, tlt, rlt,
max_sales_per_day, safety_factor, unit_selling_price, unit_purchase_price,
moq, eoq, effective_from, created_by, created_on, modified_by,
modified_on,IFNULL(is_default_zone,'Y') AS is_default_zone, IFNULL(red_zone,0) AS
red_zone, IFNULL(yellow_zone,0) AS yellow_zone from buffer_norm where sku_id
= ?param0 and node_id = ?param1 and effective_from = ?param2]
2018-03-15 10:55:09,902-Statement Id: [SelectBatchInsertedBufferNorm] Prepared SQL:
[select b.buffer_norm_id, b.sku_id, b.node_id, b.buffer_norm, b.olt, b.plt, b.tlt,
b.rlt, b.max_sales_per_day, b.safety_factor, b.unit_selling_price,
b.unit_purchase_price, b.moq, b.eoq, b.effective_from, b.created_by, b.created_on,
b.modified_by, b.modified_on, b.identifier, b.is_default_zone, b.red_zone,
b.yellow_zone from buffer_norm b where identifier = ?param0]
2018-03-15 10:55:09,902-Statement Id: [InsertBufferNorm] Prepared SQL: [insert into
buffer_norm (sku_id, node_id, buffer_norm, olt, plt, tlt, rlt,
max_sales_per_day, safety_factor, unit_selling_price, unit_purchase_price,
moq, eoq, effective_from, created_by, created_on) values ( ?param0 ,
?param1 , ?param2 , ?param3 , ?param4 , ?param5 , ?param6 , ?param7 , ?
param8 , ?param9 , ?param10 , ?param11 , ?param12 , date_format( ?
param13 , "%Y-%c-%e %H:%i:%s"), ?param14 , NOW());]
2018-03-15 10:55:09,902-Statement Id: [InsertBufferNorm.SelectKey] Prepared SQL:
[select last_insert_id() as value]
2018-03-15 10:55:09,902-Statement Id: [UpdateBufferNorm] Prepared SQL: [update
buffer_norm set sku_id = ?param0 , node_id = ?param1 ,
buffer_norm = ?param2 , olt = ?param3 , plt = ?param4 , tlt
= ?param5 , rlt = ?param6 , max_sales_per_day = ?param7 ,
safety_factor = ?param8 , unit_selling_price = ?param9 ,
unit_purchase_price = ?param10 , moq = ?param11 , eoq = ?param12 ,
effective_from = date_format( ?param13 , "%Y-%c-%e %H:%i:%s"), modified_by =
?param14 , modified_on = NOW() where buffer_norm_id = ?param15]
2018-03-15 10:55:09,902-Statement Id: [DeleteBufferNorm] Prepared SQL: [delete from
buffer_norm where buffer_norm_id = ?param0]
2018-03-15 10:55:09,903-Adding file [TransactionHelper.xml] to list of watched
files.
2018-03-15 10:55:09,904-Statement Id: [SelectTransactionForDuplicate] Prepared SQL:
[select transaction_id, sku_id, node_id, supply_node_id, transaction_date, grn,
sales, closing_quantity, in_transit, inst_hold, quality_hold, qa_hold,
pending_orders, orders_in_hand, transport_mode, db_sync, mongo_sync, created_by,
created_on, open_stock_transfer_order, open_planned_order,
open_purchase_request, open_production_order, open_purchase_order, field1, field2,
field3, field4, field5, field6, field7, field8, field9, field10 from
transaction where sku_id = ?param0 and node_id = ?param1 and transaction_date =
?param2]
2018-03-15 10:55:09,905-Statement Id: [SelectReplenishmentList] Prepared SQL:
[select tr.transaction_id, tr.transaction_date,
date_format(tr.transaction_date,'%d/%m/%Y') as display_date,
date_format(tr.transaction_date,'%Y%m%d') as transfilter_date, tr.sku_id,
s.sku_code, s.sku_name, tr.node_id, n.node_code, n.node_name, sc.category_id,
cat.category_code, cat.category_name, ifnull(bn.buffer_norm, 0) as
buffer_norm, ifnull(tr.closing_quantity, 0) as closing_quantity,
ifnull(tr.in_transit, 0) as in_transit, ifnull(tr.sales, 0) as sales,
ifnull(tr.inst_hold, 0) as inst_hold, ifnull(tr.quality_hold, 0) as quality_hold,
ifnull(tr.qa_hold, 0) as qa_hold, ifnull(tr.pending_orders, 0) as
pending_orders, ifnull(tr.orders_in_hand, 0) as orders_in_hand,
ifnull(tr.transport_mode, '') as transport_mode, nsm.supplier_node_id as
supply_node_id, sn.node_name as supply_node_name, sn.node_code as
supply_node_code, ifnull(str.closing_quantity, 0) as supplying_quantity,
ifnull(sbn.buffer_norm, 0) as supplying_buffer_norm,
round(ifnull(bn.buffer_norm, 0),2) as 'green_zone_qty', CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2)
END AS 'yellow_zone_qty', CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END as 'red_zone_qty', case
when ifnull(bn.buffer_norm, 0) = 0 then 'White' when
(ifnull(tr.closing_quantity, 0) <= 0 and ifnull(bn.buffer_norm, 0) > 0) then
'Black' when (ifnull(tr.closing_quantity, 0) > ifnull(bn.buffer_norm, 0) and
ifnull(bn.buffer_norm, 0) > 0) then 'Blue' when (ifnull(tr.closing_quantity,
0) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) and ifnull(tr.closing_quantity,
0) <= ifnull(bn.buffer_norm, 0) and ifnull(bn.buffer_norm, 0) > 0) then 'Green'
when (ifnull(tr.closing_quantity, 0) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) and ifnull(tr.closing_quantity, 0) <=
(CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) and ifnull(bn.buffer_norm, 0) >
0) then 'Yellow' when (ifnull(tr.closing_quantity, 0) > 0 and
ifnull(tr.closing_quantity, 0) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) and ifnull(bn.buffer_norm, 0) > 0) then
'Red' end as 'closing_stock_zone', case when
ifnull(bn.buffer_norm, 0) = 0 then 6 when (ifnull(tr.closing_quantity, 0) <=
0 and ifnull(bn.buffer_norm, 0) > 0) then 1 when
(ifnull(tr.closing_quantity, 0) > ifnull(bn.buffer_norm, 0) and
ifnull(bn.buffer_norm, 0) > 0) then 2 when (ifnull(tr.closing_quantity, 0) >
(CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) and ifnull(tr.closing_quantity,
0) <= ifnull(bn.buffer_norm, 0) and ifnull(bn.buffer_norm, 0) > 0) then 4
when (ifnull(tr.closing_quantity, 0) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) and ifnull(tr.closing_quantity, 0) <=
(CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) and ifnull(bn.buffer_norm, 0) >
0) then 3 when (ifnull(tr.closing_quantity, 0) > 0 and
ifnull(tr.closing_quantity, 0) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) and ifnull(bn.buffer_norm, 0) > 0) then
5 end as 'closing_stock_zone_sort', case when
ifnull(bn.buffer_norm, 0) = 0 then 'White' when
((ifnull(tr.closing_quantity, 0) + ifnull(tr.in_transit, 0) -
ifnull(tr.pending_orders, 0)) <= 0 and ifnull(bn.buffer_norm, 0) > 0) then 'Black'
when ((ifnull(tr.closing_quantity, 0) + ifnull(tr.in_transit, 0) -
ifnull(tr.pending_orders, 0)) > ifnull(bn.buffer_norm, 0) and
ifnull(bn.buffer_norm, 0) > 0) then 'Blue' when
((ifnull(tr.closing_quantity, 0) + ifnull(tr.in_transit, 0) -
ifnull(tr.pending_orders, 0)) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) and
(ifnull(tr.closing_quantity, 0) + tr.in_transit - tr.pending_orders) <=
ifnull(bn.buffer_norm, 0) and ifnull(bn.buffer_norm, 0) > 0) then 'Green'
when ((ifnull(tr.closing_quantity, 0) + ifnull(tr.in_transit, 0) -
ifnull(tr.pending_orders, 0)) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) and (tr.closing_quantity +
tr.in_transit - tr.pending_orders) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2)
ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) and ifnull(bn.buffer_norm,
0) > 0) then 'Yellow' when ((ifnull(tr.closing_quantity, 0) +
ifnull(tr.in_transit, 0) - ifnull(tr.pending_orders, 0)) > 0 and
(ifnull(tr.closing_quantity, 0) + tr.in_transit - tr.pending_orders) <= (CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) and
ifnull(bn.buffer_norm, 0) > 0) then 'Red' end as 'in_transit_zone',
case when ifnull(bn.buffer_norm, 0) = 0 then 6 when
((ifnull(tr.closing_quantity, 0) + ifnull(tr.in_transit, 0) -
ifnull(tr.pending_orders, 0)) <= 0 and ifnull(bn.buffer_norm, 0) > 0) then 1
when ((ifnull(tr.closing_quantity, 0) + ifnull(tr.in_transit, 0) -
ifnull(tr.pending_orders, 0)) > ifnull(bn.buffer_norm, 0) and
ifnull(bn.buffer_norm, 0) > 0) then 2 when ((ifnull(tr.closing_quantity, 0)
+ ifnull(tr.in_transit, 0) - ifnull(tr.pending_orders, 0)) > (CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2)
END) and (ifnull(tr.closing_quantity, 0) + tr.in_transit - tr.pending_orders) <=
ifnull(bn.buffer_norm, 0) and ifnull(bn.buffer_norm, 0) > 0) then 4 when
((ifnull(tr.closing_quantity, 0) + ifnull(tr.in_transit, 0) -
ifnull(tr.pending_orders, 0)) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) and (ifnull(tr.closing_quantity, 0) +
tr.in_transit - tr.pending_orders) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2)
ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) and ifnull(bn.buffer_norm,
0) > 0) then 3 when ((ifnull(tr.closing_quantity, 0) + ifnull(tr.in_transit,
0) - ifnull(tr.pending_orders, 0)) > 0 and (ifnull(tr.closing_quantity, 0) +
tr.in_transit - tr.pending_orders) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) and ifnull(bn.buffer_norm, 0) > 0) then
5 end as 'in_transit_zone_sort', case when
ifnull(sbn.buffer_norm, 0) = 0 then 'White' when
(ifnull(str.closing_quantity, 0) <= 0 and ifnull(sbn.buffer_norm, 0) > 0) then
'Black' when (ifnull(str.closing_quantity, 0) > ifnull(sbn.buffer_norm, 0)
and ifnull(sbn.buffer_norm, 0) > 0) then 'Blue' when
(ifnull(str.closing_quantity, 0) > (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) and
ifnull(str.closing_quantity, 0) <= ifnull(sbn.buffer_norm, 0) and
ifnull(sbn.buffer_norm, 0) > 0) then 'Green' when
(ifnull(str.closing_quantity, 0) > (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) and ifnull(str.closing_quantity, 0) <=
(CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) and ifnull(sbn.buffer_norm, 0)
> 0) then 'Yellow' when (ifnull(str.closing_quantity, 0) > 0 and
ifnull(str.closing_quantity, 0) <= (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) and ifnull(sbn.buffer_norm, 0) > 0)
then 'Red' end as 'supplying_node_zone', case when
ifnull(sbn.buffer_norm, 0) = 0 then 6 when (ifnull(str.closing_quantity, 0)
<= 0 and ifnull(sbn.buffer_norm, 0) > 0) then 1 when
(ifnull(str.closing_quantity, 0) > ifnull(sbn.buffer_norm, 0) and
ifnull(sbn.buffer_norm, 0) > 0) then 2 when (ifnull(str.closing_quantity,
0) > (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) and
ifnull(str.closing_quantity, 0) <= ifnull(sbn.buffer_norm, 0) and
ifnull(sbn.buffer_norm, 0) > 0) then 4 when (ifnull(str.closing_quantity, 0)
> (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) and ifnull(str.closing_quantity, 0) <=
(CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) and ifnull(sbn.buffer_norm, 0)
> 0) then 3 when (ifnull(str.closing_quantity, 0) > 0 and
ifnull(str.closing_quantity, 0) <= (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) and ifnull(sbn.buffer_norm, 0) > 0)
then 5 end as 'supplying_node_zone_sort', case when
((ifnull(bn.buffer_norm, 0) - ifnull(tr.closing_quantity, 0) -
ifnull(tr.in_transit, 0)) + ifnull(tr.pending_orders, 0)) -
(ifnull(tr.open_planned_order, 0) + ifnull(tr.open_purchase_request, 0) +
ifnull(tr.open_production_order, 0) + ifnull(tr.open_purchase_order, 0)) <= 0 then
0 else ((ifnull(bn.buffer_norm, 0) - ifnull(tr.closing_quantity, 0) -
ifnull(tr.in_transit, 0)) + ifnull(tr.pending_orders, 0)) -
(ifnull(tr.open_planned_order, 0) + ifnull(tr.open_purchase_request, 0) +
ifnull(tr.open_production_order, 0) + ifnull(tr.open_purchase_order, 0)) end
as 'replenishment_quantity', case when (ifnull(tr.closing_quantity,
0) + ifnull(tr.in_transit, 0) + ifnull(tr.open_planned_order, 0) +
ifnull(tr.open_purchase_request, 0) + ifnull(tr.open_production_order, 0) +
ifnull(tr.open_purchase_order, 0) ) - ifnull(tr.pending_orders, 0) <= 0 then 0
else (ifnull(tr.closing_quantity, 0) + ifnull(tr.in_transit, 0) +
ifnull(tr.open_planned_order, 0) + ifnull(tr.open_purchase_request, 0) +
ifnull(tr.open_production_order, 0) + ifnull(tr.open_purchase_order, 0) ) -
ifnull(tr.pending_orders, 0) end as 'final_quantity', case
when ifnull(bn.buffer_norm, 0) = 0 then 0 else (CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END)
end as 'mrq', (select count(1) from transaction_comment where
transaction_id = tr.transaction_id) as 'transaction_comment',
ifnull(tr.open_stock_transfer_order, 0) as open_stock_transfer_order,
ifnull(tr.open_planned_order, 0) as open_planned_order,
ifnull(tr.open_purchase_request, 0) as open_purchase_request,
ifnull(tr.open_production_order, 0) as open_production_order,
ifnull(tr.open_purchase_order, 0) as open_purchase_order, tr.field1,
tr.field2, tr.field3, tr.field4, tr.field5, tr.field6, tr.field7, tr.field8,
tr.field9, tr.field10 from ( select transaction_id from
transaction where transaction_date = ?param0 limit ?param1 , ?
param2 ) otr join transaction tr on tr.transaction_id
= otr.transaction_id left join buffer_norm bn on bn.sku_id =
tr.sku_id and bn.node_id = tr.node_id and bn.effective_from = (
select max(effective_from) from buffer_norm where effective_from <=
tr.transaction_date and sku_id = tr.sku_id and node_id = tr.node_id)
left join sku s on s.sku_id = tr.sku_id left join sku_category sc
on sc.sku_id = tr.sku_id left join category cat on cat.category_id
= sc.category_id left join node n on n.node_id = tr.node_id
left join node_sku_mapping nsm on nsm.receiver_node_id = tr.node_id
and nsm.sku_id = tr.sku_id and nsm.effective_date = ( select
max(effective_date) from node_sku_mapping where effective_date <=
tr.transaction_date and sku_id = tr.sku_id and receiver_node_id =
tr.node_id) left join node sn on sn.node_id = nsm.supplier_node_id
left join buffer_norm sbn on sbn.sku_id = nsm.sku_id and sbn.node_id
= nsm.supplier_node_id and sbn.effective_from = ( select
max(effective_from) from buffer_norm where effective_from <=
tr.transaction_date and sku_id = tr.sku_id and node_id = tr.node_id)
left join ( select transaction_id, sku_id, node_id, closing_quantity
from transaction where transaction_date = ?param0 ) str
on str.sku_id = nsm.sku_id and str.node_id = nsm.supplier_node_id and
str.transaction_id = otr.transaction_id order by tr.transaction_id]
2018-03-15 10:55:09,905-Statement Id: [MapTransaction] Prepared SQL: [select * from
transaction where transaction_id = ?param0]
2018-03-15 10:55:09,905-Statement Id: [SelectMaxTransactionDate] Prepared SQL:
[select date_sub(max(transaction_date), interval 15 day) as avg_date,
max(transaction_date) as transaction_date from transaction]
2018-03-15 10:55:09,905-Statement Id: [SelectSKUNodeGroup] Prepared SQL: [select
sku_id, node_id from transaction group by sku_id, node_id]
2018-03-15 10:55:09,905-Statement Id: [SelectTransactionBySKUNode] Prepared SQL:
[select transaction_id, sku_id, node_id, supply_node_id, transaction_date, grn,
sales, closing_quantity, in_transit, inst_hold, quality_hold, qa_hold,
pending_orders, orders_in_hand, transport_mode, db_sync, mongo_sync, created_by,
created_on, open_stock_transfer_order, open_planned_order,
open_purchase_request, open_production_order, open_purchase_order, field1, field2,
field3, field4, field5, field6, field7, field8, field9, field10 from
transaction where sku_id = ?param0 and node_id = ?param1]
2018-03-15 10:55:09,905-Statement Id: [SelectTransactionByDate] Prepared SQL:
[select transaction_id, sku_id, node_id, supply_node_id, transaction_date, grn,
sales, closing_quantity, in_transit, inst_hold, quality_hold, qa_hold,
pending_orders, orders_in_hand, transport_mode, db_sync, mongo_sync, created_by,
created_on, open_stock_transfer_order, open_planned_order,
open_purchase_request, open_production_order, open_purchase_order, field1, field2,
field3, field4, field5, field6, field7, field8, field9, field10 from
transaction where transaction_date = ?param0]
2018-03-15 10:55:09,905-Statement Id: [SelectTransactionDates] Prepared SQL:
[select DATE_FORMAT(transaction_date, '%Y-%m-%d %H:%i:%s') as transaction_date from
transaction group by transaction_date asc limit ?param0]
2018-03-15 10:55:09,905-Statement Id: [SelectBNCalculationTransactionDates]
Prepared SQL: [select DATE_FORMAT(transaction_date, '%Y-%m-%d %H:%i:%s') as
transaction_date from transaction where transaction_date >= ?param0
group by transaction_date asc]
2018-03-15 10:55:09,905-Statement Id: [SelectTransactionIdsForBNCalculation]
Prepared SQL: [select transaction_id from transaction where transaction_date
= ?param0 and sku_id = ?param1 and node_id = ?param2]
2018-03-15 10:55:09,905-Statement Id: [SelectBatchInsertedTransactionID] Prepared
SQL: [select transaction_id, identifier from transaction where identifier = ?
param0]
2018-03-15 10:55:09,905-Statement Id: [SelectUpdateTransactionImport] Prepared SQL:
[select DISTINCT transaction_id from update_transaction WHERE identifier = ?
param0]
2018-03-15 10:55:09,906-Statement Id: [SelectClosingStockForTransactionDate]
Prepared SQL: [SELECT transaction_date, closing_quantity, sales, grn from
transaction WHERE transaction_date < ?param0 AND sku_id = ?param1
AND node_id = ?param2 ORDER BY transaction_date DESC LIMIT 1]
2018-03-15 10:55:09,906-Statement Id: [InsertTransaction] Prepared SQL: [insert
into transaction (sku_id, node_id, supply_node_id, transaction_date, grn,
sales, closing_quantity, in_transit, inst_hold, quality_hold, qa_hold,
pending_orders, orders_in_hand, transport_mode, db_sync, mongo_sync, created_by,
created_on, open_stock_transfer_order, open_planned_order,
open_purchase_request, open_production_order, open_purchase_order, field1, field2,
field3, field4, field5, field6, field7, field8, field9, field10) values
( ?param0 , ?param1 , ?param2 , ?param3 , ?param4 , ?param5 , ?param6 , ?
param7 , ?param8 , ?param9 , ?param10 , ?param11 , ?param12 , ?param13
, 0, 0, ?param14 , NOW(), ?param15 , ?param16 , ?param17 , ?
param18 , ?param19 , ?param20 , ?param21 , ?param22 , ?param23 , ?param24 ,
?param25 , ?param26 , ?param27 , ?param28 , ?param29 );]
2018-03-15 10:55:09,906-Statement Id: [InsertTransaction.SelectKey] Prepared SQL:
[select last_insert_id() as value]
2018-03-15 10:55:09,906-Statement Id: [InsertTransactionComment] Prepared SQL:
[insert into transaction_comment (transaction_id, sku_id, node_id, comment,
reason, created_by, created_on) values ( ?param0 , ?param1 , ?
param2 , ?param3 , ?param4 , ?param5 , NOW());]
2018-03-15 10:55:09,906-Statement Id: [InsertTransactionComment.SelectKey] Prepared
SQL: [select last_insert_id() as value]
2018-03-15 10:55:09,907-Statement Id: [UpdateTransaction] Prepared SQL: [update
transaction set sku_id = ?param0 , node_id = ?param1 ,
supply_node_id = ?param2 , transaction_date = ?param3 , grn = ?
param4 , sales = ?param5 , closing_quantity = ?param6 ,
in_transit = ?param7 , inst_hold = ?param8 , quality_hold = ?
param9 , qa_hold = ?param10 , pending_orders = ?param11 ,
orders_in_hand = ?param12 , transport_mode = ?param13 , db_sync
= ?param14 , mongo_sync = ?param15 where transaction_id = ?
param16]
2018-03-15 10:55:09,907-Statement Id: [DeleteUpdatesTransaction] Prepared SQL:
[delete from update_transaction WHERE identifier = ?param0]
2018-03-15 10:55:09,907-Adding file [SKUCategoryHelper.xml] to list of watched
files.
2018-03-15 10:55:09,908-Statement Id: [SelectSKUCategoryBySKUCategory] Prepared
SQL: [select sku_category_id, sku_id, category_id, created_by, created_on
from sku_category where sku_id = ?param0 and category_id = ?param1]
2018-03-15 10:55:09,908-Statement Id: [InsertSKUCategory] Prepared SQL: [insert
into sku_category (sku_id, category_id, created_by, created_on)
values ( ?param0 , ?param1 , ?param2 , NOW());]
2018-03-15 10:55:09,908-Statement Id: [InsertSKUCategory.SelectKey] Prepared SQL:
[select last_insert_id() as value]
2018-03-15 10:55:09,908-Adding file [SKUChartHelper.xml] to list of watched files.
2018-03-15 10:55:09,908-Statement Id: [SelectSKUChart] Prepared SQL: [select
rpl.transaction_date, date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date,
sum(rpl.closing_quantity) as closing_quantity, sum(rpl.red_zone_qty) as
red_zone_qty, sum(rpl.yellow_zone_qty) as yellow_zone_qty,
sum(rpl.green_zone_qty) as green_zone_qty, sum(rpl.in_transit) as in_transit,
sum(rpl.sales) as sales, count(distinct(rpl.sku_id)) as total_sku_count,
(select count(distinct(sku_id)) from replenishment where closing_stock_zone_sort =
2 and transaction_date = rpl.transaction_date) as blue_sku_count, (select
count(distinct(sku_id)) from replenishment where (closing_stock_zone_sort = 1 or
closing_stock_zone_sort = 5) and transaction_date = rpl.transaction_date) as
rb_sku_count from replenishment rpl where rpl.transaction_date = ?
param0 group by rpl.transaction_date]
2018-03-15 10:55:09,908-Statement Id: [SelectSKUChartNode] Prepared SQL: [select
rpl.transaction_date, date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date, rpl.node_id,
sum(rpl.closing_quantity) as closing_quantity, sum(rpl.red_zone_qty) as
red_zone_qty, sum(rpl.yellow_zone_qty) as yellow_zone_qty,
sum(rpl.green_zone_qty) as green_zone_qty, sum(rpl.in_transit) as in_transit,
sum(rpl.sales) as sales, count(distinct(rpl.sku_id)) as total_sku_count,
ifnull((select count(distinct(sku_id)) from replenishment where
closing_stock_zone_sort = 2 and transaction_date = rpl.transaction_date and node_id
= rpl.node_id), 0) as blue_sku_count, ifnull((select count(distinct(sku_id))
from replenishment where (closing_stock_zone_sort = 1 or closing_stock_zone_sort =
5) and transaction_date = rpl.transaction_date and node_id = rpl.node_id), 0) as
rb_sku_count from replenishment rpl where rpl.transaction_date = ?
param0 group by rpl.transaction_date, rpl.node_id]
2018-03-15 10:55:09,909-Statement Id: [SelectSKUChartCategory] Prepared SQL:
[select rpl.transaction_date, date_format(rpl.transaction_date,'%d/%m/%Y') as
display_date, date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date,
rpl.category_id, sum(rpl.closing_quantity) as closing_quantity,
sum(rpl.red_zone_qty) as red_zone_qty, sum(rpl.yellow_zone_qty) as yellow_zone_qty,
sum(rpl.green_zone_qty) as green_zone_qty, sum(rpl.in_transit) as in_transit,
sum(rpl.sales) as sales, count(distinct(rpl.sku_id)) as total_sku_count,
ifnull((select count(distinct(sku_id)) from replenishment where
closing_stock_zone_sort = 2 and transaction_date = rpl.transaction_date and
category_id = rpl.category_id), 0) as blue_sku_count, ifnull((select
count(distinct(sku_id)) from replenishment where (closing_stock_zone_sort = 1 or
closing_stock_zone_sort = 5) and transaction_date = rpl.transaction_date and
category_id = rpl.category_id), 0) as rb_sku_count from replenishment rpl
where rpl.transaction_date = ?param0 and rpl.category_id is not null
group by rpl.transaction_date, rpl.category_id]
2018-03-15 10:55:09,909-Statement Id: [SelectSKUChartSKU] Prepared SQL: [select
rpl.transaction_date, date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date, rpl.sku_id,
sum(rpl.closing_quantity) as closing_quantity, sum(rpl.red_zone_qty) as
red_zone_qty, sum(rpl.yellow_zone_qty) as yellow_zone_qty,
sum(rpl.green_zone_qty) as green_zone_qty, sum(rpl.in_transit) as in_transit,
sum(rpl.sales) as sales, count(distinct(rpl.sku_id)) as total_sku_count,
ifnull((select count(distinct(sku_id)) from replenishment where
closing_stock_zone_sort = 2 and transaction_date = rpl.transaction_date and sku_id
= rpl.sku_id), 0) as blue_sku_count, ifnull((select count(distinct(sku_id))
from replenishment where (closing_stock_zone_sort = 1 or closing_stock_zone_sort =
5) and transaction_date = rpl.transaction_date and sku_id = rpl.sku_id), 0) as
rb_sku_count from replenishment rpl use index(inx_sku_chart_s) where
rpl.transaction_date = ?param0 group by rpl.transaction_date, rpl.sku_id]
2018-03-15 10:55:09,909-Adding file [ImportExportLogHelper.xml] to list of watched
files.
2018-03-15 10:55:09,910-Statement Id: [SelectImportExportLogByType] Prepared SQL:
[select import_export_log_id, reference_date, reference_type, reference_title,
type, log_file, status, status_text, comment, created_by, created_on from
import_export_log where type = ?param0 order by reference_date desc]
2018-03-15 10:55:09,910-Statement Id: [InsertImportExportLog] Prepared SQL: [insert
into import_export_log (reference_date, reference_type, reference_title,
type, log_file, status, status_text, comment, created_by, created_on) values
(date_format( ?param0 , "%Y-%c-%e %H:%i:%s"), ?param1 , ?param2 , ?param3 , ?
param4 , ?param5 , ?param6 , ?param7 , ?param8 , NOW() );]
2018-03-15 10:55:09,910-Statement Id: [InsertImportExportLog.SelectKey] Prepared
SQL: [select last_insert_id() as value]
2018-03-15 10:55:09,910-Statement Id: [UpdateImportExportLog] Prepared SQL: [update
import_export_log set reference_date = date_format( ?param0 , "%Y-%c-%e %H:
%i:%s"), reference_type = ?param1 , reference_title = ?param2 ,
type = ?param3 , log_file = ?param4 , status = ?param5 ,
status_text = ?param6 , comment = ?param7 where
import_export_log_id = ?param8]
2018-03-15 10:55:09,910-Statement Id: [DeleteImportExportLog] Prepared SQL: [delete
from import_export_log where import_export_log_id = ?param0]
2018-03-15 10:55:09,910-Adding file [DynamicBufferManagementHelper.xml] to list of
watched files.
2018-03-15 10:55:09,911-Statement Id: [InsertDynamicBufferManagement] Prepared SQL:
[insert into dynamic_buffer_management (activate_auto_dbm,
excess_inv_occ_count, excess_inv_decrease_per, excess_inv_wait_cycle,
stockout_inv_occ_count, stockout_inv_decrease_per, stockout_inv_wait_cycle,
override_sku_location_dbm, activate_auto_dcm, red_percentage,
yellow_percentage, green_percentage, created_by, created_on) values (
?param0 , ?param1 , ?param2 , ?param3 , ?param4 , ?param5 , ?param6 ,
?param7 , ?param8 , ?param9 , ?param10 , ?param11 , ?param12 , NOW());]
2018-03-15 10:55:09,911-Statement Id: [InsertDynamicBufferManagement.SelectKey]
Prepared SQL: [select last_insert_id() as value]
2018-03-15 10:55:09,911-Statement Id: [UpdateDynamicBufferManagement] Prepared SQL:
[update dynamic_buffer_management set activate_auto_dbm = ?param0 ,
excess_inv_occ_count = ?param1 , excess_inv_decrease_per = ?param2 ,
excess_inv_wait_cycle = ?param3 , stockout_inv_occ_count = ?param4 ,
stockout_inv_decrease_per = ?param5 , stockout_inv_wait_cycle = ?param6 ,
override_sku_location_dbm = ?param7 , activate_auto_dcm = ?param8 ,
red_percentage = ?param9 , yellow_percentage = ?param10 ,
green_percentage = ?param11 , modified_by = ?param12 , modified_on
= NOW() where dynamic_buffer_management_id = ?param13]
2018-03-15 10:55:09,911-Adding file [ReplenishmentHelper.xml] to list of watched
files.
2018-03-15 10:55:09,912-Statement Id: [SelectReplenishmentData] Prepared SQL:
[select transaction_id, transaction_date, display_date, transfilter_date, sku_id,
sku_code, sku_name, node_id, node_code, node_name, category_id,
category_code, category_name, buffer_norm, grn, closing_quantity, in_transit,
sales, inst_hold, quality_hold, qa_hold, pending_orders, orders_in_hand,
transport_mode, supply_node_id, supply_node_name, supply_node_code,
supplying_quantity, supplying_buffer_norm, green_zone_qty, yellow_zone_qty,
red_zone_qty, closing_stock_zone, closing_stock_zone_sort, in_transit_zone,
in_transit_zone_sort, supplying_node_zone, supplying_node_zone_sort,
replenishment_quantity, final_quantity, mrq, transaction_comment,
open_stock_transfer_order, open_planned_order, open_purchase_request,
open_production_order, open_purchase_order, field1, field2, field3, field4,
field5, field6, field7, field8, field9, field10, mtd_sales, mtd_grn from
replenishment where transaction_date = ?param0]
2018-03-15 10:55:09,912-Statement Id: [SelectReplenishmentBySKUNode] Prepared SQL:
[select transaction_id, transaction_date, display_date, transfilter_date, sku_id,
sku_code, sku_name, node_id, node_code, node_name, category_id,
category_code, category_name, buffer_norm, closing_quantity, grn, in_transit,
sales, inst_hold, quality_hold, qa_hold, pending_orders, orders_in_hand,
transport_mode, supply_node_id, supply_node_name, supply_node_code,
supplying_quantity, supplying_buffer_norm, green_zone_qty, yellow_zone_qty,
red_zone_qty, closing_stock_zone, closing_stock_zone_sort, in_transit_zone,
in_transit_zone_sort, supplying_node_zone, supplying_node_zone_sort,
replenishment_quantity, final_quantity, mrq, transaction_comment,
open_stock_transfer_order, open_planned_order, open_purchase_request,
open_production_order, open_purchase_order, field1, field2, field3, field4,
field5, field6, field7, field8, field9, field10, mtd_sales, mtd_grn from
replenishment where transaction_date = ?param0 and sku_id = ?
param1 and node_id = ?param2]
2018-03-15 10:55:09,912-Statement Id: [SelectReplenishmentDates] Prepared SQL:
[SELECT DATE_FORMAT(transaction_date,'%Y-%m-%d') AS transaction_date FROM
replenishment USE INDEX (transaction_date) WHERE (transaction_date
BETWEEN ?param0 and ?param1 ) GROUP BY transaction_date]
2018-03-15 10:55:09,913-Statement Id: [InsertReplenishmentList] Prepared SQL:
[insert into replenishment (transaction_id, transaction_date, display_date,
transfilter_date, sku_id, sku_code, sku_name, node_id, node_code, node_name,
category_id, category_code, category_name, buffer_norm, grn, in_transit,
sales, inst_hold, quality_hold, qa_hold, pending_orders, orders_in_hand,
transport_mode, supply_node_id, supply_node_name, supply_node_code,
supplying_quantity, supplying_buffer_norm, green_zone_qty, yellow_zone_qty,
red_zone_qty, closing_stock_zone, closing_stock_zone_sort, in_transit_zone,
in_transit_zone_sort, supplying_node_zone, supplying_node_zone_sort,
replenishment_quantity, final_quantity, mrq, transaction_comment, db_sync,
mongo_sync, open_stock_transfer_order, open_planned_order,
open_purchase_request, open_production_order, open_purchase_order, field1,
field2, field3, field4, field5, field6, field7, field8, field9, field10,
closing_quantity, mtd_sales, mtd_grn ) SELECT tmt.transaction_id,
tmt.transaction_date, tmt.display_date, tmt.transfilter_date, tmt.sku_id,
tmt.sku_code, tmt.sku_name, tmt.node_id, tmt.node_code, tmt.node_name,
tmt.category_id, tmt.category_code, tmt.category_name, tmt.buffer_norm,
tmt.grn, tmt.in_transit, tmt.sales, tmt.inst_hold, tmt.quality_hold,
tmt.qa_hold, tmt.pending_orders, tmt.orders_in_hand, tmt.transport_mode,
tmt.supply_node_id, tmt.supply_node_name, tmt.supply_node_code,
tmt.supplying_quantity, tmt.supplying_buffer_norm, tmt.green_zone_qty,
tmt.yellow_zone_qty, tmt.red_zone_qty, tmt.closing_stock_zone,
tmt.closing_stock_zone_sort, tmt.in_transit_zone, tmt.in_transit_zone_sort,
tmt.supplying_node_zone, tmt.supplying_node_zone_sort,
tmt.replenishment_quantity, tmt.final_quantity, tmt.mrq,
tmt.transaction_comment, tmt.db_sync, tmt.mongo_sync,
tmt.open_stock_transfer_order, tmt.open_planned_order, tmt.open_purchase_request,
tmt.open_production_order, tmt.open_purchase_order, tmt.field1, tmt.field2,
tmt.field3, tmt.field4, tmt.field5, tmt.field6, tmt.field7, tmt.field8, tmt.field9,
tmt.field10, CASE WHEN IFNULL(tmt.closing_quantity,0) > 0 THEN
tmt.closing_quantity ELSE IFNULL((SELECT tcl.closing_quantity FROM
TRANSACTION tcl WHERE tcl.transaction_date < tmt.transaction_date AND
tcl.sku_id = tmt.sku_id AND tcl.node_id = tmt.node_id ORDER BY
tcl.transaction_date DESC LIMIT 1), 0) END AS closing_quantity,
IFNULL((SELECT SUM(tms.sales) FROM TRANSACTION tms USE INDEX
(inx_tdt_sku_node_sales) WHERE tms.transaction_date <= tmt.transaction_date
AND tms.transaction_date >= DATE_FORMAT(tmt.transaction_date,'%Y-%m-01') AND
tms.sku_id = tmt.sku_id AND tms.node_id = tmt.node_id), 0) AS mtd_sales,
IFNULL((SELECT SUM(tmg.grn) FROM TRANSACTION tmg USE INDEX (inx_tdt_sku_node_grn)
WHERE tmg.transaction_date <= tmt.transaction_date AND tmg.transaction_date >=
DATE_FORMAT(tmt.transaction_date,'%Y-%m-01') AND tmg.sku_id = tmt.sku_id AND
tmg.node_id = tmt.node_id), 0) AS mtd_grn FROM (SELECT
tr.transaction_id, tr.transaction_date, DATE_FORMAT(tr.transaction_date,'%d/%m/%Y')
AS display_date, DATE_FORMAT(tr.transaction_date,'%Y%m%d') AS transfilter_date,
tr.sku_id, s.sku_code, s.sku_name, tr.node_id, n.node_code, n.node_name,
sc.category_id, cat.category_code, cat.category_name, IFNULL(bn.buffer_norm,
0) AS buffer_norm, IFNULL(tr.closing_quantity, 0) AS closing_quantity,
IFNULL(tr.grn,0) AS grn, IFNULL(tr.in_transit, 0) AS in_transit, IFNULL(tr.sales,
0) AS sales, IFNULL(tr.inst_hold, 0) AS inst_hold, IFNULL(tr.quality_hold,
0) AS quality_hold, IFNULL(tr.qa_hold, 0) AS qa_hold,
IFNULL(tr.pending_orders, 0) AS pending_orders, IFNULL(tr.orders_in_hand, 0) AS
orders_in_hand, IFNULL(tr.transport_mode, '') AS transport_mode, CASE WHEN
IFNULL(tr.supply_node_id,0) > 0 THEN IFNULL(tr.supply_node_id,0) ELSE
IFNULL(nsm.supplier_node_id,0) END AS supply_node_id, sn.node_name AS
supply_node_name, sn.node_code AS supply_node_code,
IFNULL(str.closing_quantity, 0) AS supplying_quantity,
IFNULL(sbn.buffer_norm, 0) AS supplying_buffer_norm,
ROUND(IFNULL(bn.buffer_norm, 0),2) AS 'green_zone_qty', CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2)
END AS 'yellow_zone_qty', CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END AS 'red_zone_qty', CASE
WHEN IFNULL(bn.buffer_norm, 0) = 0 THEN 'White' WHEN
(IFNULL(tr.closing_quantity, 0) <= 0 AND IFNULL(bn.buffer_norm, 0) > 0) THEN
'Black' WHEN (IFNULL(tr.closing_quantity, 0) > IFNULL(bn.buffer_norm, 0) AND
IFNULL(bn.buffer_norm, 0) > 0) THEN 'Blue' WHEN (IFNULL(tr.closing_quantity,
0) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(tr.closing_quantity,
0) <= IFNULL(bn.buffer_norm, 0) AND IFNULL(bn.buffer_norm, 0) > 0) THEN 'Green'
WHEN (IFNULL(tr.closing_quantity, 0) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(tr.closing_quantity, 0) <=
(CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(bn.buffer_norm, 0) >
0) THEN 'Yellow' WHEN (IFNULL(tr.closing_quantity, 0) > 0 AND
IFNULL(tr.closing_quantity, 0) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(bn.buffer_norm, 0) > 0) THEN
'Red' END AS 'closing_stock_zone', CASE WHEN
IFNULL(bn.buffer_norm, 0) = 0 THEN 6 WHEN (IFNULL(tr.closing_quantity, 0) <=
0 AND IFNULL(bn.buffer_norm, 0) > 0) THEN 1 WHEN
(IFNULL(tr.closing_quantity, 0) > IFNULL(bn.buffer_norm, 0) AND
IFNULL(bn.buffer_norm, 0) > 0) THEN 2 WHEN (IFNULL(tr.closing_quantity, 0) >
(CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(tr.closing_quantity,
0) <= IFNULL(bn.buffer_norm, 0) AND IFNULL(bn.buffer_norm, 0) > 0) THEN 4
WHEN (IFNULL(tr.closing_quantity, 0) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(tr.closing_quantity, 0) <=
(CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(bn.buffer_norm, 0) >
0) THEN 3 WHEN (IFNULL(tr.closing_quantity, 0) > 0 AND
IFNULL(tr.closing_quantity, 0) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(bn.buffer_norm, 0) > 0) THEN
5 END AS 'closing_stock_zone_sort', CASE WHEN
IFNULL(bn.buffer_norm, 0) = 0 THEN 'White' WHEN
((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) <= 0 AND IFNULL(bn.buffer_norm, 0) > 0) THEN 'Black'
WHEN ((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > IFNULL(bn.buffer_norm, 0) AND
IFNULL(bn.buffer_norm, 0) > 0) THEN 'Blue' WHEN
((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND
(IFNULL(tr.closing_quantity, 0) + tr.in_transit - tr.pending_orders) <=
IFNULL(bn.buffer_norm, 0) AND IFNULL(bn.buffer_norm, 0) > 0) THEN 'Green'
WHEN ((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND (tr.closing_quantity +
tr.in_transit - tr.pending_orders) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2)
ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(bn.buffer_norm,
0) > 0) THEN 'Yellow' WHEN ((IFNULL(tr.closing_quantity, 0) +
IFNULL(tr.in_transit, 0) - IFNULL(tr.pending_orders, 0)) > 0 AND
(IFNULL(tr.closing_quantity, 0) + tr.in_transit - tr.pending_orders) <= (CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND
IFNULL(bn.buffer_norm, 0) > 0) THEN 'Red' END AS 'in_transit_zone',
CASE WHEN IFNULL(bn.buffer_norm, 0) = 0 THEN 6 WHEN
((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) <= 0 AND IFNULL(bn.buffer_norm, 0) > 0) THEN 1
WHEN ((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > IFNULL(bn.buffer_norm, 0) AND
IFNULL(bn.buffer_norm,
0) > 0) THEN 2 WHEN ((IFNULL(tr.closing_quantity, 0) +
IFNULL(tr.in_transit, 0) - IFNULL(tr.pending_orders, 0)) > (CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2)
END) AND (IFNULL(tr.closing_quantity, 0) + tr.in_transit - tr.pending_orders) <=
IFNULL(bn.buffer_norm, 0) AND IFNULL(bn.buffer_norm, 0) > 0) THEN 4 WHEN
((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND (IFNULL(tr.closing_quantity, 0) +
tr.in_transit - tr.pending_orders) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2)
ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(bn.buffer_norm,
0) > 0) THEN 3 WHEN ((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit,
0) - IFNULL(tr.pending_orders, 0)) > 0 AND (IFNULL(tr.closing_quantity, 0) +
tr.in_transit - tr.pending_orders) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(bn.buffer_norm, 0) > 0) THEN
5 END AS 'in_transit_zone_sort', CASE WHEN
IFNULL(sbn.buffer_norm, 0) = 0 THEN 'White' WHEN
(IFNULL(str.closing_quantity, 0) <= 0 AND IFNULL(sbn.buffer_norm, 0) > 0) THEN
'Black' WHEN (IFNULL(str.closing_quantity, 0) > IFNULL(sbn.buffer_norm, 0)
AND IFNULL(sbn.buffer_norm, 0) > 0) THEN 'Blue' WHEN
(IFNULL(str.closing_quantity, 0) > (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) AND
IFNULL(str.closing_quantity, 0) <= IFNULL(sbn.buffer_norm, 0) AND
IFNULL(sbn.buffer_norm, 0) > 0) THEN 'Green' WHEN
(IFNULL(str.closing_quantity, 0) > (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) AND IFNULL(str.closing_quantity, 0) <=
(CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) AND IFNULL(sbn.buffer_norm, 0)
> 0) THEN 'Yellow' WHEN (IFNULL(str.closing_quantity, 0) > 0 AND
IFNULL(str.closing_quantity, 0) <= (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) AND IFNULL(sbn.buffer_norm, 0) > 0)
THEN 'Red' END AS 'supplying_node_zone', CASE WHEN
IFNULL(sbn.buffer_norm, 0) = 0 THEN 6 WHEN (IFNULL(str.closing_quantity, 0)
<= 0 AND IFNULL(sbn.buffer_norm, 0) > 0) THEN 1 WHEN
(IFNULL(str.closing_quantity, 0) > IFNULL(sbn.buffer_norm, 0) AND
IFNULL(sbn.buffer_norm, 0) > 0) THEN 2 WHEN (IFNULL(str.closing_quantity, 0)
> (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) AND
IFNULL(str.closing_quantity, 0) <= IFNULL(sbn.buffer_norm, 0) AND
IFNULL(sbn.buffer_norm, 0) > 0) THEN 4 WHEN (IFNULL(str.closing_quantity, 0)
> (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) AND IFNULL(str.closing_quantity, 0) <=
(CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) AND IFNULL(sbn.buffer_norm, 0)
> 0) THEN 3 WHEN (IFNULL(str.closing_quantity, 0) > 0 AND
IFNULL(str.closing_quantity, 0) <= (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) AND IFNULL(sbn.buffer_norm, 0) > 0)
THEN 5 END AS 'supplying_node_zone_sort', CASE WHEN
((IFNULL(bn.buffer_norm, 0) - IFNULL(tr.closing_quantity, 0) -
IFNULL(tr.in_transit, 0)) + IFNULL(tr.pending_orders, 0)) -
(IFNULL(tr.open_planned_order, 0) + IFNULL(tr.open_purchase_request, 0) +
IFNULL(tr.open_production_order, 0) + IFNULL(tr.open_purchase_order, 0)) <= 0 THEN
0 ELSE ((IFNULL(bn.buffer_norm, 0) - IFNULL(tr.closing_quantity, 0) -
IFNULL(tr.in_transit, 0)) + IFNULL(tr.pending_orders, 0)) -
(IFNULL(tr.open_planned_order, 0) + IFNULL(tr.open_purchase_request, 0) +
IFNULL(tr.open_production_order, 0) + IFNULL(tr.open_purchase_order, 0)) END
AS 'replenishment_quantity', CASE WHEN (IFNULL(tr.closing_quantity,
0) + IFNULL(tr.in_transit, 0) + IFNULL(tr.open_planned_order, 0) +
IFNULL(tr.open_purchase_request, 0) + IFNULL(tr.open_production_order, 0) +
IFNULL(tr.open_purchase_order, 0) ) - IFNULL(tr.pending_orders, 0) <= 0 THEN 0
ELSE (IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) +
IFNULL(tr.open_planned_order, 0) + IFNULL(tr.open_purchase_request, 0) +
IFNULL(tr.open_production_order, 0) + IFNULL(tr.open_purchase_order, 0) ) -
IFNULL(tr.pending_orders, 0) END AS 'final_quantity', CASE
WHEN IFNULL(bn.buffer_norm, 0) = 0 THEN 0 ELSE (CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END)
END AS 'mrq', (SELECT COUNT(1) FROM transaction_comment WHERE
transaction_id = tr.transaction_id) AS 'transaction_comment', 0 AS db_sync, 0 AS
mongo_sync, IFNULL(tr.open_stock_transfer_order, 0) AS
open_stock_transfer_order, IFNULL(tr.open_planned_order, 0) AS open_planned_order,
IFNULL(tr.open_purchase_request, 0) AS open_purchase_request,
IFNULL(tr.open_production_order, 0) AS open_production_order,
IFNULL(tr.open_purchase_order, 0) AS open_purchase_order, tr.field1,
tr.field2, tr.field3, tr.field4, tr.field5, tr.field6, tr.field7, tr.field8,
tr.field9, tr.field10 from ( select tt.transaction_id from
transaction tt use index (transaction_date) inner join update_transaction ut
use index (inx_transactionid) on ut.transaction_id = tt.transaction_id
where tt.transaction_date = ?param0 ORDER BY tt.sku_id limit ?
param1 , ?param2 ) otr join transaction tr on
tr.transaction_id = otr.transaction_id LEFT JOIN buffer_norm bn USE INDEX
(inx_sku_node_efdt) ON bn.sku_id = tr.sku_id AND bn.node_id =
tr.node_id AND bn.effective_from = ( SELECT MAX(effective_from) FROM
buffer_norm WHERE effective_from <= tr.transaction_date AND sku_id =
tr.sku_id AND node_id = tr.node_id) LEFT JOIN sku s ON
s.sku_id = tr.sku_id LEFT JOIN sku_category sc ON
sc.sku_category_id = (SELECT sku_category_id FROM sku_category WHERE sku_id =
tr.sku_id LIMIT 1) LEFT JOIN category cat ON cat.category_id =
sc.category_id LEFT JOIN node n ON n.node_id = tr.node_id
LEFT OUTER JOIN node_sku_mapping nsm USE INDEX (inx_sku_receiver_node_efdt)
ON nsm.receiver_node_id = tr.node_id AND nsm.sku_id = tr.sku_id AND
nsm.effective_date = ( SELECT MAX(effective_date) FROM node_sku_mapping
WHERE effective_date <= tr.transaction_date AND sku_id = tr.sku_id
AND receiver_node_id = tr.node_id) LEFT JOIN node sn ON CASE WHEN
IFNULL(tr.supply_node_id,0) > 0 THEN sn.node_id = tr.supply_node_id ELSE
sn.node_id = nsm.supplier_node_id END LEFT JOIN buffer_norm sbn USE INDEX
(inx_sku_node_efdt) ON sbn.sku_id = tr.sku_id AND CASE WHEN
IFNULL(tr.supply_node_id,0) > 0 THEN sbn.node_id = tr.supply_node_id ELSE
sbn.node_id = nsm.supplier_node_id END AND sbn.effective_from =
( SELECT MAX(effective_from) FROM buffer_norm WHERE effective_from <=
tr.transaction_date AND sku_id = tr.sku_id AND node_id = tr.node_id)
LEFT JOIN TRANSACTION str USE INDEX (inx_tdt_sku_node_snode) ON
str.transaction_date = tr.transaction_date AND str.sku_id = tr.sku_id
AND CASE WHEN IFNULL(tr.supply_node_id,0) > 0 THEN str.node_id =
IFNULL(tr.supply_node_id,0) ELSE str.node_id = nsm.supplier_node_id END
GROUP BY tr.transaction_id ORDER BY tr.transaction_id) tmt ON
DUPLICATE KEY UPDATE category_id=VALUES(category_id),
category_code=VALUES(category_code), category_name=VALUES(category_name),
buffer_norm=VALUES(buffer_norm), closing_quantity=VALUES(closing_quantity),
grn=VALUES(grn), in_transit=VALUES(in_transit), sales=VALUES(sales),
inst_hold=VALUES(inst_hold), quality_hold=VALUES(quality_hold),
qa_hold=VALUES(qa_hold), pending_orders=VALUES(pending_orders),
orders_in_hand=VALUES(orders_in_hand), mtd_sales=VALUES(mtd_sales),
mtd_grn=VALUES(mtd_grn), transport_mode=VALUES(transport_mode),
supply_node_id=VALUES(supply_node_id), supply_node_name=VALUES(supply_node_name),
supply_node_code=VALUES(supply_node_code),
supplying_quantity=VALUES(supplying_quantity),
supplying_buffer_norm=VALUES(supplying_buffer_norm),
green_zone_qty=VALUES(green_zone_qty), yellow_zone_qty=VALUES(yellow_zone_qty),
red_zone_qty=VALUES(red_zone_qty), closing_stock_zone=VALUES(closing_stock_zone),
closing_stock_zone_sort=VALUES(closing_stock_zone_sort),
in_transit_zone=VALUES(in_transit_zone),
in_transit_zone_sort=VALUES(in_transit_zone_sort),
supplying_node_zone=VALUES(supplying_node_zone),
supplying_node_zone_sort=VALUES(supplying_node_zone_sort),
replenishment_quantity=VALUES(replenishment_quantity),
final_quantity=VALUES(final_quantity), mrq=VALUES(mrq), db_sync=VALUES(db_sync),
mongo_sync=VALUES(mongo_sync),
open_stock_transfer_order=VALUES(open_stock_transfer_order),
open_planned_order=VALUES(open_planned_order),
open_purchase_request=VALUES(open_purchase_request),
open_production_order=VALUES(open_production_order),
open_purchase_order=VALUES(open_purchase_order), field1=VALUES(field1),
field2=VALUES(field2), field3=VALUES(field3), field4=VALUES(field4),
field5=VALUES(field5), field6=VALUES(field6), field7=VALUES(field7),
field8=VALUES(field8), field9=VALUES(field9), field10=VALUES(field10);]
2018-03-15 10:55:09,914-Statement Id: [InsertReplenishmentListFullSync] Prepared
SQL: [insert into replenishment (transaction_id, transaction_date,
display_date, transfilter_date, sku_id, sku_code, sku_name, node_id, node_code,
node_name, category_id, category_code, category_name, buffer_norm,
closing_quantity, in_transit, sales, inst_hold, quality_hold, qa_hold,
pending_orders, orders_in_hand, transport_mode, supply_node_id,
supply_node_name, supply_node_code, supplying_quantity, supplying_buffer_norm,
green_zone_qty, yellow_zone_qty, red_zone_qty, closing_stock_zone,
closing_stock_zone_sort, in_transit_zone, in_transit_zone_sort,
supplying_node_zone, supplying_node_zone_sort, replenishment_quantity,
final_quantity, mrq, transaction_comment, db_sync, mongo_sync,
open_stock_transfer_order, open_planned_order, open_purchase_request,
open_production_order, open_purchase_order, field1, field2, field3, field4, field5,
field6, field7, field8, field9, field10 ) SELECT tr.transaction_id,
tr.transaction_date, DATE_FORMAT(tr.transaction_date,'%d/%m/%Y') AS display_date,
DATE_FORMAT(tr.transaction_date,'%Y%m%d') AS transfilter_date, tr.sku_id,
s.sku_code, s.sku_name, tr.node_id, n.node_code, n.node_name, sc.category_id,
cat.category_code, cat.category_name, IFNULL(bn.buffer_norm, 0) AS
buffer_norm, IFNULL(tr.closing_quantity, 0) AS closing_quantity,
IFNULL(tr.in_transit, 0) AS in_transit, IFNULL(tr.sales, 0) AS sales,
IFNULL(tr.inst_hold, 0) AS inst_hold, IFNULL(tr.quality_hold, 0) AS quality_hold,
IFNULL(tr.qa_hold, 0) AS qa_hold, IFNULL(tr.pending_orders, 0) AS
pending_orders, IFNULL(tr.orders_in_hand, 0) AS orders_in_hand,
IFNULL(tr.transport_mode, '') AS transport_mode, CASE WHEN
IFNULL(tr.supply_node_id,0) > 0 THEN IFNULL(tr.supply_node_id,0) ELSE
IFNULL(nsm.supplier_node_id,0) END AS supply_node_id, sn.node_name AS
supply_node_name, sn.node_code AS supply_node_code,
IFNULL(str.closing_quantity, 0) AS supplying_quantity,
IFNULL(sbn.buffer_norm, 0) AS supplying_buffer_norm,
ROUND(IFNULL(bn.buffer_norm, 0),2) AS 'green_zone_qty', CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2)
END AS 'yellow_zone_qty', CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END AS 'red_zone_qty', CASE
WHEN IFNULL(bn.buffer_norm, 0) = 0 THEN 'White' WHEN
(IFNULL(tr.closing_quantity, 0) <= 0 AND IFNULL(bn.buffer_norm, 0) > 0) THEN
'Black' WHEN (IFNULL(tr.closing_quantity, 0) > IFNULL(bn.buffer_norm, 0) AND
IFNULL(bn.buffer_norm, 0) > 0) THEN 'Blue' WHEN (IFNULL(tr.closing_quantity,
0) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(tr.closing_quantity,
0) <= IFNULL(bn.buffer_norm, 0) AND IFNULL(bn.buffer_norm, 0) > 0) THEN 'Green'
WHEN (IFNULL(tr.closing_quantity, 0) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(tr.closing_quantity, 0) <=
(CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(bn.buffer_norm, 0) >
0) THEN 'Yellow' WHEN (IFNULL(tr.closing_quantity, 0) > 0 AND
IFNULL(tr.closing_quantity, 0) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(bn.buffer_norm, 0) > 0) THEN
'Red' END AS 'closing_stock_zone', CASE WHEN
IFNULL(bn.buffer_norm, 0) = 0 THEN 6 WHEN (IFNULL(tr.closing_quantity, 0) <=
0 AND IFNULL(bn.buffer_norm, 0) > 0) THEN 1 WHEN
(IFNULL(tr.closing_quantity, 0) > IFNULL(bn.buffer_norm, 0) AND
IFNULL(bn.buffer_norm, 0) > 0) THEN 2 WHEN (IFNULL(tr.closing_quantity, 0) >
(CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(tr.closing_quantity,
0) <= IFNULL(bn.buffer_norm, 0) AND IFNULL(bn.buffer_norm, 0) > 0) THEN 4
WHEN (IFNULL(tr.closing_quantity, 0) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(tr.closing_quantity, 0) <=
(CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(bn.buffer_norm, 0) >
0) THEN 3 WHEN (IFNULL(tr.closing_quantity, 0) > 0 AND
IFNULL(tr.closing_quantity, 0) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(bn.buffer_norm, 0) > 0) THEN
5 END AS 'closing_stock_zone_sort', CASE WHEN
IFNULL(bn.buffer_norm, 0) = 0 THEN 'White' WHEN
((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) <= 0 AND IFNULL(bn.buffer_norm, 0) > 0) THEN 'Black'
WHEN ((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > IFNULL(bn.buffer_norm, 0) AND
IFNULL(bn.buffer_norm, 0) > 0) THEN 'Blue' WHEN
((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND
(IFNULL(tr.closing_quantity, 0) + tr.in_transit - tr.pending_orders) <=
IFNULL(bn.buffer_norm, 0) AND IFNULL(bn.buffer_norm, 0) > 0) THEN 'Green'
WHEN ((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND (tr.closing_quantity +
tr.in_transit - tr.pending_orders) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2)
ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(bn.buffer_norm,
0) > 0) THEN 'Yellow' WHEN ((IFNULL(tr.closing_quantity, 0) +
IFNULL(tr.in_transit, 0) - IFNULL(tr.pending_orders, 0)) > 0 AND
(IFNULL(tr.closing_quantity, 0) + tr.in_transit - tr.pending_orders) <= (CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND
IFNULL(bn.buffer_norm, 0) > 0) THEN 'Red' END AS 'in_transit_zone',
CASE WHEN IFNULL(bn.buffer_norm, 0) = 0 THEN 6 WHEN
((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) <= 0 AND IFNULL(bn.buffer_norm, 0) > 0) THEN 1
WHEN ((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > IFNULL(bn.buffer_norm, 0) AND
IFNULL(bn.buffer_norm, 0) > 0) THEN 2 WHEN ((IFNULL(tr.closing_quantity, 0)
+ IFNULL(tr.in_transit, 0) - IFNULL(tr.pending_orders, 0)) > (CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2)
END) AND (IFNULL(tr.closing_quantity, 0) + tr.in_transit - tr.pending_orders) <=
IFNULL(bn.buffer_norm, 0) AND IFNULL(bn.buffer_norm, 0) > 0) THEN 4 WHEN
((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND (IFNULL(tr.closing_quantity, 0) +
tr.in_transit - tr.pending_orders) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2)
ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(bn.buffer_norm,
0) > 0) THEN 3 WHEN ((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit,
0) - IFNULL(tr.pending_orders, 0)) > 0 AND (IFNULL(tr.closing_quantity, 0) +
tr.in_transit - tr.pending_orders) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(bn.buffer_norm, 0) > 0) THEN
5 END AS 'in_transit_zone_sort', CASE WHEN
IFNULL(sbn.buffer_norm, 0) = 0 THEN 'White' WHEN
(IFNULL(str.closing_quantity, 0) <= 0 AND IFNULL(sbn.buffer_norm, 0) > 0) THEN
'Black' WHEN (IFNULL(str.closing_quantity, 0) > IFNULL(sbn.buffer_norm, 0)
AND IFNULL(sbn.buffer_norm, 0) > 0) THEN 'Blue' WHEN
(IFNULL(str.closing_quantity, 0) > (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) AND
IFNULL(str.closing_quantity, 0) <= IFNULL(sbn.buffer_norm, 0) AND
IFNULL(sbn.buffer_norm, 0) > 0) THEN 'Green' WHEN
(IFNULL(str.closing_quantity, 0) > (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.red_zone,0)
/ 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE ROUND(IFNULL(sbn.buffer_norm, 0) /
3,2) END) AND IFNULL(str.closing_quantity, 0) <= (CASE WHEN
IFNULL(sbn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(sbn.yellow_zone,0) / 100)
* IFNULL(sbn.buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(sbn.buffer_norm,
0)),2) END) AND IFNULL(sbn.buffer_norm, 0) > 0) THEN 'Yellow' WHEN
(IFNULL(str.closing_quantity, 0) > 0 AND IFNULL(str.closing_quantity, 0) <= (CASE
WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(sbn.red_zone,0) /
100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2)
END) AND IFNULL(sbn.buffer_norm, 0) > 0) THEN 'Red' END AS
'supplying_node_zone', CASE WHEN IFNULL(sbn.buffer_norm, 0) = 0
THEN 6 WHEN (IFNULL(str.closing_quantity, 0) <= 0 AND
IFNULL(sbn.buffer_norm, 0) > 0) THEN 1 WHEN (IFNULL(str.closing_quantity, 0)
> IFNULL(sbn.buffer_norm, 0) AND IFNULL(sbn.buffer_norm, 0) > 0) THEN 2 WHEN
(IFNULL(str.closing_quantity, 0) > (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) AND
IFNULL(str.closing_quantity, 0) <= IFNULL(sbn.buffer_norm, 0) AND
IFNULL(sbn.buffer_norm, 0) > 0) THEN 4 WHEN (IFNULL(str.closing_quantity, 0)
> (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) AND IFNULL(str.closing_quantity, 0) <=
(CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) AND IFNULL(sbn.buffer_norm, 0)
> 0) THEN 3 WHEN (IFNULL(str.closing_quantity, 0) > 0 AND
IFNULL(str.closing_quantity, 0) <= (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) AND IFNULL(sbn.buffer_norm, 0) > 0)
THEN 5 END AS 'supplying_node_zone_sort', CASE WHEN
((IFNULL(bn.buffer_norm, 0) - IFNULL(tr.closing_quantity, 0) -
IFNULL(tr.in_transit, 0)) + IFNULL(tr.pending_orders, 0)) -
(IFNULL(tr.open_planned_order, 0) + IFNULL(tr.open_purchase_request, 0) +
IFNULL(tr.open_production_order, 0) + IFNULL(tr.open_purchase_order, 0)) <= 0 THEN
0 ELSE ((IFNULL(bn.buffer_norm, 0) - IFNULL(tr.closing_quantity, 0) -
IFNULL(tr.in_transit, 0)) + IFNULL(tr.pending_orders, 0)) -
(IFNULL(tr.open_planned_order, 0) + IFNULL(tr.open_purchase_request, 0) +
IFNULL(tr.open_production_order, 0) + IFNULL(tr.open_purchase_order, 0)) END
AS 'replenishment_quantity', CASE WHEN (IFNULL(tr.closing_quantity,
0) + IFNULL(tr.in_transit, 0) + IFNULL(tr.open_planned_order, 0) +
IFNULL(tr.open_purchase_request, 0) + IFNULL(tr.open_production_order, 0) +
IFNULL(tr.open_purchase_order, 0) ) - IFNULL(tr.pending_orders, 0) <= 0 THEN 0
ELSE (IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) +
IFNULL(tr.open_planned_order, 0) + IFNULL(tr.open_purchase_request, 0) +
IFNULL(tr.open_production_order, 0) + IFNULL(tr.open_purchase_order, 0) ) -
IFNULL(tr.pending_orders, 0) END AS 'final_quantity', CASE
WHEN IFNULL(bn.buffer_norm, 0) = 0 THEN 0 ELSE (CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END)
END AS 'mrq', (SELECT COUNT(1) FROM transaction_comment WHERE
transaction_id = tr.transaction_id) AS 'transaction_comment', 0 AS db_sync, 0 AS
mongo_sync, IFNULL(tr.open_stock_transfer_order, 0),
IFNULL(tr.open_planned_order, 0), IFNULL(tr.open_purchase_request,
0),IFNULL(tr.open_production_order, 0), IFNULL(tr.open_purchase_order, 0),
tr.field1, tr.field2, tr.field3, tr.field4, tr.field5, tr.field6, tr.field7,
tr.field8, tr.field9, tr.field10 from ( select tt.transaction_id
from transaction tt use index (transaction_date) where
tt.transaction_date = ?param0 ORDER BY tt.sku_id limit ?
param1 , ?param2 ) otr join transaction tr on
tr.transaction_id = otr.transaction_id LEFT JOIN buffer_norm bn USE INDEX
(inx_sku_node_efdt) ON bn.sku_id = tr.sku_id AND bn.node_id =
tr.node_id AND bn.effective_from = ( SELECT MAX(effective_from) FROM
buffer_norm WHERE effective_from <= tr.transaction_date AND sku_id =
tr.sku_id AND node_id = tr.node_id) LEFT JOIN sku s ON
s.sku_id = tr.sku_id LEFT JOIN sku_category sc ON
sc.sku_category_id = (SELECT sku_category_id FROM sku_category WHERE sku_id =
tr.sku_id LIMIT 1) LEFT JOIN category cat ON cat.category_id =
sc.category_id LEFT JOIN node n ON n.node_id = tr.node_id
LEFT OUTER JOIN node_sku_mapping nsm USE INDEX (inx_sku_receiver_node_efdt)
ON nsm.receiver_node_id = tr.node_id AND nsm.sku_id = tr.sku_id AND
nsm.effective_date = ( SELECT MAX(effective_date) FROM node_sku_mapping
WHERE effective_date <= tr.transaction_date AND sku_id = tr.sku_id
AND receiver_node_id = tr.node_id) LEFT JOIN node sn ON CASE WHEN
IFNULL(tr.supply_node_id,0) > 0 THEN sn.node_id = tr.supply_node_id ELSE
sn.node_id = nsm.supplier_node_id END LEFT JOIN buffer_norm sbn USE INDEX
(inx_sku_node_efdt) ON sbn.sku_id = tr.sku_id AND CASE WHEN
IFNULL(tr.supply_node_id,0) > 0 THEN sbn.node_id = tr.supply_node_id ELSE
sbn.node_id = nsm.supplier_node_id END AND sbn.effective_from =
( SELECT MAX(effective_from) FROM buffer_norm WHERE effective_from <=
tr.transaction_date AND sku_id = tr.sku_id AND node_id = tr.node_id)
LEFT JOIN TRANSACTION str USE INDEX (inx_tdt_sku_node_snode) ON
str.transaction_date = tr.transaction_date AND str.sku_id = tr.sku_id
AND CASE WHEN IFNULL(tr.supply_node_id,0) > 0 THEN str.node_id =
IFNULL(tr.supply_node_id,0) ELSE str.node_id = nsm.supplier_node_id END
GROUP BY tr.transaction_id ORDER BY tr.transaction_id]
2018-03-15 10:55:09,915-Adding file [UserHelper.xml] to list of watched files.
2018-03-15 10:55:09,915-Statement Id: [SelectUserNameDuplicate] Prepared SQL:
[select user_id, user_name, first_name, middle_name, last_name, email, mobile,
description, password, status, approved, locked, role_id, region_id,
created_by, created_on, modified_by, modified_on from user where user_name =
?param0 and user_id != ?param1]
2018-03-15 10:55:09,915-Statement Id: [SelectUserMobileDuplicate] Prepared SQL:
[select user_id, user_name, first_name, middle_name, last_name, email, mobile,
description, password, status, approved, locked, role_id, region_id,
created_by, created_on, modified_by, modified_on from user where mobile = ?
param0 and user_id != ?param1]
2018-03-15 10:55:09,915-Statement Id: [SelectUserCheckAuthenticate] Prepared SQL:
[select user_id, user_name, first_name, middle_name, last_name, email, mobile,
description, password, status, approved, locked, role_id, region_id,
created_by, created_on, modified_by, modified_on from user where user_name =
?param0 and password = ?param1 and status = 1]
2018-03-15 10:55:09,915-Statement Id: [SelectUserCheckLocked] Prepared SQL: [select
user_id, user_name, first_name, middle_name, last_name, email, mobile, description,
password, status, approved, locked, role_id, region_id, created_by,
created_on, modified_by, modified_on from user where user_name = ?param0]
2018-03-15 10:55:09,916-Statement Id: [InsertUser] Prepared SQL: [insert into user
(user_name, first_name, middle_name, last_name, email, mobile, description,
password, status, approved, locked, role_id, region_id, created_by,
created_on) values ( ?param0 , ?param1 , ?param2 , ?param3 , ?
param4 , ?param5 , ?param6 , ?param7 , ?param8 , ?param9 , ?param10 ,
?param11 , ?param12 , ?param13 , NOW());]
2018-03-15 10:55:09,916-Statement Id: [InsertUser.SelectKey] Prepared SQL: [select
last_insert_id() as value]
2018-03-15 10:55:09,916-Statement Id: [UpdateUser] Prepared SQL: [update user set
user_name = ?param0 , first_name = ?param1 , middle_name = ?param2
, last_name = ?param3 , email = ?param4 , mobile = ?
param5 , description = ?param6 , password = ?param7 , status
= ?param8 , approved = ?param9 , locked = ?param10 ,
role_id = ?param11 , region_id = ?param12 , modified_by = ?param13
, modified_on = NOW() where user_id = ?param14]
2018-03-15 10:55:09,916-Statement Id: [DeleteUser] Prepared SQL: [delete from user
where user_id = ?param0]
2018-03-15 10:55:09,916-Adding file [UserModuleHelper.xml] to list of watched
files.
2018-03-15 10:55:09,916-Statement Id: [InsertUserModule] Prepared SQL: [insert into
user_module (role_id, module_id, created_by, created_on) values
( ?param0 , ?param1 , ?param2 , NOW());]
2018-03-15 10:55:09,916-Statement Id: [InsertUserModule.SelectKey] Prepared SQL:
[select last_insert_id() as value]
2018-03-15 10:55:09,916-Statement Id: [DeleteUserModule] Prepared SQL: [delete from
user_module where user_module_id = ?param0]
2018-03-15 10:55:09,916-Statement Id: [DeleteModuleByRole] Prepared SQL: [delete
from user_module where role_id = ?param0]
2018-03-15 10:55:09,916-Adding file [SKUGridHelper.xml] to list of watched files.
2018-03-15 10:55:09,920-Statement Id: [SelectSKUGrid] Prepared SQL: [select
s.sku_name, n.node_name, c.category_id, c.category_name, sku_grid.*, case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (1 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(1 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (1 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (1 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (1 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (1 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (1 * avg_sales)) > 0 and (closing_quantity - (1 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(red_zone,0) /
100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and
buffer_norm > 0) then 'Red' end as 'one', case when (closing_quantity
- (1 * avg_sales)) <= 0 then 0 else (closing_quantity - (1 * avg_sales)) end as
'one_qty', case when ifnull(buffer_norm, 0) = 0 then 'White'
when ((closing_quantity - (2 * avg_sales)) <= 0 and buffer_norm > 0) then 'Black'
when ((closing_quantity - (2 * avg_sales)) > buffer_norm and buffer_norm > 0) then
'Blue' when ((closing_quantity - (2 * avg_sales)) > (CASE WHEN
IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) *
IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END)
and (closing_quantity - (2 * avg_sales)) <= buffer_norm and buffer_norm > 0) then
'Green' when ((closing_quantity - (2 * avg_sales)) > (CASE WHEN
IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(red_zone,0) / 100) *
IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and
(closing_quantity - (2 * avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow'
when ((closing_quantity - (2 * avg_sales)) > 0 and (closing_quantity - (2 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'two', case when (closing_quantity - (2 * avg_sales)) <= 0 then 0 else
(closing_quantity - (2 * avg_sales)) end as 'two_qty', case when
ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (3 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(3 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (3 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (3 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (3 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (3 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (3 * avg_sales)) > 0 and (closing_quantity - (3 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(red_zone,0) /
100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and
buffer_norm > 0) then 'Red' end as 'three', case when
(closing_quantity - (3 * avg_sales)) <= 0 then 0 else (closing_quantity - (3 *
avg_sales)) end as 'three_qty', case when ifnull(buffer_norm, 0) = 0
then 'White' when ((closing_quantity - (4 * avg_sales)) <= 0 and buffer_norm
> 0) then 'Black' when ((closing_quantity - (4 * avg_sales)) > buffer_norm
and buffer_norm > 0) then 'Blue' when ((closing_quantity - (4 * avg_sales))
> (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(yellow_zone,0) /
100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2)
END) and (closing_quantity - (4 * avg_sales)) <= buffer_norm and buffer_norm > 0)
then 'Green' when ((closing_quantity - (4 * avg_sales)) > (CASE WHEN
IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(red_zone,0) / 100) *
IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and
(closing_quantity - (4 * avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow'
when ((closing_quantity - (4 * avg_sales)) > 0 and (closing_quantity - (4 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'four', case when (closing_quantity - (4 * avg_sales)) <= 0 then 0 else
(closing_quantity - (4 * avg_sales)) end as 'four_qty', case when
ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (5 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(5 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (5 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (5 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (5 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (5 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (5 * avg_sales)) > 0 and (closing_quantity - (5 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(red_zone,0) /
100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and
buffer_norm > 0) then 'Red' end as 'five', case when
(closing_quantity - (5 * avg_sales)) <= 0 then 0 else (closing_quantity - (5 *
avg_sales)) end as 'five_qty', case when ifnull(buffer_norm, 0) = 0
then 'White' when ((closing_quantity - (6 * avg_sales)) <= 0 and buffer_norm
> 0) then 'Black' when ((closing_quantity - (6 * avg_sales)) > buffer_norm
and buffer_norm > 0) then 'Blue' when ((closing_quantity - (6 * avg_sales))
> (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(yellow_zone,0) /
100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2)
END) and (closing_quantity - (6 * avg_sales)) <= buffer_norm and buffer_norm > 0)
then 'Green' when ((closing_quantity - (6 * avg_sales)) > (CASE WHEN
IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(red_zone,0) / 100) *
IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and
(closing_quantity - (6 * avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow'
when ((closing_quantity - (6 * avg_sales)) > 0 and (closing_quantity - (6 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'six', case when (closing_quantity - (6 * avg_sales)) <= 0 then 0 else
(closing_quantity - (6 * avg_sales)) end as 'six_qty', case when
ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (7 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(7 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (7 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (7 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (7 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (7 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm
> 0) then 'Yellow' when ((closing_quantity - (7 * avg_sales)) > 0 and
(closing_quantity - (7 * avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'seven', case when (closing_quantity - (7 * avg_sales)) <= 0 then 0 else
(closing_quantity - (7 * avg_sales)) end as 'seven_qty', case when
ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (8 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(8 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (8 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (8 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (8 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (8 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (8 * avg_sales)) > 0 and (closing_quantity - (8 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(red_zone,0) /
100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and
buffer_norm > 0) then 'Red' end as 'eight', case when
(closing_quantity - (8 * avg_sales)) <= 0 then 0 else (closing_quantity - (8 *
avg_sales)) end as 'eight_qty', case when ifnull(buffer_norm, 0) = 0
then 'White' when ((closing_quantity - (9 * avg_sales)) <= 0 and buffer_norm
> 0) then 'Black' when ((closing_quantity - (9 * avg_sales)) > buffer_norm
and buffer_norm > 0) then 'Blue' when ((closing_quantity - (9 * avg_sales))
> (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(yellow_zone,0) /
100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2)
END) and (closing_quantity - (9 * avg_sales)) <= buffer_norm and buffer_norm > 0)
then 'Green' when ((closing_quantity - (9 * avg_sales)) > (CASE WHEN
IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(red_zone,0) / 100) *
IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and
(closing_quantity - (9 * avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow'
when ((closing_quantity - (9 * avg_sales)) > 0 and (closing_quantity - (9 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'nine', case when (closing_quantity - (9 * avg_sales)) <= 0 then 0 else
(closing_quantity - (9 * avg_sales)) end as 'nine_qty', case when
ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (10 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(10 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (10 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (10 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (10 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (10 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (10 * avg_sales)) > 0 and (closing_quantity - (10 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'ten', case when (closing_quantity - (10 * avg_sales)) <= 0 then 0 else
(closing_quantity - (10 * avg_sales)) end as 'ten_qty', case when
ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (11 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(11 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (11 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (11 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (11 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (11 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (11 * avg_sales)) > 0 and (closing_quantity - (11 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'eleven', case when (closing_quantity - (11 * avg_sales)) <= 0 then 0
else (closing_quantity - (11 * avg_sales)) end as 'eleven_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (12 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(12 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (12 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (12 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (12 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (12 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (12 * avg_sales)) > 0 and (closing_quantity - (12 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twelve', case when (closing_quantity - (12 * avg_sales)) <= 0 then 0
else (closing_quantity - (12 * avg_sales)) end as 'twelve_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (13 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(13 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (13 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (13 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (13 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (13 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (13 * avg_sales)) > 0 and (closing_quantity - (13 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'thirteen', case when (closing_quantity - (13 * avg_sales)) <= 0 then 0
else (closing_quantity - (13 * avg_sales)) end as 'thirteen_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (14 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(14 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (14 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (14 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (14 * avg_sales)) > (CASE
WHEN IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(red_zone,0) / 100) *
IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and
(closing_quantity - (14 * avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow'
when ((closing_quantity - (14 * avg_sales)) > 0 and (closing_quantity - (14 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'fourteen', case when (closing_quantity - (14 * avg_sales)) <= 0 then 0
else (closing_quantity - (14 * avg_sales)) end as 'fourteen_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (15 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(15 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (15 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (15 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (15 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (15 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (15 * avg_sales)) > 0 and (closing_quantity - (15 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'fifteen', case when (closing_quantity - (15 * avg_sales)) <= 0 then 0
else (closing_quantity - (15 * avg_sales)) end as 'fifteen_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (16 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(16 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (16 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (16 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (16 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (16 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (16 * avg_sales)) > 0 and (closing_quantity - (16 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'sixteen', case when (closing_quantity - (16 * avg_sales)) <= 0 then 0
else (closing_quantity - (16 * avg_sales)) end as 'sixteen_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (17 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(17 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (17 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (17 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (17 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (17 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (17 * avg_sales)) > 0 and (closing_quantity - (17 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'seventeen', case when (closing_quantity - (17 * avg_sales)) <= 0 then 0
else (closing_quantity - (17 * avg_sales)) end as 'seventeen_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (18 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(18 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (18 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (18 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (18 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (18 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (18 * avg_sales)) > 0 and (closing_quantity - (18 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'eighteen', case when (closing_quantity - (18 * avg_sales)) <= 0 then 0
else (closing_quantity - (18 * avg_sales)) end as 'eighteen_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (19 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(19 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (19 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (19 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (19 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (19 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (19 * avg_sales)) > 0 and (closing_quantity - (19 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'nineteen', case when (closing_quantity - (19 * avg_sales)) <= 0 then 0
else (closing_quantity - (19 * avg_sales)) end as 'nineteen_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (20 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(20 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (20 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (20 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (20 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (20 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (20 * avg_sales)) > 0 and (closing_quantity - (20 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twenty', case when (closing_quantity - (20 * avg_sales)) <= 0 then 0
else (closing_quantity - (20 * avg_sales)) end as 'twenty_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (21 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity
- (21 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (21 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (21 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (21 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (21 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (21 * avg_sales)) > 0 and (closing_quantity - (21 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twentyone', case when (closing_quantity - (21 * avg_sales)) <= 0 then 0
else (closing_quantity - (21 * avg_sales)) end as 'twentyone_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (22 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(22 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (22 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (22 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (22 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (22 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (22 * avg_sales)) > 0 and (closing_quantity - (22 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twentytwo', case when (closing_quantity - (22 * avg_sales)) <= 0 then 0
else (closing_quantity - (22 * avg_sales)) end as 'twentytwo_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (23 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(23 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (23 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (23 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (23 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (23 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (23 * avg_sales)) > 0 and (closing_quantity - (23 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twentythree', case when (closing_quantity - (23 * avg_sales)) <= 0 then
0 else (closing_quantity - (23 * avg_sales)) end as 'twentythree_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (24 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(24 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (24 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (24 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (24 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (24 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (24 * avg_sales)) > 0 and (closing_quantity - (24 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twentyfour', case when (closing_quantity - (24 * avg_sales)) <= 0 then 0
else (closing_quantity - (24 * avg_sales)) end as 'twentyfour_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (25 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(25 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (25 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (25 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (25 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (25 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (25 * avg_sales)) > 0 and (closing_quantity - (25 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twentyfive', case when (closing_quantity - (25 * avg_sales)) <= 0 then 0
else (closing_quantity - (25 * avg_sales)) end as 'twentyfive_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (26 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(26 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (26 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (26 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (26 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (26 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (26 * avg_sales)) > 0 and (closing_quantity - (26 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twentysix', case when (closing_quantity - (26 * avg_sales)) <= 0 then 0
else (closing_quantity - (26 * avg_sales)) end as 'twentysix_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (27 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(27 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (27 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (27 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (27 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (27 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (27 * avg_sales)) > 0 and (closing_quantity - (27 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0)
/ 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END)
and buffer_norm > 0) then 'Red' end as 'twentyseven', case when
(closing_quantity - (27 * avg_sales)) <= 0 then 0 else (closing_quantity - (27 *
avg_sales)) end as 'twentyseven_qty', case when ifnull(buffer_norm,
0) = 0 then 'White' when ((closing_quantity - (28 * avg_sales)) <= 0 and
buffer_norm > 0) then 'Black' when ((closing_quantity - (28 * avg_sales)) >
buffer_norm and buffer_norm > 0) then 'Blue' when ((closing_quantity - (28 *
avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (28 * avg_sales)) <=
buffer_norm and buffer_norm > 0) then 'Green' when ((closing_quantity - (28
* avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (28 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (28 * avg_sales)) > 0 and (closing_quantity - (28 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twentyeight', case when (closing_quantity - (28 * avg_sales)) <= 0 then
0 else (closing_quantity - (28 * avg_sales)) end as 'twentyeight_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (29 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(29 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (29 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (29 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (29 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (29 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (29 * avg_sales)) > 0 and (closing_quantity - (29 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twentynine', case when (closing_quantity - (29 * avg_sales)) <= 0 then 0
else (closing_quantity - (29 * avg_sales)) end as 'twentynine_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (30 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(30 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (30 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (30 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (30 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (30 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (30 * avg_sales)) > 0 and (closing_quantity - (30 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'thirty', case when (closing_quantity - (30 * avg_sales)) <= 0 then 0
else (closing_quantity - (30 * avg_sales)) end as 'thirty_qty' from (
select tr.sku_id, tr.node_id, round(sum(tr.sales) / 15, 2) as avg_sales,
t.closing_quantity, ifnull(bn.buffer_norm, (select buffer_norm from
buffer_norm use index(inx_sku_node_efdt) where effective_from < tr.transaction_date
and sku_id = tr.sku_id and node_id = tr.node_id order by effective_from desc limit
1)) as buffer_norm, ifnull(bn.is_default_zone,'Y') as is_default_zone,
ifnull(bn.yellow_zone,0) as yellow_zone, ifnull(bn.red_zone,0) as red_zone,
case when (t.closing_quantity + t.in_transit - t.pending_orders) <= 0 then 0
else (t.closing_quantity + t.in_transit - t.pending_orders) end as
'final_quantity' from transaction tr inner join transaction t
on t.transaction_date = ?param0 and t.sku_id = tr.sku_id and
t.node_id = tr.node_id left join buffer_norm bn use
index(inx_sku_node_efdt) on bn.sku_id = tr.sku_id and bn.node_id =
tr.node_id and bn.effective_from = ?param0 where tr.sku_id = ?
param1 and tr.node_id = ?param2 and tr.transaction_date > ?param3 group
by tr.sku_id, tr.node_id ) as sku_grid inner join sku s on
s.sku_id = sku_grid.sku_id inner join node n on n.node_id =
sku_grid.node_id inner join sku_category sc on sc.sku_category_id =
(select sku_category_id from sku_category where sku_id = sku_grid.sku_id limit 1)
inner join category c on c.category_id = sc.category_id]
2018-03-15 10:55:09,924-Adding file [ExcessInventoryHelper.xml] to list of watched
files.
2018-03-15 10:55:09,924-Adding file [StockoutAvailabilityChartHelper.xml] to list
of watched files.
2018-03-15 10:55:09,924-Adding file [InventoryTurnsHelper.xml] to list of watched
files.
2018-03-15 10:55:09,929-Statement Id: [SelectInventoryTurns] Prepared SQL: [select
rpl.transaction_date, rpl.category_id, rpl.category_name,
date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date, sum(1) as
count, sum(rpl.closing_quantity) as closing_quantity, sum(rpl.sales) as sales
from replenishment rpl where rpl.category_id is not null and
rpl.transaction_date = ?param0 group by rpl.transaction_date,
rpl.category_id]
2018-03-15 10:55:09,929-Statement Id: [SelectInventoryTurnsSKU] Prepared SQL:
[select rpl.transaction_date, rpl.category_id, rpl.sku_id, rpl.category_name,
date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date, sum(1) as
count, sum(rpl.closing_quantity) as closing_quantity, sum(rpl.sales) as sales
from replenishment rpl where rpl.category_id is not null and
rpl.transaction_date = ?param0 group by rpl.transaction_date,
rpl.category_id, rpl.sku_id]
2018-03-15 10:55:09,930-Adding file [CntQtyFillRateChartHelper.xml] to list of
watched files.
2018-03-15 10:55:09,930-Statement Id: [SelectCntQtyFillRateChart] Prepared SQL:
[select rpl.transaction_date, rpl.closing_stock_zone,
group_concat(distinct(rpl.sku_id) SEPARATOR ',') as str_sku_ids,
date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date,
sum(rpl.closing_quantity) as closing_quantity, sum(rpl.buffer_norm) as buffer_norm
from replenishment rpl where rpl.closing_stock_zone != "White" and
rpl.transaction_date = ?param0 group by rpl.transaction_date,
rpl.closing_stock_zone]
2018-03-15 10:55:09,930-Statement Id: [SelectCntQtyFillRateChartNode] Prepared SQL:
[select rpl.transaction_date, rpl.closing_stock_zone, rpl.node_id,
group_concat(distinct(rpl.sku_id) SEPARATOR ',') as str_sku_ids,
date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date,
sum(rpl.closing_quantity) as closing_quantity, sum(rpl.buffer_norm) as buffer_norm
from replenishment rpl where rpl.closing_stock_zone != "White" and
rpl.transaction_date = ?param0 group by rpl.transaction_date,
rpl.closing_stock_zone, rpl.node_id]
2018-03-15 10:55:09,930-Statement Id: [SelectCntQtyFillRateChartCategory] Prepared
SQL: [select rpl.transaction_date, rpl.closing_stock_zone, rpl.category_id,
group_concat(distinct(rpl.sku_id) SEPARATOR ',') as str_sku_ids,
date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date,
sum(rpl.closing_quantity) as closing_quantity, sum(rpl.buffer_norm) as buffer_norm
from replenishment rpl where rpl.closing_stock_zone != "White" and
rpl.transaction_date = ?param0 group by rpl.transaction_date,
rpl.closing_stock_zone, rpl.category_id]
2018-03-15 10:55:09,930-Statement Id: [SelectCntQtyFillRateChartSKU] Prepared SQL:
[select rpl.transaction_date, rpl.closing_stock_zone, rpl.sku_id,
group_concat(distinct(rpl.sku_id) SEPARATOR ',') as str_sku_ids,
date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date,
sum(rpl.closing_quantity) as closing_quantity, sum(rpl.buffer_norm) as buffer_norm
from replenishment rpl where rpl.closing_stock_zone != "White" and
rpl.transaction_date = ?param0 group by rpl.transaction_date,
rpl.closing_stock_zone, rpl.sku_id]
2018-03-15 10:55:09,930-Adding file [UserDataPermissionHelper.xml] to list of
watched files.
2018-03-15 10:55:09,930-Statement Id: [SelectDataPermissionByRole] Prepared SQL:
[select user_data_id, role_id, object_type, object_id, chk_state, created_by,
created_on from user_data_permissions WHERE role_id = ?param0 AND
object_type = ?param1]
2018-03-15 10:55:09,930-Statement Id: [InsertUserDataPermission] Prepared SQL:
[insert into user_data_permissions (role_id, object_type, object_id,
chk_state, created_by, created_on) values ( ?param0 , ?param1 , ?
param2 , ?param3 , ?param4 , NOW());]
2018-03-15 10:55:09,930-Statement Id: [InsertUserDataPermission.SelectKey] Prepared
SQL: [select last_insert_id() as value]
2018-03-15 10:55:09,930-Statement Id: [DeleteDataPermissionByRole] Prepared SQL:
[delete from user_data_permissions where role_id = ?param0]
2018-03-15 10:55:09,930-Adding file [RoleHelper.xml] to list of watched files.
2018-03-15 10:55:09,930-Statement Id: [SelectRoleNameDuplicate] Prepared SQL:
[select role_id,role_name,status,created_by,created_on,modified_by,modified_on
from role where role_name = ?param0 and role_id != ?param1]
2018-03-15 10:55:09,934-Statement Id: [InsertRole] Prepared SQL: [insert into role
(role_name,status,created_by,created_on) values ( ?param0 , ?
param1 , ?param2 , NOW());]
2018-03-15 10:55:09,934-Statement Id: [InsertRole.SelectKey] Prepared SQL: [select
last_insert_id() as value]
2018-03-15 10:55:09,934-Statement Id: [UpdateRole] Prepared SQL: [update role set
role_name = ?param0 , status = ?param1 , modified_by = ?param2 ,
modified_on = NOW() where role_id = ?param3]
2018-03-15 10:55:09,934-Adding file [BOMHelper.xml] to list of watched files.
2018-03-15 10:55:09,935-Statement Id: [SelectBOMDictionary] Prepared SQL: [SELECT
DISTINCT sk.sku_code, bm.sku_id FROM sku sk INNER JOIN bom bm ON bm.sku_id =
sk.sku_id]
2018-03-15 10:55:09,935-Adding file [Matrix1Helper.xml] to list of watched files.
2018-03-15 10:55:09,941-Statement Id: [SelectUserCheckAuthenticate]
PreparedStatement : [select user_id, user_name, first_name, middle_name,
last_name, email, mobile, description, password, status, approved, locked,
role_id, region_id, created_by, created_on, modified_by, modified_on from
user where user_name = ?param0 and password = ?param1 and status = 1]
2018-03-15 10:55:09,941-Statement Id: [SelectUserCheckAuthenticate] Parameters: [?
param0=[user_name,Admin], ?param1=[password,Ennovate789]]
2018-03-15 10:55:09,941-Statement Id: [SelectUserCheckAuthenticate] Types: [?
param0=[String, System.String], ?param1=[String, System.String]]
2018-03-15 10:55:09,945-Open Connection "39855713" to "MySQL, MySQL provider ver
6:5:4:0".
2018-03-15 10:55:09,947-Close Connection "39855713" to "MySQL, MySQL provider ver
6:5:4:0".
2018-03-15 10:55:11,597-Adding file [SqlMap.config] to list of watched files.
2018-03-15 10:55:11,597-Add property "provider" value "MySql6"
2018-03-15 10:55:11,598-Add property "datasource" value "localhost"
2018-03-15 10:55:11,598-Add property "database" value "scmplus"
2018-03-15 10:55:11,598-Add property "port" value "3306"
2018-03-15 10:55:11,598-Add property "userid" value "root"
2018-03-15 10:55:11,598-Add property "password" value "root"
2018-03-15 10:55:11,598-Add property "mapperResources" value
"./bin/iBatis/SqlMapper/"
2018-03-15 10:55:11,599-Adding file [CategoryHelper.xml] to list of watched files.
2018-03-15 10:55:11,600-Statement Id: [SelectCategoryByCode] Prepared SQL: [select
category_id, category_code, category_name, parent_id, status, created_by,
created_on, modified_by, modified_on from category where category_code = ?
param0]
2018-03-15 10:55:11,600-Statement Id: [SelectCategoryForDuplicate] Prepared SQL:
[select category_id, category_code, category_name, parent_id, status, created_by,
created_on, modified_by, modified_on from category where category_code = ?
param0 and category_name = ?param1 and parent_id = ?param2]
2018-03-15 10:55:11,600-Statement Id: [SelectCategoryBy] Prepared SQL: [select
category_id, parent_id, category_name, category_code, status, created_by,
created_on, modified_by, modified_on from category where ?param0 = ?
param1]
2018-03-15 10:55:11,601-Statement Id: [InsertCategory] Prepared SQL: [insert into
category (category_code, category_name, parent_id, status, created_by,
created_on) values ( ?param0 , ?param1 , ?param2 , ?param3 , ?
param4 , NOW());]
2018-03-15 10:55:11,601-Statement Id: [InsertCategory.SelectKey] Prepared SQL:
[select last_insert_id() as value]
2018-03-15 10:55:11,601-Statement Id: [UpdateCategory] Prepared SQL: [update
category set category_name = ?param0 , parent_id = ?param1 ,
status = ?param2 , modified_by = ?param3 , modified_on = NOW()
where category_code = ?param4]
2018-03-15 10:55:11,601-Statement Id: [DeleteCategory] Prepared SQL: [delete from
category where category_id = ?param0]
2018-03-15 10:55:11,601-Adding file [NodeHelper.xml] to list of watched files.
2018-03-15 10:55:11,603-Statement Id: [MapNode] Prepared SQL: [select node_id,
node_code, node_name, address_line1, address_line2, status from node where node_id
= ?param0 union all select '' as node_id, '' as node_code, '' as
node_name, '' as address_line1, '' as address_line2, null as status limit 1]
2018-03-15 10:55:11,603-Statement Id: [SelectNodeByCode] Prepared SQL: [select
node_id, node_code, node_name, parent_id, location_id, address_line1,
address_line2, latitude, longitude, status, created_by, created_on,
modified_by, modified_on from node where node_code = ?param0]
2018-03-15 10:55:11,603-Statement Id: [SelectNodeForDuplicate] Prepared SQL:
[select node_id, node_code, node_name, parent_id, location_id, address_line1,
address_line2, latitude, longitude, status, created_by, created_on,
modified_by, modified_on from node where node_code = ?param0 and node_name
= ?param1 and parent_id = ?param2]
2018-03-15 10:55:11,604-Statement Id: [InsertNode] Prepared SQL: [insert into node
(node_code, node_name, parent_id, location_id, address_line1, address_line2,
latitude, longitude, status, created_by, created_on) values
( ?param0 , ?param1 , ?param2 , ?param3 , ?param4 , ?param5 , ?param6 , ?
param7 , ?param8 , ?param9 , NOW());]
2018-03-15 10:55:11,604-Statement Id: [InsertNode.SelectKey] Prepared SQL: [select
last_insert_id() as value]
2018-03-15 10:55:11,604-Statement Id: [UpdateNode] Prepared SQL: [update node set
node_name = ?param0 , parent_id = ?param1 , location_id = ?
param2 , address_line1 = ?param3 , address_line2 = ?param4 ,
latitude = ?param5 , longitude = ?param6 , status = ?param7 ,
modified_by = ?param8 , modified_on = NOW() where node_code = ?
param9]
2018-03-15 10:55:11,604-Statement Id: [DeleteNode] Prepared SQL: [delete from node
where node_id = ?param0]
2018-03-15 10:55:11,604-Adding file [AttributeHelper.xml] to list of watched files.
2018-03-15 10:55:11,605-Statement Id: [SelectAttributeByCode] Prepared SQL: [select
attribute_id, attribute_code, attribute_name, data_type, optional, status,
created_by, created_on, modified_by, modified_on from attribute where
attribute_code = ?param0]
2018-03-15 10:55:11,605-Statement Id: [InsertAttribute] Prepared SQL: [insert into
attribute (attribute_code, attribute_name, data_type, optional, status,
created_by, created_on) values ( ?param0 , ?param1 , ?param2 , ?
param3 , ?param4 , ?param5 , NOW());]
2018-03-15 10:55:11,605-Statement Id: [InsertAttribute.SelectKey] Prepared SQL:
[select last_insert_id() as value]
2018-03-15 10:55:11,605-Statement Id: [UpdateAttribute] Prepared SQL: [update
attribute set attribute_name = ?param0 , data_type = ?param1 ,
optional = ?param2 , status = ?param3 , modified_by = ?param4 ,
modified_on = NOW() where attribute_id = ?param5]
2018-03-15 10:55:11,605-Statement Id: [DeleteAttribute] Prepared SQL: [delete from
attribute where attribute_id = ?param0]
2018-03-15 10:55:11,606-Adding file [SKUHelper.xml] to list of watched files.
2018-03-15 10:55:11,607-Statement Id: [MapSKU] Prepared SQL: [select * from sku
where sku_id = ?param0]
2018-03-15 10:55:11,607-Statement Id: [SelectSKUByCode] Prepared SQL: [select
sku_id, sku_code, sku_name, sku_description, status, created_by, created_on,
modified_by, modified_on from sku where sku_code = ?param0]
2018-03-15 10:55:11,607-Statement Id: [SelectSKUForDuplicate] Prepared SQL: [select
sku_id, sku_code, sku_name, sku_description, status, created_by, created_on,
modified_by, modified_on from sku where sku_code = ?param0 and sku_name =
?param1 and sku_description = ?param2]
2018-03-15 10:55:11,607-Statement Id: [SelectBatchInsertedSKU] Prepared SQL:
[select sku_id, sku_code, sku_name, sku_description, status, created_by,
created_on, modified_by, modified_on from sku where sku_id >= (SELECT
(AUTO_INCREMENT - ?param0 ) FROM information_schema.`TABLES` WHERE TABLE_NAME =
'sku' LIMIT 1)]
2018-03-15 10:55:11,607-Statement Id: [InsertSKU] Prepared SQL: [insert into sku
(sku_code, sku_name, sku_description, status, created_by, created_on) values
( ?param0 , ?param1 , ?param2 , ?param3 , ?param4 , NOW());]
2018-03-15 10:55:11,607-Statement Id: [InsertSKU.SelectKey] Prepared SQL: [select
last_insert_id() as value]
2018-03-15 10:55:11,607-Statement Id: [UpdateSKU] Prepared SQL: [update sku set
sku_name = ?param0 , sku_description = ?param1 , status = ?
param2 , modified_by = ?param3 , modified_on = NOW() where
sku_id = ?param4]
2018-03-15 10:55:11,608-Statement Id: [DeleteSKU] Prepared SQL: [delete from sku
where sku_id = ?param0]
2018-03-15 10:55:11,608-Adding file [SKUAttributeHelper.xml] to list of watched
files.
2018-03-15 10:55:11,608-Statement Id: [SelectSKUAttributeMappingBySKUAttribute]
Prepared SQL: [select sku_attribute_mapping_id, sku_id, attribute_id, value,
created_by, created_on from sku_attribute_mapping where sku_id = ?param0
and attribute_id = ?param1]
2018-03-15 10:55:11,608-Statement Id: [SelectSKUAttributeMappingBySKU] Prepared
SQL: [select sku_attribute_mapping_id, sku_id, attribute_id, value, created_by,
created_on from sku_attribute_mapping where sku_id = ?param0]
2018-03-15 10:55:11,608-Statement Id: [InsertSKUAttributeMapping] Prepared SQL:
[insert into sku_attribute_mapping (sku_id, attribute_id, value, created_by,
created_on) values ( ?param0 , ?param1 , ?param2 , ?param3 ,
NOW());]
2018-03-15 10:55:11,608-Statement Id: [InsertSKUAttributeMapping.SelectKey]
Prepared SQL: [select last_insert_id() as value]
2018-03-15 10:55:11,608-Statement Id: [UpdateSKUAttributeMapping] Prepared SQL:
[update sku_attribute_mapping set value = ?param0 , where
sku_attribute_mapping_id = ?param1]
2018-03-15 10:55:11,608-Statement Id: [DeleteSKUAttributeMapping] Prepared SQL:
[delete from sku_attribute_mapping where sku_id = ?param0 and attribute_id
= ?param1]
2018-03-15 10:55:11,609-Adding file [NodeSKUHelper.xml] to list of watched files.
2018-03-15 10:55:11,610-Statement Id: [SelectNodeSKUMappingByNodeSKU] Prepared SQL:
[select node_sku_mapping_id, receiver_node_id, sku_id, supplier_node_id,
effective_date, created_by, created_on from node_sku_mapping where sku_id =
?param0 and receiver_node_id = ?param1 and supplier_node_id = ?param2 and
effective_date = ?param3]
2018-03-15 10:55:11,610-Statement Id: [selectSKU] Prepared SQL: [select * from sku
where sku_id = ?param0]
2018-03-15 10:55:11,610-Statement Id: [selectNode] Prepared SQL: [select * from
node where node_id = ?param0]
2018-03-15 10:55:11,610-Statement Id: [InsertNodeSKUMapping] Prepared SQL: [insert
into node_sku_mapping (receiver_node_id, sku_id, supplier_node_id,
effective_date, created_by, created_on) values ( ?param0 , ?param1 ,
?param2 , date_format( ?param3 , "%Y-%c-%e %H:%i:%s"), ?param4 , NOW());]
2018-03-15 10:55:11,611-Statement Id: [InsertNodeSKUMapping.SelectKey] Prepared
SQL: [select last_insert_id() as value]
2018-03-15 10:55:11,611-Statement Id: [DeleteNodeSKUMapping] Prepared SQL: [delete
from node_sku_mapping where node_sku_mapping_id = ?param0]
2018-03-15 10:55:11,611-Adding file [BufferNormHelper.xml] to list of watched
files.
2018-03-15 10:55:11,613-Statement Id: [MapBufferNorm] Prepared SQL: [select
buffer_norm_id, sku_id, node_id, buffer_norm, olt, plt, tlt, rlt,
max_sales_per_day, safety_factor, unit_selling_price, unit_purchase_price,
moq, eoq, effective_from, created_by, created_on, modified_by, modified_on
from buffer_norm where buffer_norm_id = ?param0 union all select '' as
buffer_norm_id, '' as sku_id, '' as node_id, 0 as buffer_norm, 0 as olt, 0 as plt,
0 as tlt, 0 as rlt, 0 as max_sales_per_day, 0 as safety_factor, 0 as
unit_selling_price, 0 as unit_purchase_price, 0 as moq, 0 as eoq, '' as
effective_from, null as created_by, null as created_on, null as modified_by, null
as modified_on limit 1]
2018-03-15 10:55:11,613-Statement Id: [SelectBufferNormBySKUNode] Prepared SQL:
[select buffer_norm_id, sku_id, node_id, buffer_norm, olt, plt, tlt, rlt,
max_sales_per_day, safety_factor, unit_selling_price, unit_purchase_price,
moq, eoq, effective_from, created_by, created_on, modified_by,
modified_on,IFNULL(is_default_zone,'Y') AS is_default_zone, IFNULL(red_zone,0) AS
red_zone, IFNULL(yellow_zone,0) AS yellow_zone from buffer_norm where sku_id
= ?param0 and node_id = ?param1 and effective_from = ?param2]
2018-03-15 10:55:11,613-Statement Id: [SelectBatchInsertedBufferNorm] Prepared SQL:
[select b.buffer_norm_id, b.sku_id, b.node_id, b.buffer_norm, b.olt, b.plt, b.tlt,
b.rlt, b.max_sales_per_day, b.safety_factor, b.unit_selling_price,
b.unit_purchase_price, b.moq, b.eoq, b.effective_from, b.created_by, b.created_on,
b.modified_by, b.modified_on, b.identifier, b.is_default_zone, b.red_zone,
b.yellow_zone from buffer_norm b where identifier = ?param0]
2018-03-15 10:55:11,614-Statement Id: [InsertBufferNorm] Prepared SQL: [insert into
buffer_norm (sku_id, node_id, buffer_norm, olt, plt, tlt, rlt,
max_sales_per_day, safety_factor, unit_selling_price, unit_purchase_price,
moq, eoq, effective_from, created_by, created_on) values ( ?param0 ,
?param1 , ?param2 , ?param3 , ?param4 , ?param5 , ?param6 , ?param7 , ?
param8 , ?param9 , ?param10 , ?param11 , ?param12 , date_format( ?
param13 , "%Y-%c-%e %H:%i:%s"), ?param14 , NOW());]
2018-03-15 10:55:11,614-Statement Id: [InsertBufferNorm.SelectKey] Prepared SQL:
[select last_insert_id() as value]
2018-03-15 10:55:11,615-Statement Id: [UpdateBufferNorm] Prepared SQL: [update
buffer_norm set sku_id = ?param0 , node_id = ?param1 ,
buffer_norm = ?param2 , olt = ?param3 , plt = ?param4 , tlt
= ?param5 , rlt = ?param6 , max_sales_per_day = ?param7 ,
safety_factor = ?param8 , unit_selling_price = ?param9 ,
unit_purchase_price = ?param10 , moq = ?param11 , eoq = ?param12 ,
effective_from = date_format( ?param13 , "%Y-%c-%e %H:%i:%s"), modified_by =
?param14 , modified_on = NOW() where buffer_norm_id = ?param15]
2018-03-15 10:55:11,615-Statement Id: [DeleteBufferNorm] Prepared SQL: [delete from
buffer_norm where buffer_norm_id = ?param0]
2018-03-15 10:55:11,615-Adding file [TransactionHelper.xml] to list of watched
files.
2018-03-15 10:55:11,620-Statement Id: [SelectTransactionForDuplicate] Prepared SQL:
[select transaction_id, sku_id, node_id, supply_node_id, transaction_date, grn,
sales, closing_quantity, in_transit, inst_hold, quality_hold, qa_hold,
pending_orders, orders_in_hand, transport_mode, db_sync, mongo_sync, created_by,
created_on, open_stock_transfer_order, open_planned_order,
open_purchase_request, open_production_order, open_purchase_order, field1, field2,
field3, field4, field5, field6, field7, field8, field9, field10 from
transaction where sku_id = ?param0 and node_id = ?param1 and transaction_date =
?param2]
2018-03-15 10:55:11,621-Statement Id: [SelectReplenishmentList] Prepared SQL:
[select tr.transaction_id, tr.transaction_date,
date_format(tr.transaction_date,'%d/%m/%Y') as display_date,
date_format(tr.transaction_date,'%Y%m%d') as transfilter_date, tr.sku_id,
s.sku_code, s.sku_name, tr.node_id, n.node_code, n.node_name, sc.category_id,
cat.category_code, cat.category_name, ifnull(bn.buffer_norm, 0) as
buffer_norm, ifnull(tr.closing_quantity, 0) as closing_quantity,
ifnull(tr.in_transit, 0) as in_transit, ifnull(tr.sales, 0) as sales,
ifnull(tr.inst_hold, 0) as inst_hold, ifnull(tr.quality_hold, 0) as quality_hold,
ifnull(tr.qa_hold, 0) as qa_hold, ifnull(tr.pending_orders, 0) as
pending_orders, ifnull(tr.orders_in_hand, 0) as orders_in_hand,
ifnull(tr.transport_mode, '') as transport_mode, nsm.supplier_node_id as
supply_node_id, sn.node_name as supply_node_name, sn.node_code as
supply_node_code, ifnull(str.closing_quantity, 0) as supplying_quantity,
ifnull(sbn.buffer_norm, 0) as supplying_buffer_norm,
round(ifnull(bn.buffer_norm, 0),2) as 'green_zone_qty', CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2)
END AS 'yellow_zone_qty', CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END as 'red_zone_qty', case
when ifnull(bn.buffer_norm, 0) = 0 then 'White' when
(ifnull(tr.closing_quantity, 0) <= 0 and ifnull(bn.buffer_norm, 0) > 0) then
'Black' when (ifnull(tr.closing_quantity, 0) > ifnull(bn.buffer_norm, 0) and
ifnull(bn.buffer_norm, 0) > 0) then 'Blue' when (ifnull(tr.closing_quantity,
0) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) and ifnull(tr.closing_quantity,
0) <= ifnull(bn.buffer_norm, 0) and ifnull(bn.buffer_norm, 0) > 0) then 'Green'
when (ifnull(tr.closing_quantity, 0) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) and ifnull(tr.closing_quantity, 0) <=
(CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) and ifnull(bn.buffer_norm, 0) >
0) then 'Yellow' when (ifnull(tr.closing_quantity, 0) > 0 and
ifnull(tr.closing_quantity, 0) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) and ifnull(bn.buffer_norm, 0) > 0) then
'Red' end as 'closing_stock_zone', case when
ifnull(bn.buffer_norm, 0) = 0 then 6 when (ifnull(tr.closing_quantity, 0) <=
0 and ifnull(bn.buffer_norm, 0) > 0) then 1 when
(ifnull(tr.closing_quantity, 0) > ifnull(bn.buffer_norm, 0) and
ifnull(bn.buffer_norm, 0) > 0) then 2 when (ifnull(tr.closing_quantity, 0) >
(CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) and ifnull(tr.closing_quantity,
0) <= ifnull(bn.buffer_norm, 0) and ifnull(bn.buffer_norm, 0) > 0) then 4
when (ifnull(tr.closing_quantity, 0) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) and ifnull(tr.closing_quantity, 0) <=
(CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) and ifnull(bn.buffer_norm, 0) >
0) then 3 when (ifnull(tr.closing_quantity, 0) > 0 and
ifnull(tr.closing_quantity, 0) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) and ifnull(bn.buffer_norm, 0) > 0) then
5 end as 'closing_stock_zone_sort', case when
ifnull(bn.buffer_norm, 0) = 0 then 'White' when
((ifnull(tr.closing_quantity, 0) + ifnull(tr.in_transit, 0) -
ifnull(tr.pending_orders, 0)) <= 0 and ifnull(bn.buffer_norm, 0) > 0) then 'Black'
when ((ifnull(tr.closing_quantity, 0) + ifnull(tr.in_transit, 0) -
ifnull(tr.pending_orders, 0)) > ifnull(bn.buffer_norm, 0) and
ifnull(bn.buffer_norm, 0) > 0) then 'Blue' when
((ifnull(tr.closing_quantity, 0) + ifnull(tr.in_transit, 0) -
ifnull(tr.pending_orders, 0)) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) and
(ifnull(tr.closing_quantity, 0) + tr.in_transit - tr.pending_orders) <=
ifnull(bn.buffer_norm, 0) and ifnull(bn.buffer_norm, 0) > 0) then 'Green'
when ((ifnull(tr.closing_quantity, 0) + ifnull(tr.in_transit, 0) -
ifnull(tr.pending_orders, 0)) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) and (tr.closing_quantity +
tr.in_transit - tr.pending_orders) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2)
ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) and ifnull(bn.buffer_norm,
0) > 0) then 'Yellow' when ((ifnull(tr.closing_quantity, 0) +
ifnull(tr.in_transit, 0) - ifnull(tr.pending_orders, 0)) > 0 and
(ifnull(tr.closing_quantity, 0) + tr.in_transit - tr.pending_orders) <= (CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) and
ifnull(bn.buffer_norm, 0) > 0) then 'Red' end as 'in_transit_zone',
case when ifnull(bn.buffer_norm, 0) = 0 then 6 when
((ifnull(tr.closing_quantity, 0) + ifnull(tr.in_transit, 0) -
ifnull(tr.pending_orders, 0)) <= 0 and ifnull(bn.buffer_norm, 0) > 0) then 1
when ((ifnull(tr.closing_quantity, 0) + ifnull(tr.in_transit, 0) -
ifnull(tr.pending_orders, 0)) > ifnull(bn.buffer_norm, 0) and
ifnull(bn.buffer_norm, 0) > 0) then 2 when ((ifnull(tr.closing_quantity, 0)
+ ifnull(tr.in_transit, 0) - ifnull(tr.pending_orders, 0)) > (CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2)
END) and (ifnull(tr.closing_quantity, 0) + tr.in_transit - tr.pending_orders) <=
ifnull(bn.buffer_norm, 0) and ifnull(bn.buffer_norm, 0) > 0) then 4 when
((ifnull(tr.closing_quantity, 0) + ifnull(tr.in_transit, 0) -
ifnull(tr.pending_orders, 0)) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) and (ifnull(tr.closing_quantity, 0) +
tr.in_transit - tr.pending_orders) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2)
ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) and ifnull(bn.buffer_norm,
0) > 0) then 3 when ((ifnull(tr.closing_quantity, 0) + ifnull(tr.in_transit,
0) - ifnull(tr.pending_orders, 0)) > 0 and (ifnull(tr.closing_quantity, 0) +
tr.in_transit - tr.pending_orders) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) and ifnull(bn.buffer_norm, 0) > 0) then
5 end as 'in_transit_zone_sort', case when
ifnull(sbn.buffer_norm, 0) = 0 then 'White' when
(ifnull(str.closing_quantity, 0) <= 0 and ifnull(sbn.buffer_norm, 0) > 0) then
'Black' when (ifnull(str.closing_quantity, 0) > ifnull(sbn.buffer_norm, 0)
and ifnull(sbn.buffer_norm, 0) > 0) then 'Blue' when
(ifnull(str.closing_quantity, 0) > (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) and
ifnull(str.closing_quantity, 0) <= ifnull(sbn.buffer_norm, 0) and
ifnull(sbn.buffer_norm, 0) > 0) then 'Green' when
(ifnull(str.closing_quantity, 0) > (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) and ifnull(str.closing_quantity, 0) <=
(CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) and ifnull(sbn.buffer_norm, 0)
> 0) then 'Yellow' when (ifnull(str.closing_quantity, 0) > 0 and
ifnull(str.closing_quantity, 0) <= (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) and ifnull(sbn.buffer_norm, 0) > 0)
then 'Red' end as 'supplying_node_zone', case when
ifnull(sbn.buffer_norm, 0) = 0 then 6 when (ifnull(str.closing_quantity, 0)
<= 0 and ifnull(sbn.buffer_norm, 0) > 0) then 1 when
(ifnull(str.closing_quantity, 0) > ifnull(sbn.buffer_norm, 0) and
ifnull(sbn.buffer_norm, 0) > 0) then 2 when (ifnull(str.closing_quantity,
0) > (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) and
ifnull(str.closing_quantity, 0) <= ifnull(sbn.buffer_norm, 0) and
ifnull(sbn.buffer_norm, 0) > 0) then 4 when (ifnull(str.closing_quantity, 0)
> (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) and ifnull(str.closing_quantity, 0) <=
(CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) and ifnull(sbn.buffer_norm, 0)
> 0) then 3 when (ifnull(str.closing_quantity, 0) > 0 and
ifnull(str.closing_quantity, 0) <= (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) and ifnull(sbn.buffer_norm, 0) > 0)
then 5 end as 'supplying_node_zone_sort', case when
((ifnull(bn.buffer_norm, 0) - ifnull(tr.closing_quantity, 0) -
ifnull(tr.in_transit, 0)) + ifnull(tr.pending_orders, 0)) -
(ifnull(tr.open_planned_order, 0) + ifnull(tr.open_purchase_request, 0) +
ifnull(tr.open_production_order, 0) + ifnull(tr.open_purchase_order, 0)) <= 0 then
0 else ((ifnull(bn.buffer_norm, 0) - ifnull(tr.closing_quantity, 0) -
ifnull(tr.in_transit, 0)) + ifnull(tr.pending_orders, 0)) -
(ifnull(tr.open_planned_order, 0) + ifnull(tr.open_purchase_request, 0) +
ifnull(tr.open_production_order, 0) + ifnull(tr.open_purchase_order, 0)) end
as 'replenishment_quantity', case when (ifnull(tr.closing_quantity,
0) + ifnull(tr.in_transit, 0) + ifnull(tr.open_planned_order, 0) +
ifnull(tr.open_purchase_request, 0) + ifnull(tr.open_production_order, 0) +
ifnull(tr.open_purchase_order, 0) ) - ifnull(tr.pending_orders, 0) <= 0 then 0
else (ifnull(tr.closing_quantity, 0) + ifnull(tr.in_transit, 0) +
ifnull(tr.open_planned_order, 0) + ifnull(tr.open_purchase_request, 0) +
ifnull(tr.open_production_order, 0) + ifnull(tr.open_purchase_order, 0) ) -
ifnull(tr.pending_orders, 0) end as 'final_quantity', case
when ifnull(bn.buffer_norm, 0) = 0 then 0 else (CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END)
end as 'mrq', (select count(1) from transaction_comment where
transaction_id = tr.transaction_id) as 'transaction_comment',
ifnull(tr.open_stock_transfer_order, 0) as open_stock_transfer_order,
ifnull(tr.open_planned_order, 0) as open_planned_order,
ifnull(tr.open_purchase_request, 0) as open_purchase_request,
ifnull(tr.open_production_order, 0) as open_production_order,
ifnull(tr.open_purchase_order, 0) as open_purchase_order, tr.field1,
tr.field2, tr.field3, tr.field4, tr.field5, tr.field6, tr.field7, tr.field8,
tr.field9, tr.field10 from ( select transaction_id from
transaction where transaction_date = ?param0 limit ?param1 , ?
param2 ) otr join transaction tr on tr.transaction_id
= otr.transaction_id left join buffer_norm bn on bn.sku_id =
tr.sku_id and bn.node_id = tr.node_id and bn.effective_from = (
select max(effective_from) from buffer_norm where effective_from <=
tr.transaction_date and sku_id = tr.sku_id and node_id = tr.node_id)
left join sku s on s.sku_id = tr.sku_id left join sku_category sc
on sc.sku_id = tr.sku_id left join category cat on cat.category_id
= sc.category_id left join node n on n.node_id = tr.node_id
left join node_sku_mapping nsm on nsm.receiver_node_id = tr.node_id
and nsm.sku_id = tr.sku_id and nsm.effective_date = ( select
max(effective_date) from node_sku_mapping where effective_date <=
tr.transaction_date and sku_id = tr.sku_id and receiver_node_id =
tr.node_id) left join node sn on sn.node_id = nsm.supplier_node_id
left join buffer_norm sbn on sbn.sku_id = nsm.sku_id and sbn.node_id
= nsm.supplier_node_id and sbn.effective_from = ( select
max(effective_from) from buffer_norm where effective_from <=
tr.transaction_date and sku_id = tr.sku_id and node_id = tr.node_id)
left join ( select transaction_id, sku_id, node_id, closing_quantity
from transaction where transaction_date = ?param0 ) str
on str.sku_id = nsm.sku_id and str.node_id = nsm.supplier_node_id and
str.transaction_id = otr.transaction_id order by tr.transaction_id]
2018-03-15 10:55:11,621-Statement Id: [MapTransaction] Prepared SQL: [select * from
transaction where transaction_id = ?param0]
2018-03-15 10:55:11,621-Statement Id: [SelectMaxTransactionDate] Prepared SQL:
[select date_sub(max(transaction_date), interval 15 day) as avg_date,
max(transaction_date) as transaction_date from transaction]
2018-03-15 10:55:11,621-Statement Id: [SelectSKUNodeGroup] Prepared SQL: [select
sku_id, node_id from transaction group by sku_id, node_id]
2018-03-15 10:55:11,621-Statement Id: [SelectTransactionBySKUNode] Prepared SQL:
[select transaction_id, sku_id, node_id, supply_node_id, transaction_date, grn,
sales, closing_quantity, in_transit, inst_hold, quality_hold, qa_hold,
pending_orders, orders_in_hand, transport_mode, db_sync, mongo_sync, created_by,
created_on, open_stock_transfer_order, open_planned_order,
open_purchase_request, open_production_order, open_purchase_order, field1, field2,
field3, field4, field5, field6, field7, field8, field9, field10 from
transaction where sku_id = ?param0 and node_id = ?param1]
2018-03-15 10:55:11,621-Statement Id: [SelectTransactionByDate] Prepared SQL:
[select transaction_id, sku_id, node_id, supply_node_id, transaction_date, grn,
sales, closing_quantity, in_transit, inst_hold, quality_hold, qa_hold,
pending_orders, orders_in_hand, transport_mode, db_sync, mongo_sync, created_by,
created_on, open_stock_transfer_order, open_planned_order,
open_purchase_request, open_production_order, open_purchase_order, field1, field2,
field3, field4, field5, field6, field7, field8, field9, field10 from
transaction where transaction_date = ?param0]
2018-03-15 10:55:11,621-Statement Id: [SelectTransactionDates] Prepared SQL:
[select DATE_FORMAT(transaction_date, '%Y-%m-%d %H:%i:%s') as transaction_date from
transaction group by transaction_date asc limit ?param0]
2018-03-15 10:55:11,621-Statement Id: [SelectBNCalculationTransactionDates]
Prepared SQL: [select DATE_FORMAT(transaction_date, '%Y-%m-%d %H:%i:%s') as
transaction_date from transaction where transaction_date >= ?param0
group by transaction_date asc]
2018-03-15 10:55:11,621-Statement Id: [SelectTransactionIdsForBNCalculation]
Prepared SQL: [select transaction_id from transaction where transaction_date
= ?param0 and sku_id = ?param1 and node_id = ?param2]
2018-03-15 10:55:11,622-Statement Id: [SelectBatchInsertedTransactionID] Prepared
SQL: [select transaction_id, identifier from transaction where identifier = ?
param0]
2018-03-15 10:55:11,622-Statement Id: [SelectUpdateTransactionImport] Prepared SQL:
[select DISTINCT transaction_id from update_transaction WHERE identifier = ?
param0]
2018-03-15 10:55:11,622-Statement Id: [SelectClosingStockForTransactionDate]
Prepared SQL: [SELECT transaction_date, closing_quantity, sales, grn from
transaction WHERE transaction_date < ?param0 AND sku_id = ?param1
AND node_id = ?param2 ORDER BY transaction_date DESC LIMIT 1]
2018-03-15 10:55:11,622-Statement Id: [InsertTransaction] Prepared SQL: [insert
into transaction (sku_id, node_id, supply_node_id, transaction_date, grn,
sales, closing_quantity, in_transit, inst_hold, quality_hold, qa_hold,
pending_orders, orders_in_hand, transport_mode, db_sync, mongo_sync, created_by,
created_on, open_stock_transfer_order, open_planned_order,
open_purchase_request, open_production_order, open_purchase_order, field1, field2,
field3, field4, field5, field6, field7, field8, field9, field10) values
( ?param0 , ?param1 , ?param2 , ?param3 , ?param4 , ?param5 , ?param6 , ?
param7 , ?param8 , ?param9 , ?param10 , ?param11 , ?param12 , ?param13
, 0, 0, ?param14 , NOW(), ?param15 , ?param16 , ?param17 , ?
param18 , ?param19 , ?param20 , ?param21 , ?param22 , ?param23 , ?param24 ,
?param25 , ?param26 , ?param27 , ?param28 , ?param29 );]
2018-03-15 10:55:11,622-Statement Id: [InsertTransaction.SelectKey] Prepared SQL:
[select last_insert_id() as value]
2018-03-15 10:55:11,623-Statement Id: [InsertTransactionComment] Prepared SQL:
[insert into transaction_comment (transaction_id, sku_id, node_id, comment,
reason, created_by, created_on) values ( ?param0 , ?param1 , ?
param2 , ?param3 , ?param4 , ?param5 , NOW());]
2018-03-15 10:55:11,623-Statement Id: [InsertTransactionComment.SelectKey] Prepared
SQL: [select last_insert_id() as value]
2018-03-15 10:55:11,623-Statement Id: [UpdateTransaction] Prepared SQL: [update
transaction set sku_id = ?param0 , node_id = ?param1 ,
supply_node_id = ?param2 , transaction_date = ?param3 , grn = ?
param4 , sales = ?param5 , closing_quantity = ?param6 ,
in_transit = ?param7 , inst_hold = ?param8 , quality_hold = ?
param9 , qa_hold = ?param10 , pending_orders = ?param11 ,
orders_in_hand = ?param12 , transport_mode = ?param13 , db_sync
= ?param14 , mongo_sync = ?param15 where transaction_id = ?
param16]
2018-03-15 10:55:11,623-Statement Id: [DeleteUpdatesTransaction] Prepared SQL:
[delete from update_transaction WHERE identifier = ?param0]
2018-03-15 10:55:11,623-Adding file [SKUCategoryHelper.xml] to list of watched
files.
2018-03-15 10:55:11,624-Statement Id: [SelectSKUCategoryBySKUCategory] Prepared
SQL: [select sku_category_id, sku_id, category_id, created_by, created_on
from sku_category where sku_id = ?param0 and category_id = ?param1]
2018-03-15 10:55:11,624-Statement Id: [InsertSKUCategory] Prepared SQL: [insert
into sku_category (sku_id, category_id, created_by, created_on)
values ( ?param0 , ?param1 , ?param2 , NOW());]
2018-03-15 10:55:11,624-Statement Id: [InsertSKUCategory.SelectKey] Prepared SQL:
[select last_insert_id() as value]
2018-03-15 10:55:11,624-Adding file [SKUChartHelper.xml] to list of watched files.
2018-03-15 10:55:11,625-Statement Id: [SelectSKUChart] Prepared SQL: [select
rpl.transaction_date, date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date,
sum(rpl.closing_quantity) as closing_quantity, sum(rpl.red_zone_qty) as
red_zone_qty, sum(rpl.yellow_zone_qty) as yellow_zone_qty,
sum(rpl.green_zone_qty) as green_zone_qty, sum(rpl.in_transit) as in_transit,
sum(rpl.sales) as sales, count(distinct(rpl.sku_id)) as total_sku_count,
(select count(distinct(sku_id)) from replenishment where closing_stock_zone_sort =
2 and transaction_date = rpl.transaction_date) as blue_sku_count, (select
count(distinct(sku_id)) from replenishment where (closing_stock_zone_sort = 1 or
closing_stock_zone_sort = 5) and transaction_date = rpl.transaction_date) as
rb_sku_count from replenishment rpl where rpl.transaction_date = ?
param0 group by rpl.transaction_date]
2018-03-15 10:55:11,625-Statement Id: [SelectSKUChartNode] Prepared SQL: [select
rpl.transaction_date, date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date, rpl.node_id,
sum(rpl.closing_quantity) as closing_quantity, sum(rpl.red_zone_qty) as
red_zone_qty, sum(rpl.yellow_zone_qty) as yellow_zone_qty,
sum(rpl.green_zone_qty) as green_zone_qty, sum(rpl.in_transit) as in_transit,
sum(rpl.sales) as sales, count(distinct(rpl.sku_id)) as total_sku_count,
ifnull((select count(distinct(sku_id)) from replenishment where
closing_stock_zone_sort = 2 and transaction_date = rpl.transaction_date and node_id
= rpl.node_id), 0) as blue_sku_count, ifnull((select count(distinct(sku_id))
from replenishment where (closing_stock_zone_sort = 1 or closing_stock_zone_sort =
5) and transaction_date = rpl.transaction_date and node_id = rpl.node_id), 0) as
rb_sku_count from replenishment rpl where rpl.transaction_date = ?
param0 group by rpl.transaction_date, rpl.node_id]
2018-03-15 10:55:11,625-Statement Id: [SelectSKUChartCategory] Prepared SQL:
[select rpl.transaction_date, date_format(rpl.transaction_date,'%d/%m/%Y') as
display_date, date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date,
rpl.category_id, sum(rpl.closing_quantity) as closing_quantity,
sum(rpl.red_zone_qty) as red_zone_qty, sum(rpl.yellow_zone_qty) as yellow_zone_qty,
sum(rpl.green_zone_qty) as green_zone_qty, sum(rpl.in_transit) as in_transit,
sum(rpl.sales) as sales, count(distinct(rpl.sku_id)) as total_sku_count,
ifnull((select count(distinct(sku_id)) from replenishment where
closing_stock_zone_sort = 2 and transaction_date = rpl.transaction_date and
category_id = rpl.category_id), 0) as blue_sku_count, ifnull((select
count(distinct(sku_id)) from replenishment where (closing_stock_zone_sort = 1 or
closing_stock_zone_sort = 5) and transaction_date = rpl.transaction_date and
category_id = rpl.category_id), 0) as rb_sku_count from replenishment rpl
where rpl.transaction_date = ?param0 and rpl.category_id is not null
group by rpl.transaction_date, rpl.category_id]
2018-03-15 10:55:11,625-Statement Id: [SelectSKUChartSKU] Prepared SQL: [select
rpl.transaction_date, date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date, rpl.sku_id,
sum(rpl.closing_quantity) as closing_quantity, sum(rpl.red_zone_qty) as
red_zone_qty, sum(rpl.yellow_zone_qty) as yellow_zone_qty,
sum(rpl.green_zone_qty) as green_zone_qty, sum(rpl.in_transit) as in_transit,
sum(rpl.sales) as sales, count(distinct(rpl.sku_id)) as total_sku_count,
ifnull((select count(distinct(sku_id)) from replenishment where
closing_stock_zone_sort = 2 and transaction_date = rpl.transaction_date and sku_id
= rpl.sku_id), 0) as blue_sku_count, ifnull((select count(distinct(sku_id))
from replenishment where (closing_stock_zone_sort = 1 or closing_stock_zone_sort =
5) and transaction_date = rpl.transaction_date and sku_id = rpl.sku_id), 0) as
rb_sku_count from replenishment rpl use index(inx_sku_chart_s) where
rpl.transaction_date = ?param0 group by rpl.transaction_date, rpl.sku_id]
2018-03-15 10:55:11,626-Adding file [ImportExportLogHelper.xml] to list of watched
files.
2018-03-15 10:55:11,626-Statement Id: [SelectImportExportLogByType] Prepared SQL:
[select import_export_log_id, reference_date, reference_type, reference_title,
type, log_file, status, status_text, comment, created_by, created_on from
import_export_log where type = ?param0 order by reference_date desc]
2018-03-15 10:55:11,626-Statement Id: [InsertImportExportLog] Prepared SQL: [insert
into import_export_log (reference_date, reference_type, reference_title,
type, log_file, status, status_text, comment, created_by, created_on) values
(date_format( ?param0 , "%Y-%c-%e %H:%i:%s"), ?param1 , ?param2 , ?param3 , ?
param4 , ?param5 , ?param6 , ?param7 , ?param8 , NOW() );]
2018-03-15 10:55:11,626-Statement Id: [InsertImportExportLog.SelectKey] Prepared
SQL: [select last_insert_id() as value]
2018-03-15 10:55:11,627-Statement Id: [UpdateImportExportLog] Prepared SQL: [update
import_export_log set reference_date = date_format( ?param0 , "%Y-%c-%e %H:
%i:%s"), reference_type = ?param1 , reference_title = ?param2 ,
type = ?param3 , log_file = ?param4 , status = ?param5 ,
status_text = ?param6 , comment = ?param7 where
import_export_log_id = ?param8]
2018-03-15 10:55:11,627-Statement Id: [DeleteImportExportLog] Prepared SQL: [delete
from import_export_log where import_export_log_id = ?param0]
2018-03-15 10:55:11,627-Adding file [DynamicBufferManagementHelper.xml] to list of
watched files.
2018-03-15 10:55:11,629-Statement Id: [InsertDynamicBufferManagement] Prepared SQL:
[insert into dynamic_buffer_management (activate_auto_dbm,
excess_inv_occ_count, excess_inv_decrease_per, excess_inv_wait_cycle,
stockout_inv_occ_count, stockout_inv_decrease_per, stockout_inv_wait_cycle,
override_sku_location_dbm, activate_auto_dcm, red_percentage,
yellow_percentage, green_percentage, created_by, created_on) values (
?param0 , ?param1 , ?param2 , ?param3 , ?param4 , ?param5 , ?param6 ,
?param7 , ?param8 , ?param9 , ?param10 , ?param11 , ?param12 , NOW());]
2018-03-15 10:55:11,629-Statement Id: [InsertDynamicBufferManagement.SelectKey]
Prepared SQL: [select last_insert_id() as value]
2018-03-15 10:55:11,630-Statement Id: [UpdateDynamicBufferManagement] Prepared SQL:
[update dynamic_buffer_management set activate_auto_dbm = ?param0 ,
excess_inv_occ_count = ?param1 , excess_inv_decrease_per = ?param2 ,
excess_inv_wait_cycle = ?param3 , stockout_inv_occ_count = ?param4 ,
stockout_inv_decrease_per = ?param5 , stockout_inv_wait_cycle = ?param6 ,
override_sku_location_dbm = ?param7 , activate_auto_dcm = ?param8 ,
red_percentage = ?param9 , yellow_percentage = ?param10 ,
green_percentage = ?param11 , modified_by = ?param12 , modified_on
= NOW() where dynamic_buffer_management_id = ?param13]
2018-03-15 10:55:11,630-Adding file [ReplenishmentHelper.xml] to list of watched
files.
2018-03-15 10:55:11,631-Statement Id: [SelectReplenishmentData] Prepared SQL:
[select transaction_id, transaction_date, display_date, transfilter_date, sku_id,
sku_code, sku_name, node_id, node_code, node_name, category_id,
category_code, category_name, buffer_norm, grn, closing_quantity, in_transit,
sales, inst_hold, quality_hold, qa_hold, pending_orders, orders_in_hand,
transport_mode, supply_node_id, supply_node_name, supply_node_code,
supplying_quantity, supplying_buffer_norm, green_zone_qty, yellow_zone_qty,
red_zone_qty, closing_stock_zone, closing_stock_zone_sort, in_transit_zone,
in_transit_zone_sort, supplying_node_zone, supplying_node_zone_sort,
replenishment_quantity, final_quantity, mrq, transaction_comment,
open_stock_transfer_order, open_planned_order, open_purchase_request,
open_production_order, open_purchase_order, field1, field2, field3, field4,
field5, field6, field7, field8, field9, field10, mtd_sales, mtd_grn from
replenishment where transaction_date = ?param0]
2018-03-15 10:55:11,631-Statement Id: [SelectReplenishmentBySKUNode] Prepared SQL:
[select transaction_id, transaction_date, display_date, transfilter_date, sku_id,
sku_code, sku_name, node_id, node_code, node_name, category_id,
category_code, category_name, buffer_norm, closing_quantity, grn, in_transit,
sales, inst_hold, quality_hold, qa_hold, pending_orders, orders_in_hand,
transport_mode, supply_node_id, supply_node_name, supply_node_code,
supplying_quantity, supplying_buffer_norm, green_zone_qty, yellow_zone_qty,
red_zone_qty, closing_stock_zone, closing_stock_zone_sort, in_transit_zone,
in_transit_zone_sort, supplying_node_zone, supplying_node_zone_sort,
replenishment_quantity, final_quantity, mrq, transaction_comment,
open_stock_transfer_order, open_planned_order, open_purchase_request,
open_production_order, open_purchase_order, field1, field2, field3, field4,
field5, field6, field7, field8, field9, field10, mtd_sales, mtd_grn from
replenishment where transaction_date = ?param0 and sku_id = ?
param1 and node_id = ?param2]
2018-03-15 10:55:11,631-Statement Id: [SelectReplenishmentDates] Prepared SQL:
[SELECT DATE_FORMAT(transaction_date,'%Y-%m-%d') AS transaction_date FROM
replenishment USE INDEX (transaction_date) WHERE (transaction_date
BETWEEN ?param0 and ?param1 ) GROUP BY transaction_date]
2018-03-15 10:55:11,632-Statement Id: [InsertReplenishmentList] Prepared SQL:
[insert into replenishment (transaction_id, transaction_date, display_date,
transfilter_date, sku_id, sku_code, sku_name, node_id, node_code, node_name,
category_id, category_code, category_name, buffer_norm, grn, in_transit,
sales, inst_hold, quality_hold, qa_hold, pending_orders, orders_in_hand,
transport_mode, supply_node_id, supply_node_name, supply_node_code,
supplying_quantity, supplying_buffer_norm, green_zone_qty, yellow_zone_qty,
red_zone_qty, closing_stock_zone, closing_stock_zone_sort, in_transit_zone,
in_transit_zone_sort, supplying_node_zone, supplying_node_zone_sort,
replenishment_quantity, final_quantity, mrq, transaction_comment, db_sync,
mongo_sync, open_stock_transfer_order, open_planned_order,
open_purchase_request, open_production_order, open_purchase_order, field1,
field2, field3, field4, field5, field6, field7, field8, field9, field10,
closing_quantity, mtd_sales, mtd_grn ) SELECT tmt.transaction_id,
tmt.transaction_date, tmt.display_date, tmt.transfilter_date, tmt.sku_id,
tmt.sku_code, tmt.sku_name, tmt.node_id, tmt.node_code, tmt.node_name,
tmt.category_id, tmt.category_code, tmt.category_name, tmt.buffer_norm,
tmt.grn, tmt.in_transit, tmt.sales, tmt.inst_hold, tmt.quality_hold,
tmt.qa_hold, tmt.pending_orders, tmt.orders_in_hand, tmt.transport_mode,
tmt.supply_node_id, tmt.supply_node_name, tmt.supply_node_code,
tmt.supplying_quantity, tmt.supplying_buffer_norm, tmt.green_zone_qty,
tmt.yellow_zone_qty, tmt.red_zone_qty, tmt.closing_stock_zone,
tmt.closing_stock_zone_sort, tmt.in_transit_zone, tmt.in_transit_zone_sort,
tmt.supplying_node_zone, tmt.supplying_node_zone_sort,
tmt.replenishment_quantity, tmt.final_quantity, tmt.mrq,
tmt.transaction_comment, tmt.db_sync, tmt.mongo_sync,
tmt.open_stock_transfer_order, tmt.open_planned_order, tmt.open_purchase_request,
tmt.open_production_order, tmt.open_purchase_order, tmt.field1, tmt.field2,
tmt.field3, tmt.field4, tmt.field5, tmt.field6, tmt.field7, tmt.field8, tmt.field9,
tmt.field10, CASE WHEN IFNULL(tmt.closing_quantity,0) > 0 THEN
tmt.closing_quantity ELSE IFNULL((SELECT tcl.closing_quantity FROM
TRANSACTION tcl WHERE tcl.transaction_date < tmt.transaction_date AND
tcl.sku_id = tmt.sku_id AND tcl.node_id = tmt.node_id ORDER BY
tcl.transaction_date DESC LIMIT 1), 0) END AS closing_quantity,
IFNULL((SELECT SUM(tms.sales) FROM TRANSACTION tms USE INDEX
(inx_tdt_sku_node_sales) WHERE tms.transaction_date <= tmt.transaction_date
AND tms.transaction_date >= DATE_FORMAT(tmt.transaction_date,'%Y-%m-01') AND
tms.sku_id = tmt.sku_id AND tms.node_id = tmt.node_id), 0) AS mtd_sales,
IFNULL((SELECT SUM(tmg.grn) FROM TRANSACTION tmg USE INDEX (inx_tdt_sku_node_grn)
WHERE tmg.transaction_date <= tmt.transaction_date AND tmg.transaction_date >=
DATE_FORMAT(tmt.transaction_date,'%Y-%m-01') AND tmg.sku_id = tmt.sku_id AND
tmg.node_id = tmt.node_id), 0) AS mtd_grn FROM (SELECT
tr.transaction_id, tr.transaction_date, DATE_FORMAT(tr.transaction_date,'%d/%m/%Y')
AS display_date, DATE_FORMAT(tr.transaction_date,'%Y%m%d') AS transfilter_date,
tr.sku_id, s.sku_code, s.sku_name, tr.node_id, n.node_code, n.node_name,
sc.category_id, cat.category_code, cat.category_name, IFNULL(bn.buffer_norm,
0) AS buffer_norm, IFNULL(tr.closing_quantity, 0) AS closing_quantity,
IFNULL(tr.grn,0) AS grn, IFNULL(tr.in_transit, 0) AS in_transit, IFNULL(tr.sales,
0) AS sales, IFNULL(tr.inst_hold, 0) AS inst_hold, IFNULL(tr.quality_hold,
0) AS quality_hold, IFNULL(tr.qa_hold, 0) AS qa_hold,
IFNULL(tr.pending_orders, 0) AS pending_orders, IFNULL(tr.orders_in_hand, 0) AS
orders_in_hand, IFNULL(tr.transport_mode, '') AS transport_mode, CASE WHEN
IFNULL(tr.supply_node_id,0) > 0 THEN IFNULL(tr.supply_node_id,0) ELSE
IFNULL(nsm.supplier_node_id,0) END AS supply_node_id, sn.node_name AS
supply_node_name, sn.node_code AS supply_node_code,
IFNULL(str.closing_quantity, 0) AS supplying_quantity,
IFNULL(sbn.buffer_norm, 0) AS supplying_buffer_norm,
ROUND(IFNULL(bn.buffer_norm, 0),2) AS 'green_zone_qty', CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2)
END AS 'yellow_zone_qty', CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END AS 'red_zone_qty', CASE
WHEN IFNULL(bn.buffer_norm, 0) = 0 THEN 'White' WHEN
(IFNULL(tr.closing_quantity, 0) <= 0 AND IFNULL(bn.buffer_norm, 0) > 0) THEN
'Black' WHEN (IFNULL(tr.closing_quantity, 0) > IFNULL(bn.buffer_norm, 0) AND
IFNULL(bn.buffer_norm, 0) > 0) THEN 'Blue' WHEN (IFNULL(tr.closing_quantity,
0) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(tr.closing_quantity,
0) <= IFNULL(bn.buffer_norm, 0) AND IFNULL(bn.buffer_norm, 0) > 0) THEN 'Green'
WHEN (IFNULL(tr.closing_quantity, 0) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(tr.closing_quantity, 0) <=
(CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(bn.buffer_norm, 0) >
0) THEN 'Yellow' WHEN (IFNULL(tr.closing_quantity, 0) > 0 AND
IFNULL(tr.closing_quantity, 0) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(bn.buffer_norm, 0) > 0) THEN
'Red' END AS 'closing_stock_zone', CASE WHEN
IFNULL(bn.buffer_norm, 0) = 0 THEN 6 WHEN (IFNULL(tr.closing_quantity, 0) <=
0 AND IFNULL(bn.buffer_norm, 0) > 0) THEN 1 WHEN
(IFNULL(tr.closing_quantity, 0) > IFNULL(bn.buffer_norm, 0) AND
IFNULL(bn.buffer_norm, 0) > 0) THEN 2 WHEN (IFNULL(tr.closing_quantity, 0) >
(CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(tr.closing_quantity,
0) <= IFNULL(bn.buffer_norm, 0) AND IFNULL(bn.buffer_norm, 0) > 0) THEN 4
WHEN (IFNULL(tr.closing_quantity, 0) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(tr.closing_quantity, 0) <=
(CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(bn.buffer_norm, 0) >
0) THEN 3 WHEN (IFNULL(tr.closing_quantity, 0) > 0 AND
IFNULL(tr.closing_quantity, 0) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(bn.buffer_norm, 0) > 0) THEN
5 END AS 'closing_stock_zone_sort', CASE WHEN
IFNULL(bn.buffer_norm, 0) = 0 THEN 'White' WHEN
((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) <= 0 AND IFNULL(bn.buffer_norm, 0) > 0) THEN 'Black'
WHEN ((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > IFNULL(bn.buffer_norm, 0) AND
IFNULL(bn.buffer_norm, 0) > 0) THEN 'Blue' WHEN
((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND
(IFNULL(tr.closing_quantity, 0) + tr.in_transit - tr.pending_orders) <=
IFNULL(bn.buffer_norm, 0) AND IFNULL(bn.buffer_norm, 0) > 0) THEN 'Green'
WHEN ((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND (tr.closing_quantity +
tr.in_transit - tr.pending_orders) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2)
ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(bn.buffer_norm,
0) > 0) THEN 'Yellow' WHEN ((IFNULL(tr.closing_quantity, 0) +
IFNULL(tr.in_transit, 0) - IFNULL(tr.pending_orders, 0)) > 0 AND
(IFNULL(tr.closing_quantity, 0) + tr.in_transit - tr.pending_orders) <= (CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND
IFNULL(bn.buffer_norm, 0) > 0) THEN 'Red' END AS 'in_transit_zone',
CASE WHEN IFNULL(bn.buffer_norm, 0) = 0 THEN 6 WHEN
((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) <= 0 AND IFNULL(bn.buffer_norm, 0) > 0) THEN 1
WHEN ((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > IFNULL(bn.buffer_norm, 0) AND
IFNULL(bn.buffer_norm,
0) > 0) THEN 2 WHEN ((IFNULL(tr.closing_quantity, 0) +
IFNULL(tr.in_transit, 0) - IFNULL(tr.pending_orders, 0)) > (CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2)
END) AND (IFNULL(tr.closing_quantity, 0) + tr.in_transit - tr.pending_orders) <=
IFNULL(bn.buffer_norm, 0) AND IFNULL(bn.buffer_norm, 0) > 0) THEN 4 WHEN
((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND (IFNULL(tr.closing_quantity, 0) +
tr.in_transit - tr.pending_orders) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2)
ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(bn.buffer_norm,
0) > 0) THEN 3 WHEN ((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit,
0) - IFNULL(tr.pending_orders, 0)) > 0 AND (IFNULL(tr.closing_quantity, 0) +
tr.in_transit - tr.pending_orders) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(bn.buffer_norm, 0) > 0) THEN
5 END AS 'in_transit_zone_sort', CASE WHEN
IFNULL(sbn.buffer_norm, 0) = 0 THEN 'White' WHEN
(IFNULL(str.closing_quantity, 0) <= 0 AND IFNULL(sbn.buffer_norm, 0) > 0) THEN
'Black' WHEN (IFNULL(str.closing_quantity, 0) > IFNULL(sbn.buffer_norm, 0)
AND IFNULL(sbn.buffer_norm, 0) > 0) THEN 'Blue' WHEN
(IFNULL(str.closing_quantity, 0) > (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) AND
IFNULL(str.closing_quantity, 0) <= IFNULL(sbn.buffer_norm, 0) AND
IFNULL(sbn.buffer_norm, 0) > 0) THEN 'Green' WHEN
(IFNULL(str.closing_quantity, 0) > (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) AND IFNULL(str.closing_quantity, 0) <=
(CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) AND IFNULL(sbn.buffer_norm, 0)
> 0) THEN 'Yellow' WHEN (IFNULL(str.closing_quantity, 0) > 0 AND
IFNULL(str.closing_quantity, 0) <= (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) AND IFNULL(sbn.buffer_norm, 0) > 0)
THEN 'Red' END AS 'supplying_node_zone', CASE WHEN
IFNULL(sbn.buffer_norm, 0) = 0 THEN 6 WHEN (IFNULL(str.closing_quantity, 0)
<= 0 AND IFNULL(sbn.buffer_norm, 0) > 0) THEN 1 WHEN
(IFNULL(str.closing_quantity, 0) > IFNULL(sbn.buffer_norm, 0) AND
IFNULL(sbn.buffer_norm, 0) > 0) THEN 2 WHEN (IFNULL(str.closing_quantity, 0)
> (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) AND
IFNULL(str.closing_quantity, 0) <= IFNULL(sbn.buffer_norm, 0) AND
IFNULL(sbn.buffer_norm, 0) > 0) THEN 4 WHEN (IFNULL(str.closing_quantity, 0)
> (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) AND IFNULL(str.closing_quantity, 0) <=
(CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) AND IFNULL(sbn.buffer_norm, 0)
> 0) THEN 3 WHEN (IFNULL(str.closing_quantity, 0) > 0 AND
IFNULL(str.closing_quantity, 0) <= (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) AND IFNULL(sbn.buffer_norm, 0) > 0)
THEN 5 END AS 'supplying_node_zone_sort', CASE WHEN
((IFNULL(bn.buffer_norm, 0) - IFNULL(tr.closing_quantity, 0) -
IFNULL(tr.in_transit, 0)) + IFNULL(tr.pending_orders, 0)) -
(IFNULL(tr.open_planned_order, 0) + IFNULL(tr.open_purchase_request, 0) +
IFNULL(tr.open_production_order, 0) + IFNULL(tr.open_purchase_order, 0)) <= 0 THEN
0 ELSE ((IFNULL(bn.buffer_norm, 0) - IFNULL(tr.closing_quantity, 0) -
IFNULL(tr.in_transit, 0)) + IFNULL(tr.pending_orders, 0)) -
(IFNULL(tr.open_planned_order, 0) + IFNULL(tr.open_purchase_request, 0) +
IFNULL(tr.open_production_order, 0) + IFNULL(tr.open_purchase_order, 0)) END
AS 'replenishment_quantity', CASE WHEN (IFNULL(tr.closing_quantity,
0) + IFNULL(tr.in_transit, 0) + IFNULL(tr.open_planned_order, 0) +
IFNULL(tr.open_purchase_request, 0) + IFNULL(tr.open_production_order, 0) +
IFNULL(tr.open_purchase_order, 0) ) - IFNULL(tr.pending_orders, 0) <= 0 THEN 0
ELSE (IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) +
IFNULL(tr.open_planned_order, 0) + IFNULL(tr.open_purchase_request, 0) +
IFNULL(tr.open_production_order, 0) + IFNULL(tr.open_purchase_order, 0) ) -
IFNULL(tr.pending_orders, 0) END AS 'final_quantity', CASE
WHEN IFNULL(bn.buffer_norm, 0) = 0 THEN 0 ELSE (CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END)
END AS 'mrq', (SELECT COUNT(1) FROM transaction_comment WHERE
transaction_id = tr.transaction_id) AS 'transaction_comment', 0 AS db_sync, 0 AS
mongo_sync, IFNULL(tr.open_stock_transfer_order, 0) AS
open_stock_transfer_order, IFNULL(tr.open_planned_order, 0) AS open_planned_order,
IFNULL(tr.open_purchase_request, 0) AS open_purchase_request,
IFNULL(tr.open_production_order, 0) AS open_production_order,
IFNULL(tr.open_purchase_order, 0) AS open_purchase_order, tr.field1,
tr.field2, tr.field3, tr.field4, tr.field5, tr.field6, tr.field7, tr.field8,
tr.field9, tr.field10 from ( select tt.transaction_id from
transaction tt use index (transaction_date) inner join update_transaction ut
use index (inx_transactionid) on ut.transaction_id = tt.transaction_id
where tt.transaction_date = ?param0 ORDER BY tt.sku_id limit ?
param1 , ?param2 ) otr join transaction tr on
tr.transaction_id = otr.transaction_id LEFT JOIN buffer_norm bn USE INDEX
(inx_sku_node_efdt) ON bn.sku_id = tr.sku_id AND bn.node_id =
tr.node_id AND bn.effective_from = ( SELECT MAX(effective_from) FROM
buffer_norm WHERE effective_from <= tr.transaction_date AND sku_id =
tr.sku_id AND node_id = tr.node_id) LEFT JOIN sku s ON
s.sku_id = tr.sku_id LEFT JOIN sku_category sc ON
sc.sku_category_id = (SELECT sku_category_id FROM sku_category WHERE sku_id =
tr.sku_id LIMIT 1) LEFT JOIN category cat ON cat.category_id =
sc.category_id LEFT JOIN node n ON n.node_id = tr.node_id
LEFT OUTER JOIN node_sku_mapping nsm USE INDEX (inx_sku_receiver_node_efdt)
ON nsm.receiver_node_id = tr.node_id AND nsm.sku_id = tr.sku_id AND
nsm.effective_date = ( SELECT MAX(effective_date) FROM node_sku_mapping
WHERE effective_date <= tr.transaction_date AND sku_id = tr.sku_id
AND receiver_node_id = tr.node_id) LEFT JOIN node sn ON CASE WHEN
IFNULL(tr.supply_node_id,0) > 0 THEN sn.node_id = tr.supply_node_id ELSE
sn.node_id = nsm.supplier_node_id END LEFT JOIN buffer_norm sbn USE INDEX
(inx_sku_node_efdt) ON sbn.sku_id = tr.sku_id AND CASE WHEN
IFNULL(tr.supply_node_id,0) > 0 THEN sbn.node_id = tr.supply_node_id ELSE
sbn.node_id = nsm.supplier_node_id END AND sbn.effective_from =
( SELECT MAX(effective_from) FROM buffer_norm WHERE effective_from <=
tr.transaction_date AND sku_id = tr.sku_id AND node_id = tr.node_id)
LEFT JOIN TRANSACTION str USE INDEX (inx_tdt_sku_node_snode) ON
str.transaction_date = tr.transaction_date AND str.sku_id = tr.sku_id
AND CASE WHEN IFNULL(tr.supply_node_id,0) > 0 THEN str.node_id =
IFNULL(tr.supply_node_id,0) ELSE str.node_id = nsm.supplier_node_id END
GROUP BY tr.transaction_id ORDER BY tr.transaction_id) tmt ON
DUPLICATE KEY UPDATE category_id=VALUES(category_id),
category_code=VALUES(category_code), category_name=VALUES(category_name),
buffer_norm=VALUES(buffer_norm), closing_quantity=VALUES(closing_quantity),
grn=VALUES(grn), in_transit=VALUES(in_transit), sales=VALUES(sales),
inst_hold=VALUES(inst_hold), quality_hold=VALUES(quality_hold),
qa_hold=VALUES(qa_hold), pending_orders=VALUES(pending_orders),
orders_in_hand=VALUES(orders_in_hand), mtd_sales=VALUES(mtd_sales),
mtd_grn=VALUES(mtd_grn), transport_mode=VALUES(transport_mode),
supply_node_id=VALUES(supply_node_id), supply_node_name=VALUES(supply_node_name),
supply_node_code=VALUES(supply_node_code),
supplying_quantity=VALUES(supplying_quantity),
supplying_buffer_norm=VALUES(supplying_buffer_norm),
green_zone_qty=VALUES(green_zone_qty), yellow_zone_qty=VALUES(yellow_zone_qty),
red_zone_qty=VALUES(red_zone_qty), closing_stock_zone=VALUES(closing_stock_zone),
closing_stock_zone_sort=VALUES(closing_stock_zone_sort),
in_transit_zone=VALUES(in_transit_zone),
in_transit_zone_sort=VALUES(in_transit_zone_sort),
supplying_node_zone=VALUES(supplying_node_zone),
supplying_node_zone_sort=VALUES(supplying_node_zone_sort),
replenishment_quantity=VALUES(replenishment_quantity),
final_quantity=VALUES(final_quantity), mrq=VALUES(mrq), db_sync=VALUES(db_sync),
mongo_sync=VALUES(mongo_sync),
open_stock_transfer_order=VALUES(open_stock_transfer_order),
open_planned_order=VALUES(open_planned_order),
open_purchase_request=VALUES(open_purchase_request),
open_production_order=VALUES(open_production_order),
open_purchase_order=VALUES(open_purchase_order), field1=VALUES(field1),
field2=VALUES(field2), field3=VALUES(field3), field4=VALUES(field4),
field5=VALUES(field5), field6=VALUES(field6), field7=VALUES(field7),
field8=VALUES(field8), field9=VALUES(field9), field10=VALUES(field10);]
2018-03-15 10:55:11,633-Statement Id: [InsertReplenishmentListFullSync] Prepared
SQL: [insert into replenishment (transaction_id, transaction_date,
display_date, transfilter_date, sku_id, sku_code, sku_name, node_id, node_code,
node_name, category_id, category_code, category_name, buffer_norm,
closing_quantity, in_transit, sales, inst_hold, quality_hold, qa_hold,
pending_orders, orders_in_hand, transport_mode, supply_node_id,
supply_node_name, supply_node_code, supplying_quantity, supplying_buffer_norm,
green_zone_qty, yellow_zone_qty, red_zone_qty, closing_stock_zone,
closing_stock_zone_sort, in_transit_zone, in_transit_zone_sort,
supplying_node_zone, supplying_node_zone_sort, replenishment_quantity,
final_quantity, mrq, transaction_comment, db_sync, mongo_sync,
open_stock_transfer_order, open_planned_order, open_purchase_request,
open_production_order, open_purchase_order, field1, field2, field3, field4, field5,
field6, field7, field8, field9, field10 ) SELECT tr.transaction_id,
tr.transaction_date, DATE_FORMAT(tr.transaction_date,'%d/%m/%Y') AS display_date,
DATE_FORMAT(tr.transaction_date,'%Y%m%d') AS transfilter_date, tr.sku_id,
s.sku_code, s.sku_name, tr.node_id, n.node_code, n.node_name, sc.category_id,
cat.category_code, cat.category_name, IFNULL(bn.buffer_norm, 0) AS
buffer_norm, IFNULL(tr.closing_quantity, 0) AS closing_quantity,
IFNULL(tr.in_transit, 0) AS in_transit, IFNULL(tr.sales, 0) AS sales,
IFNULL(tr.inst_hold, 0) AS inst_hold, IFNULL(tr.quality_hold, 0) AS quality_hold,
IFNULL(tr.qa_hold, 0) AS qa_hold, IFNULL(tr.pending_orders, 0) AS
pending_orders, IFNULL(tr.orders_in_hand, 0) AS orders_in_hand,
IFNULL(tr.transport_mode, '') AS transport_mode, CASE WHEN
IFNULL(tr.supply_node_id,0) > 0 THEN IFNULL(tr.supply_node_id,0) ELSE
IFNULL(nsm.supplier_node_id,0) END AS supply_node_id, sn.node_name AS
supply_node_name, sn.node_code AS supply_node_code,
IFNULL(str.closing_quantity, 0) AS supplying_quantity,
IFNULL(sbn.buffer_norm, 0) AS supplying_buffer_norm,
ROUND(IFNULL(bn.buffer_norm, 0),2) AS 'green_zone_qty', CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2)
END AS 'yellow_zone_qty', CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END AS 'red_zone_qty', CASE
WHEN IFNULL(bn.buffer_norm, 0) = 0 THEN 'White' WHEN
(IFNULL(tr.closing_quantity, 0) <= 0 AND IFNULL(bn.buffer_norm, 0) > 0) THEN
'Black' WHEN (IFNULL(tr.closing_quantity, 0) > IFNULL(bn.buffer_norm, 0) AND
IFNULL(bn.buffer_norm, 0) > 0) THEN 'Blue' WHEN (IFNULL(tr.closing_quantity,
0) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(tr.closing_quantity,
0) <= IFNULL(bn.buffer_norm, 0) AND IFNULL(bn.buffer_norm, 0) > 0) THEN 'Green'
WHEN (IFNULL(tr.closing_quantity, 0) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(tr.closing_quantity, 0) <=
(CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(bn.buffer_norm, 0) >
0) THEN 'Yellow' WHEN (IFNULL(tr.closing_quantity, 0) > 0 AND
IFNULL(tr.closing_quantity, 0) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(bn.buffer_norm, 0) > 0) THEN
'Red' END AS 'closing_stock_zone', CASE WHEN
IFNULL(bn.buffer_norm, 0) = 0 THEN 6 WHEN (IFNULL(tr.closing_quantity, 0) <=
0 AND IFNULL(bn.buffer_norm, 0) > 0) THEN 1 WHEN
(IFNULL(tr.closing_quantity, 0) > IFNULL(bn.buffer_norm, 0) AND
IFNULL(bn.buffer_norm, 0) > 0) THEN 2 WHEN (IFNULL(tr.closing_quantity, 0) >
(CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(tr.closing_quantity,
0) <= IFNULL(bn.buffer_norm, 0) AND IFNULL(bn.buffer_norm, 0) > 0) THEN 4
WHEN (IFNULL(tr.closing_quantity, 0) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(tr.closing_quantity, 0) <=
(CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(bn.buffer_norm, 0) >
0) THEN 3 WHEN (IFNULL(tr.closing_quantity, 0) > 0 AND
IFNULL(tr.closing_quantity, 0) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(bn.buffer_norm, 0) > 0) THEN
5 END AS 'closing_stock_zone_sort', CASE WHEN
IFNULL(bn.buffer_norm, 0) = 0 THEN 'White' WHEN
((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) <= 0 AND IFNULL(bn.buffer_norm, 0) > 0) THEN 'Black'
WHEN ((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > IFNULL(bn.buffer_norm, 0) AND
IFNULL(bn.buffer_norm, 0) > 0) THEN 'Blue' WHEN
((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND
(IFNULL(tr.closing_quantity, 0) + tr.in_transit - tr.pending_orders) <=
IFNULL(bn.buffer_norm, 0) AND IFNULL(bn.buffer_norm, 0) > 0) THEN 'Green'
WHEN ((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND (tr.closing_quantity +
tr.in_transit - tr.pending_orders) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2)
ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(bn.buffer_norm,
0) > 0) THEN 'Yellow' WHEN ((IFNULL(tr.closing_quantity, 0) +
IFNULL(tr.in_transit, 0) - IFNULL(tr.pending_orders, 0)) > 0 AND
(IFNULL(tr.closing_quantity, 0) + tr.in_transit - tr.pending_orders) <= (CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND
IFNULL(bn.buffer_norm, 0) > 0) THEN 'Red' END AS 'in_transit_zone',
CASE WHEN IFNULL(bn.buffer_norm, 0) = 0 THEN 6 WHEN
((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) <= 0 AND IFNULL(bn.buffer_norm, 0) > 0) THEN 1
WHEN ((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > IFNULL(bn.buffer_norm, 0) AND
IFNULL(bn.buffer_norm, 0) > 0) THEN 2 WHEN ((IFNULL(tr.closing_quantity, 0)
+ IFNULL(tr.in_transit, 0) - IFNULL(tr.pending_orders, 0)) > (CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2)
END) AND (IFNULL(tr.closing_quantity, 0) + tr.in_transit - tr.pending_orders) <=
IFNULL(bn.buffer_norm, 0) AND IFNULL(bn.buffer_norm, 0) > 0) THEN 4 WHEN
((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND (IFNULL(tr.closing_quantity, 0) +
tr.in_transit - tr.pending_orders) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2)
ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(bn.buffer_norm,
0) > 0) THEN 3 WHEN ((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit,
0) - IFNULL(tr.pending_orders, 0)) > 0 AND (IFNULL(tr.closing_quantity, 0) +
tr.in_transit - tr.pending_orders) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(bn.buffer_norm, 0) > 0) THEN
5 END AS 'in_transit_zone_sort', CASE WHEN
IFNULL(sbn.buffer_norm, 0) = 0 THEN 'White' WHEN
(IFNULL(str.closing_quantity, 0) <= 0 AND IFNULL(sbn.buffer_norm, 0) > 0) THEN
'Black' WHEN (IFNULL(str.closing_quantity, 0) > IFNULL(sbn.buffer_norm, 0)
AND IFNULL(sbn.buffer_norm, 0) > 0) THEN 'Blue' WHEN
(IFNULL(str.closing_quantity, 0) > (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) AND
IFNULL(str.closing_quantity, 0) <= IFNULL(sbn.buffer_norm, 0) AND
IFNULL(sbn.buffer_norm, 0) > 0) THEN 'Green' WHEN
(IFNULL(str.closing_quantity, 0) > (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.red_zone,0)
/ 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE ROUND(IFNULL(sbn.buffer_norm, 0) /
3,2) END) AND IFNULL(str.closing_quantity, 0) <= (CASE WHEN
IFNULL(sbn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(sbn.yellow_zone,0) / 100)
* IFNULL(sbn.buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(sbn.buffer_norm,
0)),2) END) AND IFNULL(sbn.buffer_norm, 0) > 0) THEN 'Yellow' WHEN
(IFNULL(str.closing_quantity, 0) > 0 AND IFNULL(str.closing_quantity, 0) <= (CASE
WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(sbn.red_zone,0) /
100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2)
END) AND IFNULL(sbn.buffer_norm, 0) > 0) THEN 'Red' END AS
'supplying_node_zone', CASE WHEN IFNULL(sbn.buffer_norm, 0) = 0
THEN 6 WHEN (IFNULL(str.closing_quantity, 0) <= 0 AND
IFNULL(sbn.buffer_norm, 0) > 0) THEN 1 WHEN (IFNULL(str.closing_quantity, 0)
> IFNULL(sbn.buffer_norm, 0) AND IFNULL(sbn.buffer_norm, 0) > 0) THEN 2 WHEN
(IFNULL(str.closing_quantity, 0) > (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) AND
IFNULL(str.closing_quantity, 0) <= IFNULL(sbn.buffer_norm, 0) AND
IFNULL(sbn.buffer_norm, 0) > 0) THEN 4 WHEN (IFNULL(str.closing_quantity, 0)
> (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) AND IFNULL(str.closing_quantity, 0) <=
(CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) AND IFNULL(sbn.buffer_norm, 0)
> 0) THEN 3 WHEN (IFNULL(str.closing_quantity, 0) > 0 AND
IFNULL(str.closing_quantity, 0) <= (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) AND IFNULL(sbn.buffer_norm, 0) > 0)
THEN 5 END AS 'supplying_node_zone_sort', CASE WHEN
((IFNULL(bn.buffer_norm, 0) - IFNULL(tr.closing_quantity, 0) -
IFNULL(tr.in_transit, 0)) + IFNULL(tr.pending_orders, 0)) -
(IFNULL(tr.open_planned_order, 0) + IFNULL(tr.open_purchase_request, 0) +
IFNULL(tr.open_production_order, 0) + IFNULL(tr.open_purchase_order, 0)) <= 0 THEN
0 ELSE ((IFNULL(bn.buffer_norm, 0) - IFNULL(tr.closing_quantity, 0) -
IFNULL(tr.in_transit, 0)) + IFNULL(tr.pending_orders, 0)) -
(IFNULL(tr.open_planned_order, 0) + IFNULL(tr.open_purchase_request, 0) +
IFNULL(tr.open_production_order, 0) + IFNULL(tr.open_purchase_order, 0)) END
AS 'replenishment_quantity', CASE WHEN (IFNULL(tr.closing_quantity,
0) + IFNULL(tr.in_transit, 0) + IFNULL(tr.open_planned_order, 0) +
IFNULL(tr.open_purchase_request, 0) + IFNULL(tr.open_production_order, 0) +
IFNULL(tr.open_purchase_order, 0) ) - IFNULL(tr.pending_orders, 0) <= 0 THEN 0
ELSE (IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) +
IFNULL(tr.open_planned_order, 0) + IFNULL(tr.open_purchase_request, 0) +
IFNULL(tr.open_production_order, 0) + IFNULL(tr.open_purchase_order, 0) ) -
IFNULL(tr.pending_orders, 0) END AS 'final_quantity', CASE
WHEN IFNULL(bn.buffer_norm, 0) = 0 THEN 0 ELSE (CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END)
END AS 'mrq', (SELECT COUNT(1) FROM transaction_comment WHERE
transaction_id = tr.transaction_id) AS 'transaction_comment', 0 AS db_sync, 0 AS
mongo_sync, IFNULL(tr.open_stock_transfer_order, 0),
IFNULL(tr.open_planned_order, 0), IFNULL(tr.open_purchase_request,
0),IFNULL(tr.open_production_order, 0), IFNULL(tr.open_purchase_order, 0),
tr.field1, tr.field2, tr.field3, tr.field4, tr.field5, tr.field6, tr.field7,
tr.field8, tr.field9, tr.field10 from ( select tt.transaction_id
from transaction tt use index (transaction_date) where
tt.transaction_date = ?param0 ORDER BY tt.sku_id limit ?
param1 , ?param2 ) otr join transaction tr on
tr.transaction_id = otr.transaction_id LEFT JOIN buffer_norm bn USE INDEX
(inx_sku_node_efdt) ON bn.sku_id = tr.sku_id AND bn.node_id =
tr.node_id AND bn.effective_from = ( SELECT MAX(effective_from) FROM
buffer_norm WHERE effective_from <= tr.transaction_date AND sku_id =
tr.sku_id AND node_id = tr.node_id) LEFT JOIN sku s ON
s.sku_id = tr.sku_id LEFT JOIN sku_category sc ON
sc.sku_category_id = (SELECT sku_category_id FROM sku_category WHERE sku_id =
tr.sku_id LIMIT 1) LEFT JOIN category cat ON cat.category_id =
sc.category_id LEFT JOIN node n ON n.node_id = tr.node_id
LEFT OUTER JOIN node_sku_mapping nsm USE INDEX (inx_sku_receiver_node_efdt)
ON nsm.receiver_node_id = tr.node_id AND nsm.sku_id = tr.sku_id AND
nsm.effective_date = ( SELECT MAX(effective_date) FROM node_sku_mapping
WHERE effective_date <= tr.transaction_date AND sku_id = tr.sku_id
AND receiver_node_id = tr.node_id) LEFT JOIN node sn ON CASE WHEN
IFNULL(tr.supply_node_id,0) > 0 THEN sn.node_id = tr.supply_node_id ELSE
sn.node_id = nsm.supplier_node_id END LEFT JOIN buffer_norm sbn USE INDEX
(inx_sku_node_efdt) ON sbn.sku_id = tr.sku_id AND CASE WHEN
IFNULL(tr.supply_node_id,0) > 0 THEN sbn.node_id = tr.supply_node_id ELSE
sbn.node_id = nsm.supplier_node_id END AND sbn.effective_from =
( SELECT MAX(effective_from) FROM buffer_norm WHERE effective_from <=
tr.transaction_date AND sku_id = tr.sku_id AND node_id = tr.node_id)
LEFT JOIN TRANSACTION str USE INDEX (inx_tdt_sku_node_snode) ON
str.transaction_date = tr.transaction_date AND str.sku_id = tr.sku_id
AND CASE WHEN IFNULL(tr.supply_node_id,0) > 0 THEN str.node_id =
IFNULL(tr.supply_node_id,0) ELSE str.node_id = nsm.supplier_node_id END
GROUP BY tr.transaction_id ORDER BY tr.transaction_id]
2018-03-15 10:55:11,634-Adding file [UserHelper.xml] to list of watched files.
2018-03-15 10:55:11,634-Statement Id: [SelectUserNameDuplicate] Prepared SQL:
[select user_id, user_name, first_name, middle_name, last_name, email, mobile,
description, password, status, approved, locked, role_id, region_id,
created_by, created_on, modified_by, modified_on from user where user_name =
?param0 and user_id != ?param1]
2018-03-15 10:55:11,634-Statement Id: [SelectUserMobileDuplicate] Prepared SQL:
[select user_id, user_name, first_name, middle_name, last_name, email, mobile,
description, password, status, approved, locked, role_id, region_id,
created_by, created_on, modified_by, modified_on from user where mobile = ?
param0 and user_id != ?param1]
2018-03-15 10:55:11,634-Statement Id: [SelectUserCheckAuthenticate] Prepared SQL:
[select user_id, user_name, first_name, middle_name, last_name, email, mobile,
description, password, status, approved, locked, role_id, region_id,
created_by, created_on, modified_by, modified_on from user where user_name =
?param0 and password = ?param1 and status = 1]
2018-03-15 10:55:11,634-Statement Id: [SelectUserCheckLocked] Prepared SQL: [select
user_id, user_name, first_name, middle_name, last_name, email, mobile, description,
password, status, approved, locked, role_id, region_id, created_by,
created_on, modified_by, modified_on from user where user_name = ?param0]
2018-03-15 10:55:11,634-Statement Id: [InsertUser] Prepared SQL: [insert into user
(user_name, first_name, middle_name, last_name, email, mobile, description,
password, status, approved, locked, role_id, region_id, created_by,
created_on) values ( ?param0 , ?param1 , ?param2 , ?param3 , ?
param4 , ?param5 , ?param6 , ?param7 , ?param8 , ?param9 , ?param10 ,
?param11 , ?param12 , ?param13 , NOW());]
2018-03-15 10:55:11,634-Statement Id: [InsertUser.SelectKey] Prepared SQL: [select
last_insert_id() as value]
2018-03-15 10:55:11,634-Statement Id: [UpdateUser] Prepared SQL: [update user set
user_name = ?param0 , first_name = ?param1 , middle_name = ?param2
, last_name = ?param3 , email = ?param4 , mobile = ?
param5 , description = ?param6 , password = ?param7 , status
= ?param8 , approved = ?param9 , locked = ?param10 ,
role_id = ?param11 , region_id = ?param12 , modified_by = ?param13
, modified_on = NOW() where user_id = ?param14]
2018-03-15 10:55:11,634-Statement Id: [DeleteUser] Prepared SQL: [delete from user
where user_id = ?param0]
2018-03-15 10:55:11,634-Adding file [UserModuleHelper.xml] to list of watched
files.
2018-03-15 10:55:11,634-Statement Id: [InsertUserModule] Prepared SQL: [insert into
user_module (role_id, module_id, created_by, created_on) values
( ?param0 , ?param1 , ?param2 , NOW());]
2018-03-15 10:55:11,634-Statement Id: [InsertUserModule.SelectKey] Prepared SQL:
[select last_insert_id() as value]
2018-03-15 10:55:11,634-Statement Id: [DeleteUserModule] Prepared SQL: [delete from
user_module where user_module_id = ?param0]
2018-03-15 10:55:11,634-Statement Id: [DeleteModuleByRole] Prepared SQL: [delete
from user_module where role_id = ?param0]
2018-03-15 10:55:11,634-Adding file [SKUGridHelper.xml] to list of watched files.
2018-03-15 10:55:11,641-Statement Id: [SelectSKUGrid] Prepared SQL: [select
s.sku_name, n.node_name, c.category_id, c.category_name, sku_grid.*, case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (1 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(1 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (1 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (1 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (1 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (1 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (1 * avg_sales)) > 0 and (closing_quantity - (1 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(red_zone,0) /
100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and
buffer_norm > 0) then 'Red' end as 'one', case when (closing_quantity
- (1 * avg_sales)) <= 0 then 0 else (closing_quantity - (1 * avg_sales)) end as
'one_qty', case when ifnull(buffer_norm, 0) = 0 then 'White'
when ((closing_quantity - (2 * avg_sales)) <= 0 and buffer_norm > 0) then 'Black'
when ((closing_quantity - (2 * avg_sales)) > buffer_norm and buffer_norm > 0) then
'Blue' when ((closing_quantity - (2 * avg_sales)) > (CASE WHEN
IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) *
IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END)
and (closing_quantity - (2 * avg_sales)) <= buffer_norm and buffer_norm > 0) then
'Green' when ((closing_quantity - (2 * avg_sales)) > (CASE WHEN
IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(red_zone,0) / 100) *
IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and
(closing_quantity - (2 * avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow'
when ((closing_quantity - (2 * avg_sales)) > 0 and (closing_quantity - (2 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'two', case when (closing_quantity - (2 * avg_sales)) <= 0 then 0 else
(closing_quantity - (2 * avg_sales)) end as 'two_qty', case when
ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (3 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(3 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (3 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (3 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (3 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (3 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (3 * avg_sales)) > 0 and (closing_quantity - (3 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(red_zone,0) /
100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and
buffer_norm > 0) then 'Red' end as 'three', case when
(closing_quantity - (3 * avg_sales)) <= 0 then 0 else (closing_quantity - (3 *
avg_sales)) end as 'three_qty', case when ifnull(buffer_norm, 0) = 0
then 'White' when ((closing_quantity - (4 * avg_sales)) <= 0 and buffer_norm
> 0) then 'Black' when ((closing_quantity - (4 * avg_sales)) > buffer_norm
and buffer_norm > 0) then 'Blue' when ((closing_quantity - (4 * avg_sales))
> (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(yellow_zone,0) /
100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2)
END) and (closing_quantity - (4 * avg_sales)) <= buffer_norm and buffer_norm > 0)
then 'Green' when ((closing_quantity - (4 * avg_sales)) > (CASE WHEN
IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(red_zone,0) / 100) *
IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and
(closing_quantity - (4 * avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow'
when ((closing_quantity - (4 * avg_sales)) > 0 and (closing_quantity - (4 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'four', case when (closing_quantity - (4 * avg_sales)) <= 0 then 0 else
(closing_quantity - (4 * avg_sales)) end as 'four_qty', case when
ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (5 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(5 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (5 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (5 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (5 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (5 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (5 * avg_sales)) > 0 and (closing_quantity - (5 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(red_zone,0) /
100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and
buffer_norm > 0) then 'Red' end as 'five', case when
(closing_quantity - (5 * avg_sales)) <= 0 then 0 else (closing_quantity - (5 *
avg_sales)) end as 'five_qty', case when ifnull(buffer_norm, 0) = 0
then 'White' when ((closing_quantity - (6 * avg_sales)) <= 0 and buffer_norm
> 0) then 'Black' when ((closing_quantity - (6 * avg_sales)) > buffer_norm
and buffer_norm > 0) then 'Blue' when ((closing_quantity - (6 * avg_sales))
> (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(yellow_zone,0) /
100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2)
END) and (closing_quantity - (6 * avg_sales)) <= buffer_norm and buffer_norm > 0)
then 'Green' when ((closing_quantity - (6 * avg_sales)) > (CASE WHEN
IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(red_zone,0) / 100) *
IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and
(closing_quantity - (6 * avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow'
when ((closing_quantity - (6 * avg_sales)) > 0 and (closing_quantity - (6 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'six', case when (closing_quantity - (6 * avg_sales)) <= 0 then 0 else
(closing_quantity - (6 * avg_sales)) end as 'six_qty', case when
ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (7 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(7 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (7 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (7 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (7 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (7 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm
> 0) then 'Yellow' when ((closing_quantity - (7 * avg_sales)) > 0 and
(closing_quantity - (7 * avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'seven', case when (closing_quantity - (7 * avg_sales)) <= 0 then 0 else
(closing_quantity - (7 * avg_sales)) end as 'seven_qty', case when
ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (8 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(8 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (8 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (8 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (8 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (8 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (8 * avg_sales)) > 0 and (closing_quantity - (8 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(red_zone,0) /
100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and
buffer_norm > 0) then 'Red' end as 'eight', case when
(closing_quantity - (8 * avg_sales)) <= 0 then 0 else (closing_quantity - (8 *
avg_sales)) end as 'eight_qty', case when ifnull(buffer_norm, 0) = 0
then 'White' when ((closing_quantity - (9 * avg_sales)) <= 0 and buffer_norm
> 0) then 'Black' when ((closing_quantity - (9 * avg_sales)) > buffer_norm
and buffer_norm > 0) then 'Blue' when ((closing_quantity - (9 * avg_sales))
> (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(yellow_zone,0) /
100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2)
END) and (closing_quantity - (9 * avg_sales)) <= buffer_norm and buffer_norm > 0)
then 'Green' when ((closing_quantity - (9 * avg_sales)) > (CASE WHEN
IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(red_zone,0) / 100) *
IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and
(closing_quantity - (9 * avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow'
when ((closing_quantity - (9 * avg_sales)) > 0 and (closing_quantity - (9 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'nine', case when (closing_quantity - (9 * avg_sales)) <= 0 then 0 else
(closing_quantity - (9 * avg_sales)) end as 'nine_qty', case when
ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (10 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(10 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (10 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (10 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (10 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (10 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (10 * avg_sales)) > 0 and (closing_quantity - (10 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'ten', case when (closing_quantity - (10 * avg_sales)) <= 0 then 0 else
(closing_quantity - (10 * avg_sales)) end as 'ten_qty', case when
ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (11 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(11 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (11 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (11 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (11 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (11 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (11 * avg_sales)) > 0 and (closing_quantity - (11 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'eleven', case when (closing_quantity - (11 * avg_sales)) <= 0 then 0
else (closing_quantity - (11 * avg_sales)) end as 'eleven_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (12 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(12 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (12 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (12 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (12 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (12 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (12 * avg_sales)) > 0 and (closing_quantity - (12 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twelve', case when (closing_quantity - (12 * avg_sales)) <= 0 then 0
else (closing_quantity - (12 * avg_sales)) end as 'twelve_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (13 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(13 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (13 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (13 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (13 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (13 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (13 * avg_sales)) > 0 and (closing_quantity - (13 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'thirteen', case when (closing_quantity - (13 * avg_sales)) <= 0 then 0
else (closing_quantity - (13 * avg_sales)) end as 'thirteen_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (14 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(14 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (14 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (14 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (14 * avg_sales)) > (CASE
WHEN IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(red_zone,0) / 100) *
IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and
(closing_quantity - (14 * avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow'
when ((closing_quantity - (14 * avg_sales)) > 0 and (closing_quantity - (14 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'fourteen', case when (closing_quantity - (14 * avg_sales)) <= 0 then 0
else (closing_quantity - (14 * avg_sales)) end as 'fourteen_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (15 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(15 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (15 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (15 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (15 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (15 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (15 * avg_sales)) > 0 and (closing_quantity - (15 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'fifteen', case when (closing_quantity - (15 * avg_sales)) <= 0 then 0
else (closing_quantity - (15 * avg_sales)) end as 'fifteen_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (16 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(16 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (16 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (16 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (16 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (16 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (16 * avg_sales)) > 0 and (closing_quantity - (16 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'sixteen', case when (closing_quantity - (16 * avg_sales)) <= 0 then 0
else (closing_quantity - (16 * avg_sales)) end as 'sixteen_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (17 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(17 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (17 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (17 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (17 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (17 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (17 * avg_sales)) > 0 and (closing_quantity - (17 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'seventeen', case when (closing_quantity - (17 * avg_sales)) <= 0 then 0
else (closing_quantity - (17 * avg_sales)) end as 'seventeen_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (18 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(18 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (18 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (18 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (18 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (18 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (18 * avg_sales)) > 0 and (closing_quantity - (18 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'eighteen', case when (closing_quantity - (18 * avg_sales)) <= 0 then 0
else (closing_quantity - (18 * avg_sales)) end as 'eighteen_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (19 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(19 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (19 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (19 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (19 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (19 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (19 * avg_sales)) > 0 and (closing_quantity - (19 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'nineteen', case when (closing_quantity - (19 * avg_sales)) <= 0 then 0
else (closing_quantity - (19 * avg_sales)) end as 'nineteen_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (20 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(20 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (20 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (20 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (20 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (20 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (20 * avg_sales)) > 0 and (closing_quantity - (20 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twenty', case when (closing_quantity - (20 * avg_sales)) <= 0 then 0
else (closing_quantity - (20 * avg_sales)) end as 'twenty_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (21 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity
- (21 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (21 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (21 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (21 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (21 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (21 * avg_sales)) > 0 and (closing_quantity - (21 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twentyone', case when (closing_quantity - (21 * avg_sales)) <= 0 then 0
else (closing_quantity - (21 * avg_sales)) end as 'twentyone_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (22 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(22 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (22 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (22 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (22 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (22 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (22 * avg_sales)) > 0 and (closing_quantity - (22 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twentytwo', case when (closing_quantity - (22 * avg_sales)) <= 0 then 0
else (closing_quantity - (22 * avg_sales)) end as 'twentytwo_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (23 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(23 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (23 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (23 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (23 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (23 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (23 * avg_sales)) > 0 and (closing_quantity - (23 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twentythree', case when (closing_quantity - (23 * avg_sales)) <= 0 then
0 else (closing_quantity - (23 * avg_sales)) end as 'twentythree_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (24 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(24 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (24 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (24 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (24 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (24 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (24 * avg_sales)) > 0 and (closing_quantity - (24 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twentyfour', case when (closing_quantity - (24 * avg_sales)) <= 0 then 0
else (closing_quantity - (24 * avg_sales)) end as 'twentyfour_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (25 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(25 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (25 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (25 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (25 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (25 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (25 * avg_sales)) > 0 and (closing_quantity - (25 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twentyfive', case when (closing_quantity - (25 * avg_sales)) <= 0 then 0
else (closing_quantity - (25 * avg_sales)) end as 'twentyfive_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (26 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(26 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (26 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (26 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (26 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (26 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (26 * avg_sales)) > 0 and (closing_quantity - (26 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twentysix', case when (closing_quantity - (26 * avg_sales)) <= 0 then 0
else (closing_quantity - (26 * avg_sales)) end as 'twentysix_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (27 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(27 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (27 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (27 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (27 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (27 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (27 * avg_sales)) > 0 and (closing_quantity - (27 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0)
/ 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END)
and buffer_norm > 0) then 'Red' end as 'twentyseven', case when
(closing_quantity - (27 * avg_sales)) <= 0 then 0 else (closing_quantity - (27 *
avg_sales)) end as 'twentyseven_qty', case when ifnull(buffer_norm,
0) = 0 then 'White' when ((closing_quantity - (28 * avg_sales)) <= 0 and
buffer_norm > 0) then 'Black' when ((closing_quantity - (28 * avg_sales)) >
buffer_norm and buffer_norm > 0) then 'Blue' when ((closing_quantity - (28 *
avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (28 * avg_sales)) <=
buffer_norm and buffer_norm > 0) then 'Green' when ((closing_quantity - (28
* avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (28 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (28 * avg_sales)) > 0 and (closing_quantity - (28 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twentyeight', case when (closing_quantity - (28 * avg_sales)) <= 0 then
0 else (closing_quantity - (28 * avg_sales)) end as 'twentyeight_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (29 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(29 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (29 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (29 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (29 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (29 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (29 * avg_sales)) > 0 and (closing_quantity - (29 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twentynine', case when (closing_quantity - (29 * avg_sales)) <= 0 then 0
else (closing_quantity - (29 * avg_sales)) end as 'twentynine_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (30 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(30 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (30 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (30 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (30 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (30 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (30 * avg_sales)) > 0 and (closing_quantity - (30 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'thirty', case when (closing_quantity - (30 * avg_sales)) <= 0 then 0
else (closing_quantity - (30 * avg_sales)) end as 'thirty_qty' from (
select tr.sku_id, tr.node_id, round(sum(tr.sales) / 15, 2) as avg_sales,
t.closing_quantity, ifnull(bn.buffer_norm, (select buffer_norm from
buffer_norm use index(inx_sku_node_efdt) where effective_from < tr.transaction_date
and sku_id = tr.sku_id and node_id = tr.node_id order by effective_from desc limit
1)) as buffer_norm, ifnull(bn.is_default_zone,'Y') as is_default_zone,
ifnull(bn.yellow_zone,0) as yellow_zone, ifnull(bn.red_zone,0) as red_zone,
case when (t.closing_quantity + t.in_transit - t.pending_orders) <= 0 then 0
else (t.closing_quantity + t.in_transit - t.pending_orders) end as
'final_quantity' from transaction tr inner join transaction t
on t.transaction_date = ?param0 and t.sku_id = tr.sku_id and
t.node_id = tr.node_id left join buffer_norm bn use
index(inx_sku_node_efdt) on bn.sku_id = tr.sku_id and bn.node_id =
tr.node_id and bn.effective_from = ?param0 where tr.sku_id = ?
param1 and tr.node_id = ?param2 and tr.transaction_date > ?param3 group
by tr.sku_id, tr.node_id ) as sku_grid inner join sku s on
s.sku_id = sku_grid.sku_id inner join node n on n.node_id =
sku_grid.node_id inner join sku_category sc on sc.sku_category_id =
(select sku_category_id from sku_category where sku_id = sku_grid.sku_id limit 1)
inner join category c on c.category_id = sc.category_id]
2018-03-15 10:55:11,643-Adding file [ExcessInventoryHelper.xml] to list of watched
files.
2018-03-15 10:55:11,644-Adding file [StockoutAvailabilityChartHelper.xml] to list
of watched files.
2018-03-15 10:55:11,645-Adding file [InventoryTurnsHelper.xml] to list of watched
files.
2018-03-15 10:55:11,645-Statement Id: [SelectInventoryTurns] Prepared SQL: [select
rpl.transaction_date, rpl.category_id, rpl.category_name,
date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date, sum(1) as
count, sum(rpl.closing_quantity) as closing_quantity, sum(rpl.sales) as sales
from replenishment rpl where rpl.category_id is not null and
rpl.transaction_date = ?param0 group by rpl.transaction_date,
rpl.category_id]
2018-03-15 10:55:11,645-Statement Id: [SelectInventoryTurnsSKU] Prepared SQL:
[select rpl.transaction_date, rpl.category_id, rpl.sku_id, rpl.category_name,
date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date, sum(1) as
count, sum(rpl.closing_quantity) as closing_quantity, sum(rpl.sales) as sales
from replenishment rpl where rpl.category_id is not null and
rpl.transaction_date = ?param0 group by rpl.transaction_date,
rpl.category_id, rpl.sku_id]
2018-03-15 10:55:11,645-Adding file [CntQtyFillRateChartHelper.xml] to list of
watched files.
2018-03-15 10:55:11,645-Statement Id: [SelectCntQtyFillRateChart] Prepared SQL:
[select rpl.transaction_date, rpl.closing_stock_zone,
group_concat(distinct(rpl.sku_id) SEPARATOR ',') as str_sku_ids,
date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date,
sum(rpl.closing_quantity) as closing_quantity, sum(rpl.buffer_norm) as buffer_norm
from replenishment rpl where rpl.closing_stock_zone != "White" and
rpl.transaction_date = ?param0 group by rpl.transaction_date,
rpl.closing_stock_zone]
2018-03-15 10:55:11,645-Statement Id: [SelectCntQtyFillRateChartNode] Prepared SQL:
[select rpl.transaction_date, rpl.closing_stock_zone, rpl.node_id,
group_concat(distinct(rpl.sku_id) SEPARATOR ',') as str_sku_ids,
date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date,
sum(rpl.closing_quantity) as closing_quantity, sum(rpl.buffer_norm) as buffer_norm
from replenishment rpl where rpl.closing_stock_zone != "White" and
rpl.transaction_date = ?param0 group by rpl.transaction_date,
rpl.closing_stock_zone, rpl.node_id]
2018-03-15 10:55:11,645-Statement Id: [SelectCntQtyFillRateChartCategory] Prepared
SQL: [select rpl.transaction_date, rpl.closing_stock_zone, rpl.category_id,
group_concat(distinct(rpl.sku_id) SEPARATOR ',') as str_sku_ids,
date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date,
sum(rpl.closing_quantity) as closing_quantity, sum(rpl.buffer_norm) as buffer_norm
from replenishment rpl where rpl.closing_stock_zone != "White" and
rpl.transaction_date = ?param0 group by rpl.transaction_date,
rpl.closing_stock_zone, rpl.category_id]
2018-03-15 10:55:11,645-Statement Id: [SelectCntQtyFillRateChartSKU] Prepared SQL:
[select rpl.transaction_date, rpl.closing_stock_zone, rpl.sku_id,
group_concat(distinct(rpl.sku_id) SEPARATOR ',') as str_sku_ids,
date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date,
sum(rpl.closing_quantity) as closing_quantity, sum(rpl.buffer_norm) as buffer_norm
from replenishment rpl where rpl.closing_stock_zone != "White" and
rpl.transaction_date = ?param0 group by rpl.transaction_date,
rpl.closing_stock_zone, rpl.sku_id]
2018-03-15 10:55:11,649-Adding file [UserDataPermissionHelper.xml] to list of
watched files.
2018-03-15 10:55:11,649-Statement Id: [SelectDataPermissionByRole] Prepared SQL:
[select user_data_id, role_id, object_type, object_id, chk_state, created_by,
created_on from user_data_permissions WHERE role_id = ?param0 AND
object_type = ?param1]
2018-03-15 10:55:11,649-Statement Id: [InsertUserDataPermission] Prepared SQL:
[insert into user_data_permissions (role_id, object_type, object_id,
chk_state, created_by, created_on) values ( ?param0 , ?param1 , ?
param2 , ?param3 , ?param4 , NOW());]
2018-03-15 10:55:11,649-Statement Id: [InsertUserDataPermission.SelectKey] Prepared
SQL: [select last_insert_id() as value]
2018-03-15 10:55:11,649-Statement Id: [DeleteDataPermissionByRole] Prepared SQL:
[delete from user_data_permissions where role_id = ?param0]
2018-03-15 10:55:11,649-Adding file [RoleHelper.xml] to list of watched files.
2018-03-15 10:55:11,649-Statement Id: [SelectRoleNameDuplicate] Prepared SQL:
[select role_id,role_name,status,created_by,created_on,modified_by,modified_on
from role where role_name = ?param0 and role_id != ?param1]
2018-03-15 10:55:11,649-Statement Id: [InsertRole] Prepared SQL: [insert into role
(role_name,status,created_by,created_on) values ( ?param0 , ?
param1 , ?param2 , NOW());]
2018-03-15 10:55:11,649-Statement Id: [InsertRole.SelectKey] Prepared SQL: [select
last_insert_id() as value]
2018-03-15 10:55:11,649-Statement Id: [UpdateRole] Prepared SQL: [update role set
role_name = ?param0 , status = ?param1 , modified_by = ?param2 ,
modified_on = NOW() where role_id = ?param3]
2018-03-15 10:55:11,649-Adding file [BOMHelper.xml] to list of watched files.
2018-03-15 10:55:11,649-Statement Id: [SelectBOMDictionary] Prepared SQL: [SELECT
DISTINCT sk.sku_code, bm.sku_id FROM sku sk INNER JOIN bom bm ON bm.sku_id =
sk.sku_id]
2018-03-15 10:55:11,653-Adding file [Matrix1Helper.xml] to list of watched files.
2018-03-15 10:55:11,658-Statement Id: [SelectUserCheckAuthenticate]
PreparedStatement : [select user_id, user_name, first_name, middle_name,
last_name, email, mobile, description, password, status, approved, locked,
role_id, region_id, created_by, created_on, modified_by, modified_on from
user where user_name = ?param0 and password = ?param1 and status = 1]
2018-03-15 10:55:11,658-Statement Id: [SelectUserCheckAuthenticate] Parameters: [?
param0=[user_name,Admin], ?param1=[password,Ennovate789]]
2018-03-15 10:55:11,658-Statement Id: [SelectUserCheckAuthenticate] Types: [?
param0=[String, System.String], ?param1=[String, System.String]]
2018-03-15 10:55:11,659-Open Connection "29307921" to "MySQL, MySQL provider ver
6:5:4:0".
2018-03-15 10:55:11,663-Close Connection "29307921" to "MySQL, MySQL provider ver
6:5:4:0".
2018-03-15 10:55:11,667-Adding file [SqlMap.config] to list of watched files.
2018-03-15 10:55:11,668-Add property "provider" value "MySql6"
2018-03-15 10:55:11,668-Add property "datasource" value "localhost"
2018-03-15 10:55:11,668-Add property "database" value "scmplus"
2018-03-15 10:55:11,668-Add property "port" value "3306"
2018-03-15 10:55:11,668-Add property "userid" value "root"
2018-03-15 10:55:11,668-Add property "password" value "root"
2018-03-15 10:55:11,668-Add property "mapperResources" value
"./bin/iBatis/SqlMapper/"
2018-03-15 10:55:11,669-Adding file [CategoryHelper.xml] to list of watched files.
2018-03-15 10:55:11,669-Statement Id: [SelectCategoryByCode] Prepared SQL: [select
category_id, category_code, category_name, parent_id, status, created_by,
created_on, modified_by, modified_on from category where category_code = ?
param0]
2018-03-15 10:55:11,670-Statement Id: [SelectCategoryForDuplicate] Prepared SQL:
[select category_id, category_code, category_name, parent_id, status, created_by,
created_on, modified_by, modified_on from category where category_code = ?
param0 and category_name = ?param1 and parent_id = ?param2]
2018-03-15 10:55:11,670-Statement Id: [SelectCategoryBy] Prepared SQL: [select
category_id, parent_id, category_name, category_code, status, created_by,
created_on, modified_by, modified_on from category where ?param0 = ?
param1]
2018-03-15 10:55:11,670-Statement Id: [InsertCategory] Prepared SQL: [insert into
category (category_code, category_name, parent_id, status, created_by,
created_on) values ( ?param0 , ?param1 , ?param2 , ?param3 , ?
param4 , NOW());]
2018-03-15 10:55:11,670-Statement Id: [InsertCategory.SelectKey] Prepared SQL:
[select last_insert_id() as value]
2018-03-15 10:55:11,670-Statement Id: [UpdateCategory] Prepared SQL: [update
category set category_name = ?param0 , parent_id = ?param1 ,
status = ?param2 , modified_by = ?param3 , modified_on = NOW()
where category_code = ?param4]
2018-03-15 10:55:11,670-Statement Id: [DeleteCategory] Prepared SQL: [delete from
category where category_id = ?param0]
2018-03-15 10:55:11,670-Adding file [NodeHelper.xml] to list of watched files.
2018-03-15 10:55:11,671-Statement Id: [MapNode] Prepared SQL: [select node_id,
node_code, node_name, address_line1, address_line2, status from node where node_id
= ?param0 union all select '' as node_id, '' as node_code, '' as
node_name, '' as address_line1, '' as address_line2, null as status limit 1]
2018-03-15 10:55:11,671-Statement Id: [SelectNodeByCode] Prepared SQL: [select
node_id, node_code, node_name, parent_id, location_id, address_line1,
address_line2, latitude, longitude, status, created_by, created_on,
modified_by, modified_on from node where node_code = ?param0]
2018-03-15 10:55:11,671-Statement Id: [SelectNodeForDuplicate] Prepared SQL:
[select node_id, node_code, node_name, parent_id, location_id, address_line1,
address_line2, latitude, longitude, status, created_by, created_on,
modified_by, modified_on from node where node_code = ?param0 and node_name
= ?param1 and parent_id = ?param2]
2018-03-15 10:55:11,671-Statement Id: [InsertNode] Prepared SQL: [insert into node
(node_code, node_name, parent_id, location_id, address_line1, address_line2,
latitude, longitude, status, created_by, created_on) values
( ?param0 , ?param1 , ?param2 , ?param3 , ?param4 , ?param5 , ?param6 , ?
param7 , ?param8 , ?param9 , NOW());]
2018-03-15 10:55:11,671-Statement Id: [InsertNode.SelectKey] Prepared SQL: [select
last_insert_id() as value]
2018-03-15 10:55:11,672-Statement Id: [UpdateNode] Prepared SQL: [update node set
node_name = ?param0 , parent_id = ?param1 , location_id = ?
param2 , address_line1 = ?param3 , address_line2 = ?param4 ,
latitude = ?param5 , longitude = ?param6 , status = ?param7 ,
modified_by = ?param8 , modified_on = NOW() where node_code = ?
param9]
2018-03-15 10:55:11,672-Statement Id: [DeleteNode] Prepared SQL: [delete from node
where node_id = ?param0]
2018-03-15 10:55:11,672-Adding file [AttributeHelper.xml] to list of watched files.
2018-03-15 10:55:11,672-Statement Id: [SelectAttributeByCode] Prepared SQL: [select
attribute_id, attribute_code, attribute_name, data_type, optional, status,
created_by, created_on, modified_by, modified_on from attribute where
attribute_code = ?param0]
2018-03-15 10:55:11,672-Statement Id: [InsertAttribute] Prepared SQL: [insert into
attribute (attribute_code, attribute_name, data_type, optional, status,
created_by, created_on) values ( ?param0 , ?param1 , ?param2 , ?
param3 , ?param4 , ?param5 , NOW());]
2018-03-15 10:55:11,672-Statement Id: [InsertAttribute.SelectKey] Prepared SQL:
[select last_insert_id() as value]
2018-03-15 10:55:11,672-Statement Id: [UpdateAttribute] Prepared SQL: [update
attribute set attribute_name = ?param0 , data_type = ?param1 ,
optional = ?param2 , status = ?param3 , modified_by = ?param4 ,
modified_on = NOW() where attribute_id = ?param5]
2018-03-15 10:55:11,672-Statement Id: [DeleteAttribute] Prepared SQL: [delete from
attribute where attribute_id = ?param0]
2018-03-15 10:55:11,673-Adding file [SKUHelper.xml] to list of watched files.
2018-03-15 10:55:11,673-Statement Id: [MapSKU] Prepared SQL: [select * from sku
where sku_id = ?param0]
2018-03-15 10:55:11,673-Statement Id: [SelectSKUByCode] Prepared SQL: [select
sku_id, sku_code, sku_name, sku_description, status, created_by, created_on,
modified_by, modified_on from sku where sku_code = ?param0]
2018-03-15 10:55:11,673-Statement Id: [SelectSKUForDuplicate] Prepared SQL: [select
sku_id, sku_code, sku_name, sku_description, status, created_by, created_on,
modified_by, modified_on from sku where sku_code = ?param0 and sku_name =
?param1 and sku_description = ?param2]
2018-03-15 10:55:11,673-Statement Id: [SelectBatchInsertedSKU] Prepared SQL:
[select sku_id, sku_code, sku_name, sku_description, status, created_by,
created_on, modified_by, modified_on from sku where sku_id >= (SELECT
(AUTO_INCREMENT - ?param0 ) FROM information_schema.`TABLES` WHERE TABLE_NAME =
'sku' LIMIT 1)]
2018-03-15 10:55:11,673-Statement Id: [InsertSKU] Prepared SQL: [insert into sku
(sku_code, sku_name, sku_description, status, created_by, created_on) values
( ?param0 , ?param1 , ?param2 , ?param3 , ?param4 , NOW());]
2018-03-15 10:55:11,673-Statement Id: [InsertSKU.SelectKey] Prepared SQL: [select
last_insert_id() as value]
2018-03-15 10:55:11,673-Statement Id: [UpdateSKU] Prepared SQL: [update sku set
sku_name = ?param0 , sku_description = ?param1 , status = ?
param2 , modified_by = ?param3 , modified_on = NOW() where
sku_id = ?param4]
2018-03-15 10:55:11,674-Statement Id: [DeleteSKU] Prepared SQL: [delete from sku
where sku_id = ?param0]
2018-03-15 10:55:11,674-Adding file [SKUAttributeHelper.xml] to list of watched
files.
2018-03-15 10:55:11,674-Statement Id: [SelectSKUAttributeMappingBySKUAttribute]
Prepared SQL: [select sku_attribute_mapping_id, sku_id, attribute_id, value,
created_by, created_on from sku_attribute_mapping where sku_id = ?param0
and attribute_id = ?param1]
2018-03-15 10:55:11,674-Statement Id: [SelectSKUAttributeMappingBySKU] Prepared
SQL: [select sku_attribute_mapping_id, sku_id, attribute_id, value, created_by,
created_on from sku_attribute_mapping where sku_id = ?param0]
2018-03-15 10:55:11,674-Statement Id: [InsertSKUAttributeMapping] Prepared SQL:
[insert into sku_attribute_mapping (sku_id, attribute_id, value, created_by,
created_on) values ( ?param0 , ?param1 , ?param2 , ?param3 ,
NOW());]
2018-03-15 10:55:11,674-Statement Id: [InsertSKUAttributeMapping.SelectKey]
Prepared SQL: [select last_insert_id() as value]
2018-03-15 10:55:11,674-Statement Id: [UpdateSKUAttributeMapping] Prepared SQL:
[update sku_attribute_mapping set value = ?param0 , where
sku_attribute_mapping_id = ?param1]
2018-03-15 10:55:11,674-Statement Id: [DeleteSKUAttributeMapping] Prepared SQL:
[delete from sku_attribute_mapping where sku_id = ?param0 and attribute_id
= ?param1]
2018-03-15 10:55:11,674-Adding file [NodeSKUHelper.xml] to list of watched files.
2018-03-15 10:55:11,674-Statement Id: [SelectNodeSKUMappingByNodeSKU] Prepared SQL:
[select node_sku_mapping_id, receiver_node_id, sku_id, supplier_node_id,
effective_date, created_by, created_on from node_sku_mapping where sku_id =
?param0 and receiver_node_id = ?param1 and supplier_node_id = ?param2 and
effective_date = ?param3]
2018-03-15 10:55:11,674-Statement Id: [selectSKU] Prepared SQL: [select * from sku
where sku_id = ?param0]
2018-03-15 10:55:11,674-Statement Id: [selectNode] Prepared SQL: [select * from
node where node_id = ?param0]
2018-03-15 10:55:11,674-Statement Id: [InsertNodeSKUMapping] Prepared SQL: [insert
into node_sku_mapping (receiver_node_id, sku_id, supplier_node_id,
effective_date, created_by, created_on) values ( ?param0 , ?param1 ,
?param2 , date_format( ?param3 , "%Y-%c-%e %H:%i:%s"), ?param4 , NOW());]
2018-03-15 10:55:11,674-Statement Id: [InsertNodeSKUMapping.SelectKey] Prepared
SQL: [select last_insert_id() as value]
2018-03-15 10:55:11,674-Statement Id: [DeleteNodeSKUMapping] Prepared SQL: [delete
from node_sku_mapping where node_sku_mapping_id = ?param0]
2018-03-15 10:55:11,674-Adding file [BufferNormHelper.xml] to list of watched
files.
2018-03-15 10:55:11,674-Statement Id: [MapBufferNorm] Prepared SQL: [select
buffer_norm_id, sku_id, node_id, buffer_norm, olt, plt, tlt, rlt,
max_sales_per_day, safety_factor, unit_selling_price, unit_purchase_price,
moq, eoq, effective_from, created_by, created_on, modified_by, modified_on
from buffer_norm where buffer_norm_id = ?param0 union all select '' as
buffer_norm_id, '' as sku_id, '' as node_id, 0 as buffer_norm, 0 as olt, 0 as plt,
0 as tlt, 0 as rlt, 0 as max_sales_per_day, 0 as safety_factor, 0 as
unit_selling_price, 0 as unit_purchase_price, 0 as moq, 0 as eoq, '' as
effective_from, null as created_by, null as created_on, null as modified_by, null
as modified_on limit 1]
2018-03-15 10:55:11,674-Statement Id: [SelectBufferNormBySKUNode] Prepared SQL:
[select buffer_norm_id, sku_id, node_id, buffer_norm, olt, plt, tlt, rlt,
max_sales_per_day, safety_factor, unit_selling_price, unit_purchase_price,
moq, eoq, effective_from, created_by, created_on, modified_by,
modified_on,IFNULL(is_default_zone,'Y') AS is_default_zone, IFNULL(red_zone,0) AS
red_zone, IFNULL(yellow_zone,0) AS yellow_zone from buffer_norm where sku_id
= ?param0 and node_id = ?param1 and effective_from = ?param2]
2018-03-15 10:55:11,674-Statement Id: [SelectBatchInsertedBufferNorm] Prepared SQL:
[select b.buffer_norm_id, b.sku_id, b.node_id, b.buffer_norm, b.olt, b.plt, b.tlt,
b.rlt, b.max_sales_per_day, b.safety_factor, b.unit_selling_price,
b.unit_purchase_price, b.moq, b.eoq, b.effective_from, b.created_by, b.created_on,
b.modified_by, b.modified_on, b.identifier, b.is_default_zone, b.red_zone,
b.yellow_zone from buffer_norm b where identifier = ?param0]
2018-03-15 10:55:11,674-Statement Id: [InsertBufferNorm] Prepared SQL: [insert into
buffer_norm (sku_id, node_id, buffer_norm, olt, plt, tlt, rlt,
max_sales_per_day, safety_factor, unit_selling_price, unit_purchase_price,
moq, eoq, effective_from, created_by, created_on) values ( ?param0 ,
?param1 , ?param2 , ?param3 , ?param4 , ?param5 , ?param6 , ?param7 , ?
param8 , ?param9 , ?param10 , ?param11 , ?param12 , date_format( ?
param13 , "%Y-%c-%e %H:%i:%s"), ?param14 , NOW());]
2018-03-15 10:55:11,674-Statement Id: [InsertBufferNorm.SelectKey] Prepared SQL:
[select last_insert_id() as value]
2018-03-15 10:55:11,674-Statement Id: [UpdateBufferNorm] Prepared SQL: [update
buffer_norm set sku_id = ?param0 , node_id = ?param1 ,
buffer_norm = ?param2 , olt = ?param3 , plt = ?param4 , tlt
= ?param5 , rlt = ?param6 , max_sales_per_day = ?param7 ,
safety_factor = ?param8 , unit_selling_price = ?param9 ,
unit_purchase_price = ?param10 , moq = ?param11 , eoq = ?param12 ,
effective_from = date_format( ?param13 , "%Y-%c-%e %H:%i:%s"), modified_by =
?param14 , modified_on = NOW() where buffer_norm_id = ?param15]
2018-03-15 10:55:11,674-Statement Id: [DeleteBufferNorm] Prepared SQL: [delete from
buffer_norm where buffer_norm_id = ?param0]
2018-03-15 10:55:11,678-Adding file [TransactionHelper.xml] to list of watched
files.
2018-03-15 10:55:11,678-Statement Id: [SelectTransactionForDuplicate] Prepared SQL:
[select transaction_id, sku_id, node_id, supply_node_id, transaction_date, grn,
sales, closing_quantity, in_transit, inst_hold, quality_hold, qa_hold,
pending_orders, orders_in_hand, transport_mode, db_sync, mongo_sync, created_by,
created_on, open_stock_transfer_order, open_planned_order,
open_purchase_request, open_production_order, open_purchase_order, field1, field2,
field3, field4, field5, field6, field7, field8, field9, field10 from
transaction where sku_id = ?param0 and node_id = ?param1 and transaction_date =
?param2]
2018-03-15 10:55:11,678-Statement Id: [SelectReplenishmentList] Prepared SQL:
[select tr.transaction_id, tr.transaction_date,
date_format(tr.transaction_date,'%d/%m/%Y') as display_date,
date_format(tr.transaction_date,'%Y%m%d') as transfilter_date, tr.sku_id,
s.sku_code, s.sku_name, tr.node_id, n.node_code, n.node_name, sc.category_id,
cat.category_code, cat.category_name, ifnull(bn.buffer_norm, 0) as
buffer_norm, ifnull(tr.closing_quantity, 0) as closing_quantity,
ifnull(tr.in_transit, 0) as in_transit, ifnull(tr.sales, 0) as sales,
ifnull(tr.inst_hold, 0) as inst_hold, ifnull(tr.quality_hold, 0) as quality_hold,
ifnull(tr.qa_hold, 0) as qa_hold, ifnull(tr.pending_orders, 0) as
pending_orders, ifnull(tr.orders_in_hand, 0) as orders_in_hand,
ifnull(tr.transport_mode, '') as transport_mode, nsm.supplier_node_id as
supply_node_id, sn.node_name as supply_node_name, sn.node_code as
supply_node_code, ifnull(str.closing_quantity, 0) as supplying_quantity,
ifnull(sbn.buffer_norm, 0) as supplying_buffer_norm,
round(ifnull(bn.buffer_norm, 0),2) as 'green_zone_qty', CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2)
END AS 'yellow_zone_qty', CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END as 'red_zone_qty', case
when ifnull(bn.buffer_norm, 0) = 0 then 'White' when
(ifnull(tr.closing_quantity, 0) <= 0 and ifnull(bn.buffer_norm, 0) > 0) then
'Black' when (ifnull(tr.closing_quantity, 0) > ifnull(bn.buffer_norm, 0) and
ifnull(bn.buffer_norm, 0) > 0) then 'Blue' when (ifnull(tr.closing_quantity,
0) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) and ifnull(tr.closing_quantity,
0) <= ifnull(bn.buffer_norm, 0) and ifnull(bn.buffer_norm, 0) > 0) then 'Green'
when (ifnull(tr.closing_quantity, 0) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) and ifnull(tr.closing_quantity, 0) <=
(CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) and ifnull(bn.buffer_norm, 0) >
0) then 'Yellow' when (ifnull(tr.closing_quantity, 0) > 0 and
ifnull(tr.closing_quantity, 0) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) and ifnull(bn.buffer_norm, 0) > 0) then
'Red' end as 'closing_stock_zone', case when
ifnull(bn.buffer_norm, 0) = 0 then 6 when (ifnull(tr.closing_quantity, 0) <=
0 and ifnull(bn.buffer_norm, 0) > 0) then 1 when
(ifnull(tr.closing_quantity, 0) > ifnull(bn.buffer_norm, 0) and
ifnull(bn.buffer_norm, 0) > 0) then 2 when (ifnull(tr.closing_quantity, 0) >
(CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) and ifnull(tr.closing_quantity,
0) <= ifnull(bn.buffer_norm, 0) and ifnull(bn.buffer_norm, 0) > 0) then 4
when (ifnull(tr.closing_quantity, 0) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) and ifnull(tr.closing_quantity, 0) <=
(CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) and ifnull(bn.buffer_norm, 0) >
0) then 3 when (ifnull(tr.closing_quantity, 0) > 0 and
ifnull(tr.closing_quantity, 0) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) and ifnull(bn.buffer_norm, 0) > 0) then
5 end as 'closing_stock_zone_sort', case when
ifnull(bn.buffer_norm, 0) = 0 then 'White' when
((ifnull(tr.closing_quantity, 0) + ifnull(tr.in_transit, 0) -
ifnull(tr.pending_orders, 0)) <= 0 and ifnull(bn.buffer_norm, 0) > 0) then 'Black'
when ((ifnull(tr.closing_quantity, 0) + ifnull(tr.in_transit, 0) -
ifnull(tr.pending_orders, 0)) > ifnull(bn.buffer_norm, 0) and
ifnull(bn.buffer_norm, 0) > 0) then 'Blue' when
((ifnull(tr.closing_quantity, 0) + ifnull(tr.in_transit, 0) -
ifnull(tr.pending_orders, 0)) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) and
(ifnull(tr.closing_quantity, 0) + tr.in_transit - tr.pending_orders) <=
ifnull(bn.buffer_norm, 0) and ifnull(bn.buffer_norm, 0) > 0) then 'Green'
when ((ifnull(tr.closing_quantity, 0) + ifnull(tr.in_transit, 0) -
ifnull(tr.pending_orders, 0)) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) and (tr.closing_quantity +
tr.in_transit - tr.pending_orders) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2)
ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) and ifnull(bn.buffer_norm,
0) > 0) then 'Yellow' when ((ifnull(tr.closing_quantity, 0) +
ifnull(tr.in_transit, 0) - ifnull(tr.pending_orders, 0)) > 0 and
(ifnull(tr.closing_quantity, 0) + tr.in_transit - tr.pending_orders) <= (CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) and
ifnull(bn.buffer_norm, 0) > 0) then 'Red' end as 'in_transit_zone',
case when ifnull(bn.buffer_norm, 0) = 0 then 6 when
((ifnull(tr.closing_quantity, 0) + ifnull(tr.in_transit, 0) -
ifnull(tr.pending_orders, 0)) <= 0 and ifnull(bn.buffer_norm, 0) > 0) then 1
when ((ifnull(tr.closing_quantity, 0) + ifnull(tr.in_transit, 0) -
ifnull(tr.pending_orders, 0)) > ifnull(bn.buffer_norm, 0) and
ifnull(bn.buffer_norm, 0) > 0) then 2 when ((ifnull(tr.closing_quantity, 0)
+ ifnull(tr.in_transit, 0) - ifnull(tr.pending_orders, 0)) > (CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2)
END) and (ifnull(tr.closing_quantity, 0) + tr.in_transit - tr.pending_orders) <=
ifnull(bn.buffer_norm, 0) and ifnull(bn.buffer_norm, 0) > 0) then 4 when
((ifnull(tr.closing_quantity, 0) + ifnull(tr.in_transit, 0) -
ifnull(tr.pending_orders, 0)) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) and (ifnull(tr.closing_quantity, 0) +
tr.in_transit - tr.pending_orders) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2)
ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) and ifnull(bn.buffer_norm,
0) > 0) then 3 when ((ifnull(tr.closing_quantity, 0) + ifnull(tr.in_transit,
0) - ifnull(tr.pending_orders, 0)) > 0 and (ifnull(tr.closing_quantity, 0) +
tr.in_transit - tr.pending_orders) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) and ifnull(bn.buffer_norm, 0) > 0) then
5 end as 'in_transit_zone_sort', case when
ifnull(sbn.buffer_norm, 0) = 0 then 'White' when
(ifnull(str.closing_quantity, 0) <= 0 and ifnull(sbn.buffer_norm, 0) > 0) then
'Black' when (ifnull(str.closing_quantity, 0) > ifnull(sbn.buffer_norm, 0)
and ifnull(sbn.buffer_norm, 0) > 0) then 'Blue' when
(ifnull(str.closing_quantity, 0) > (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) and
ifnull(str.closing_quantity, 0) <= ifnull(sbn.buffer_norm, 0) and
ifnull(sbn.buffer_norm, 0) > 0) then 'Green' when
(ifnull(str.closing_quantity, 0) > (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) and ifnull(str.closing_quantity, 0) <=
(CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) and ifnull(sbn.buffer_norm, 0)
> 0) then 'Yellow' when (ifnull(str.closing_quantity, 0) > 0 and
ifnull(str.closing_quantity, 0) <= (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) and ifnull(sbn.buffer_norm, 0) > 0)
then 'Red' end as 'supplying_node_zone', case when
ifnull(sbn.buffer_norm, 0) = 0 then 6 when (ifnull(str.closing_quantity, 0)
<= 0 and ifnull(sbn.buffer_norm, 0) > 0) then 1 when
(ifnull(str.closing_quantity, 0) > ifnull(sbn.buffer_norm, 0) and
ifnull(sbn.buffer_norm, 0) > 0) then 2 when (ifnull(str.closing_quantity,
0) > (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) and
ifnull(str.closing_quantity, 0) <= ifnull(sbn.buffer_norm, 0) and
ifnull(sbn.buffer_norm, 0) > 0) then 4 when (ifnull(str.closing_quantity, 0)
> (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) and ifnull(str.closing_quantity, 0) <=
(CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) and ifnull(sbn.buffer_norm, 0)
> 0) then 3 when (ifnull(str.closing_quantity, 0) > 0 and
ifnull(str.closing_quantity, 0) <= (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) and ifnull(sbn.buffer_norm, 0) > 0)
then 5 end as 'supplying_node_zone_sort', case when
((ifnull(bn.buffer_norm, 0) - ifnull(tr.closing_quantity, 0) -
ifnull(tr.in_transit, 0)) + ifnull(tr.pending_orders, 0)) -
(ifnull(tr.open_planned_order, 0) + ifnull(tr.open_purchase_request, 0) +
ifnull(tr.open_production_order, 0) + ifnull(tr.open_purchase_order, 0)) <= 0 then
0 else ((ifnull(bn.buffer_norm, 0) - ifnull(tr.closing_quantity, 0) -
ifnull(tr.in_transit, 0)) + ifnull(tr.pending_orders, 0)) -
(ifnull(tr.open_planned_order, 0) + ifnull(tr.open_purchase_request, 0) +
ifnull(tr.open_production_order, 0) + ifnull(tr.open_purchase_order, 0)) end
as 'replenishment_quantity', case when (ifnull(tr.closing_quantity,
0) + ifnull(tr.in_transit, 0) + ifnull(tr.open_planned_order, 0) +
ifnull(tr.open_purchase_request, 0) + ifnull(tr.open_production_order, 0) +
ifnull(tr.open_purchase_order, 0) ) - ifnull(tr.pending_orders, 0) <= 0 then 0
else (ifnull(tr.closing_quantity, 0) + ifnull(tr.in_transit, 0) +
ifnull(tr.open_planned_order, 0) + ifnull(tr.open_purchase_request, 0) +
ifnull(tr.open_production_order, 0) + ifnull(tr.open_purchase_order, 0) ) -
ifnull(tr.pending_orders, 0) end as 'final_quantity', case
when ifnull(bn.buffer_norm, 0) = 0 then 0 else (CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END)
end as 'mrq', (select count(1) from transaction_comment where
transaction_id = tr.transaction_id) as 'transaction_comment',
ifnull(tr.open_stock_transfer_order, 0) as open_stock_transfer_order,
ifnull(tr.open_planned_order, 0) as open_planned_order,
ifnull(tr.open_purchase_request, 0) as open_purchase_request,
ifnull(tr.open_production_order, 0) as open_production_order,
ifnull(tr.open_purchase_order, 0) as open_purchase_order, tr.field1,
tr.field2, tr.field3, tr.field4, tr.field5, tr.field6, tr.field7, tr.field8,
tr.field9, tr.field10 from ( select transaction_id from
transaction where transaction_date = ?param0 limit ?param1 , ?
param2 ) otr join transaction tr on tr.transaction_id
= otr.transaction_id left join buffer_norm bn on bn.sku_id =
tr.sku_id and bn.node_id = tr.node_id and bn.effective_from = (
select max(effective_from) from buffer_norm where effective_from <=
tr.transaction_date and sku_id = tr.sku_id and node_id = tr.node_id)
left join sku s on s.sku_id = tr.sku_id left join sku_category sc
on sc.sku_id = tr.sku_id left join category cat on cat.category_id
= sc.category_id left join node n on n.node_id = tr.node_id
left join node_sku_mapping nsm on nsm.receiver_node_id = tr.node_id
and nsm.sku_id = tr.sku_id and nsm.effective_date = ( select
max(effective_date) from node_sku_mapping where effective_date <=
tr.transaction_date and sku_id = tr.sku_id and receiver_node_id =
tr.node_id) left join node sn on sn.node_id = nsm.supplier_node_id
left join buffer_norm sbn on sbn.sku_id = nsm.sku_id and sbn.node_id
= nsm.supplier_node_id and sbn.effective_from = ( select
max(effective_from) from buffer_norm where effective_from <=
tr.transaction_date and sku_id = tr.sku_id and node_id = tr.node_id)
left join ( select transaction_id, sku_id, node_id, closing_quantity
from transaction where transaction_date = ?param0 ) str
on str.sku_id = nsm.sku_id and str.node_id = nsm.supplier_node_id and
str.transaction_id = otr.transaction_id order by tr.transaction_id]
2018-03-15 10:55:11,678-Statement Id: [MapTransaction] Prepared SQL: [select * from
transaction where transaction_id = ?param0]
2018-03-15 10:55:11,678-Statement Id: [SelectMaxTransactionDate] Prepared SQL:
[select date_sub(max(transaction_date), interval 15 day) as avg_date,
max(transaction_date) as transaction_date from transaction]
2018-03-15 10:55:11,678-Statement Id: [SelectSKUNodeGroup] Prepared SQL: [select
sku_id, node_id from transaction group by sku_id, node_id]
2018-03-15 10:55:11,678-Statement Id: [SelectTransactionBySKUNode] Prepared SQL:
[select transaction_id, sku_id, node_id, supply_node_id, transaction_date, grn,
sales, closing_quantity, in_transit, inst_hold, quality_hold, qa_hold,
pending_orders, orders_in_hand, transport_mode, db_sync, mongo_sync, created_by,
created_on, open_stock_transfer_order, open_planned_order,
open_purchase_request, open_production_order, open_purchase_order, field1, field2,
field3, field4, field5, field6, field7, field8, field9, field10 from
transaction where sku_id = ?param0 and node_id = ?param1]
2018-03-15 10:55:11,678-Statement Id: [SelectTransactionByDate] Prepared SQL:
[select transaction_id, sku_id, node_id, supply_node_id, transaction_date, grn,
sales, closing_quantity, in_transit, inst_hold, quality_hold, qa_hold,
pending_orders, orders_in_hand, transport_mode, db_sync, mongo_sync, created_by,
created_on, open_stock_transfer_order, open_planned_order,
open_purchase_request, open_production_order, open_purchase_order, field1, field2,
field3, field4, field5, field6, field7, field8, field9, field10 from
transaction where transaction_date = ?param0]
2018-03-15 10:55:11,678-Statement Id: [SelectTransactionDates] Prepared SQL:
[select DATE_FORMAT(transaction_date, '%Y-%m-%d %H:%i:%s') as transaction_date from
transaction group by transaction_date asc limit ?param0]
2018-03-15 10:55:11,678-Statement Id: [SelectBNCalculationTransactionDates]
Prepared SQL: [select DATE_FORMAT(transaction_date, '%Y-%m-%d %H:%i:%s') as
transaction_date from transaction where transaction_date >= ?param0
group by transaction_date asc]
2018-03-15 10:55:11,678-Statement Id: [SelectTransactionIdsForBNCalculation]
Prepared SQL: [select transaction_id from transaction where transaction_date
= ?param0 and sku_id = ?param1 and node_id = ?param2]
2018-03-15 10:55:11,678-Statement Id: [SelectBatchInsertedTransactionID] Prepared
SQL: [select transaction_id, identifier from transaction where identifier = ?
param0]
2018-03-15 10:55:11,682-Statement Id: [SelectUpdateTransactionImport] Prepared SQL:
[select DISTINCT transaction_id from update_transaction WHERE identifier = ?
param0]
2018-03-15 10:55:11,682-Statement Id: [SelectClosingStockForTransactionDate]
Prepared SQL: [SELECT transaction_date, closing_quantity, sales, grn from
transaction WHERE transaction_date < ?param0 AND sku_id = ?param1
AND node_id = ?param2 ORDER BY transaction_date DESC LIMIT 1]
2018-03-15 10:55:11,683-Statement Id: [InsertTransaction] Prepared SQL: [insert
into transaction (sku_id, node_id, supply_node_id, transaction_date, grn,
sales, closing_quantity, in_transit, inst_hold, quality_hold, qa_hold,
pending_orders, orders_in_hand, transport_mode, db_sync, mongo_sync, created_by,
created_on, open_stock_transfer_order, open_planned_order,
open_purchase_request, open_production_order, open_purchase_order, field1, field2,
field3, field4, field5, field6, field7, field8, field9, field10) values
( ?param0 , ?param1 , ?param2 , ?param3 , ?param4 , ?param5 , ?param6 , ?
param7 , ?param8 , ?param9 , ?param10 , ?param11 , ?param12 , ?param13
, 0, 0, ?param14 , NOW(), ?param15 , ?param16 , ?param17 , ?
param18 , ?param19 , ?param20 , ?param21 , ?param22 , ?param23 , ?param24 ,
?param25 , ?param26 , ?param27 , ?param28 , ?param29 );]
2018-03-15 10:55:11,683-Statement Id: [InsertTransaction.SelectKey] Prepared SQL:
[select last_insert_id() as value]
2018-03-15 10:55:11,683-Statement Id: [InsertTransactionComment] Prepared SQL:
[insert into transaction_comment (transaction_id, sku_id, node_id, comment,
reason, created_by, created_on) values ( ?param0 , ?param1 , ?
param2 , ?param3 , ?param4 , ?param5 , NOW());]
2018-03-15 10:55:11,683-Statement Id: [InsertTransactionComment.SelectKey] Prepared
SQL: [select last_insert_id() as value]
2018-03-15 10:55:11,683-Statement Id: [UpdateTransaction] Prepared SQL: [update
transaction set sku_id = ?param0 , node_id = ?param1 ,
supply_node_id = ?param2 , transaction_date = ?param3 , grn = ?
param4 , sales = ?param5 , closing_quantity = ?param6 ,
in_transit = ?param7 , inst_hold = ?param8 , quality_hold = ?
param9 , qa_hold = ?param10 , pending_orders = ?param11 ,
orders_in_hand = ?param12 , transport_mode = ?param13 , db_sync
= ?param14 , mongo_sync = ?param15 where transaction_id = ?
param16]
2018-03-15 10:55:11,684-Statement Id: [DeleteUpdatesTransaction] Prepared SQL:
[delete from update_transaction WHERE identifier = ?param0]
2018-03-15 10:55:11,684-Adding file [SKUCategoryHelper.xml] to list of watched
files.
2018-03-15 10:55:11,684-Statement Id: [SelectSKUCategoryBySKUCategory] Prepared
SQL: [select sku_category_id, sku_id, category_id, created_by, created_on
from sku_category where sku_id = ?param0 and category_id = ?param1]
2018-03-15 10:55:11,684-Statement Id: [InsertSKUCategory] Prepared SQL: [insert
into sku_category (sku_id, category_id, created_by, created_on)
values ( ?param0 , ?param1 , ?param2 , NOW());]
2018-03-15 10:55:11,684-Statement Id: [InsertSKUCategory.SelectKey] Prepared SQL:
[select last_insert_id() as value]
2018-03-15 10:55:11,684-Adding file [SKUChartHelper.xml] to list of watched files.
2018-03-15 10:55:11,684-Statement Id: [SelectSKUChart] Prepared SQL: [select
rpl.transaction_date, date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date,
sum(rpl.closing_quantity) as closing_quantity, sum(rpl.red_zone_qty) as
red_zone_qty, sum(rpl.yellow_zone_qty) as yellow_zone_qty,
sum(rpl.green_zone_qty) as green_zone_qty, sum(rpl.in_transit) as in_transit,
sum(rpl.sales) as sales, count(distinct(rpl.sku_id)) as total_sku_count,
(select count(distinct(sku_id)) from replenishment where closing_stock_zone_sort =
2 and transaction_date = rpl.transaction_date) as blue_sku_count, (select
count(distinct(sku_id)) from replenishment where (closing_stock_zone_sort = 1 or
closing_stock_zone_sort = 5) and transaction_date = rpl.transaction_date) as
rb_sku_count from replenishment rpl where rpl.transaction_date = ?
param0 group by rpl.transaction_date]
2018-03-15 10:55:11,684-Statement Id: [SelectSKUChartNode] Prepared SQL: [select
rpl.transaction_date, date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date, rpl.node_id,
sum(rpl.closing_quantity) as closing_quantity, sum(rpl.red_zone_qty) as
red_zone_qty, sum(rpl.yellow_zone_qty) as yellow_zone_qty,
sum(rpl.green_zone_qty) as green_zone_qty, sum(rpl.in_transit) as in_transit,
sum(rpl.sales) as sales, count(distinct(rpl.sku_id)) as total_sku_count,
ifnull((select count(distinct(sku_id)) from replenishment where
closing_stock_zone_sort = 2 and transaction_date = rpl.transaction_date and node_id
= rpl.node_id), 0) as blue_sku_count, ifnull((select count(distinct(sku_id))
from replenishment where (closing_stock_zone_sort = 1 or closing_stock_zone_sort =
5) and transaction_date = rpl.transaction_date and node_id = rpl.node_id), 0) as
rb_sku_count from replenishment rpl where rpl.transaction_date = ?
param0 group by rpl.transaction_date, rpl.node_id]
2018-03-15 10:55:11,684-Statement Id: [SelectSKUChartCategory] Prepared SQL:
[select rpl.transaction_date, date_format(rpl.transaction_date,'%d/%m/%Y') as
display_date, date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date,
rpl.category_id, sum(rpl.closing_quantity) as closing_quantity,
sum(rpl.red_zone_qty) as red_zone_qty, sum(rpl.yellow_zone_qty) as yellow_zone_qty,
sum(rpl.green_zone_qty) as green_zone_qty, sum(rpl.in_transit) as in_transit,
sum(rpl.sales) as sales, count(distinct(rpl.sku_id)) as total_sku_count,
ifnull((select count(distinct(sku_id)) from replenishment where
closing_stock_zone_sort = 2 and transaction_date = rpl.transaction_date and
category_id = rpl.category_id), 0) as blue_sku_count, ifnull((select
count(distinct(sku_id)) from replenishment where (closing_stock_zone_sort = 1 or
closing_stock_zone_sort = 5) and transaction_date = rpl.transaction_date and
category_id = rpl.category_id), 0) as rb_sku_count from replenishment rpl
where rpl.transaction_date = ?param0 and rpl.category_id is not null
group by rpl.transaction_date, rpl.category_id]
2018-03-15 10:55:11,684-Statement Id: [SelectSKUChartSKU] Prepared SQL: [select
rpl.transaction_date, date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date, rpl.sku_id,
sum(rpl.closing_quantity) as closing_quantity, sum(rpl.red_zone_qty) as
red_zone_qty, sum(rpl.yellow_zone_qty) as yellow_zone_qty,
sum(rpl.green_zone_qty) as green_zone_qty, sum(rpl.in_transit) as in_transit,
sum(rpl.sales) as sales, count(distinct(rpl.sku_id)) as total_sku_count,
ifnull((select count(distinct(sku_id)) from replenishment where
closing_stock_zone_sort = 2 and transaction_date = rpl.transaction_date and sku_id
= rpl.sku_id), 0) as blue_sku_count, ifnull((select count(distinct(sku_id))
from replenishment where (closing_stock_zone_sort = 1 or closing_stock_zone_sort =
5) and transaction_date = rpl.transaction_date and sku_id = rpl.sku_id), 0) as
rb_sku_count from replenishment rpl use index(inx_sku_chart_s) where
rpl.transaction_date = ?param0 group by rpl.transaction_date, rpl.sku_id]
2018-03-15 10:55:11,684-Adding file [ImportExportLogHelper.xml] to list of watched
files.
2018-03-15 10:55:11,684-Statement Id: [SelectImportExportLogByType] Prepared SQL:
[select import_export_log_id, reference_date, reference_type, reference_title,
type, log_file, status, status_text, comment, created_by, created_on from
import_export_log where type = ?param0 order by reference_date desc]
2018-03-15 10:55:11,688-Statement Id: [InsertImportExportLog] Prepared SQL: [insert
into import_export_log (reference_date, reference_type, reference_title,
type, log_file, status, status_text, comment, created_by, created_on) values
(date_format( ?param0 , "%Y-%c-%e %H:%i:%s"), ?param1 , ?param2 , ?param3 , ?
param4 , ?param5 , ?param6 , ?param7 , ?param8 , NOW() );]
2018-03-15 10:55:11,688-Statement Id: [InsertImportExportLog.SelectKey] Prepared
SQL: [select last_insert_id() as value]
2018-03-15 10:55:11,688-Statement Id: [UpdateImportExportLog] Prepared SQL: [update
import_export_log set reference_date = date_format( ?param0 , "%Y-%c-%e %H:
%i:%s"), reference_type = ?param1 , reference_title = ?param2 ,
type = ?param3 , log_file = ?param4 , status = ?param5 ,
status_text = ?param6 , comment = ?param7 where
import_export_log_id = ?param8]
2018-03-15 10:55:11,688-Statement Id: [DeleteImportExportLog] Prepared SQL: [delete
from import_export_log where import_export_log_id = ?param0]
2018-03-15 10:55:11,688-Adding file [DynamicBufferManagementHelper.xml] to list of
watched files.
2018-03-15 10:55:11,688-Statement Id: [InsertDynamicBufferManagement] Prepared SQL:
[insert into dynamic_buffer_management (activate_auto_dbm,
excess_inv_occ_count, excess_inv_decrease_per, excess_inv_wait_cycle,
stockout_inv_occ_count, stockout_inv_decrease_per, stockout_inv_wait_cycle,
override_sku_location_dbm, activate_auto_dcm, red_percentage,
yellow_percentage, green_percentage, created_by, created_on) values (
?param0 , ?param1 , ?param2 , ?param3 , ?param4 , ?param5 , ?param6 ,
?param7 , ?param8 , ?param9 , ?param10 , ?param11 , ?param12 , NOW());]
2018-03-15 10:55:11,688-Statement Id: [InsertDynamicBufferManagement.SelectKey]
Prepared SQL: [select last_insert_id() as value]
2018-03-15 10:55:11,688-Statement Id: [UpdateDynamicBufferManagement] Prepared SQL:
[update dynamic_buffer_management set activate_auto_dbm = ?param0 ,
excess_inv_occ_count = ?param1 , excess_inv_decrease_per = ?param2 ,
excess_inv_wait_cycle = ?param3 , stockout_inv_occ_count = ?param4 ,
stockout_inv_decrease_per = ?param5 , stockout_inv_wait_cycle = ?param6 ,
override_sku_location_dbm = ?param7 , activate_auto_dcm = ?param8 ,
red_percentage = ?param9 , yellow_percentage = ?param10 ,
green_percentage = ?param11 , modified_by = ?param12 , modified_on
= NOW() where dynamic_buffer_management_id = ?param13]
2018-03-15 10:55:11,688-Adding file [ReplenishmentHelper.xml] to list of watched
files.
2018-03-15 10:55:11,688-Statement Id: [SelectReplenishmentData] Prepared SQL:
[select transaction_id, transaction_date, display_date, transfilter_date, sku_id,
sku_code, sku_name, node_id, node_code, node_name, category_id,
category_code, category_name, buffer_norm, grn, closing_quantity, in_transit,
sales, inst_hold, quality_hold, qa_hold, pending_orders, orders_in_hand,
transport_mode, supply_node_id, supply_node_name, supply_node_code,
supplying_quantity, supplying_buffer_norm, green_zone_qty, yellow_zone_qty,
red_zone_qty, closing_stock_zone, closing_stock_zone_sort, in_transit_zone,
in_transit_zone_sort, supplying_node_zone, supplying_node_zone_sort,
replenishment_quantity, final_quantity, mrq, transaction_comment,
open_stock_transfer_order, open_planned_order, open_purchase_request,
open_production_order, open_purchase_order, field1, field2, field3, field4,
field5, field6, field7, field8, field9, field10, mtd_sales, mtd_grn from
replenishment where transaction_date = ?param0]
2018-03-15 10:55:11,688-Statement Id: [SelectReplenishmentBySKUNode] Prepared SQL:
[select transaction_id, transaction_date, display_date, transfilter_date, sku_id,
sku_code, sku_name, node_id, node_code, node_name, category_id,
category_code, category_name, buffer_norm, closing_quantity, grn, in_transit,
sales, inst_hold, quality_hold, qa_hold, pending_orders, orders_in_hand,
transport_mode, supply_node_id, supply_node_name, supply_node_code,
supplying_quantity, supplying_buffer_norm, green_zone_qty, yellow_zone_qty,
red_zone_qty, closing_stock_zone, closing_stock_zone_sort, in_transit_zone,
in_transit_zone_sort, supplying_node_zone, supplying_node_zone_sort,
replenishment_quantity, final_quantity, mrq, transaction_comment,
open_stock_transfer_order, open_planned_order, open_purchase_request,
open_production_order, open_purchase_order, field1, field2, field3, field4,
field5, field6, field7, field8, field9, field10, mtd_sales, mtd_grn from
replenishment where transaction_date = ?param0 and sku_id = ?
param1 and node_id = ?param2]
2018-03-15 10:55:11,688-Statement Id: [SelectReplenishmentDates] Prepared SQL:
[SELECT DATE_FORMAT(transaction_date,'%Y-%m-%d') AS transaction_date FROM
replenishment USE INDEX (transaction_date) WHERE (transaction_date
BETWEEN ?param0 and ?param1 ) GROUP BY transaction_date]
2018-03-15 10:55:11,693-Statement Id: [InsertReplenishmentList] Prepared SQL:
[insert into replenishment (transaction_id, transaction_date, display_date,
transfilter_date, sku_id, sku_code, sku_name, node_id, node_code, node_name,
category_id, category_code, category_name, buffer_norm, grn, in_transit,
sales, inst_hold, quality_hold, qa_hold, pending_orders, orders_in_hand,
transport_mode, supply_node_id, supply_node_name, supply_node_code,
supplying_quantity, supplying_buffer_norm, green_zone_qty, yellow_zone_qty,
red_zone_qty, closing_stock_zone, closing_stock_zone_sort, in_transit_zone,
in_transit_zone_sort, supplying_node_zone, supplying_node_zone_sort,
replenishment_quantity, final_quantity, mrq, transaction_comment, db_sync,
mongo_sync, open_stock_transfer_order, open_planned_order,
open_purchase_request, open_production_order, open_purchase_order, field1,
field2, field3, field4, field5, field6, field7, field8, field9, field10,
closing_quantity, mtd_sales, mtd_grn ) SELECT tmt.transaction_id,
tmt.transaction_date, tmt.display_date, tmt.transfilter_date, tmt.sku_id,
tmt.sku_code, tmt.sku_name, tmt.node_id, tmt.node_code, tmt.node_name,
tmt.category_id, tmt.category_code, tmt.category_name, tmt.buffer_norm,
tmt.grn, tmt.in_transit, tmt.sales, tmt.inst_hold, tmt.quality_hold,
tmt.qa_hold, tmt.pending_orders, tmt.orders_in_hand, tmt.transport_mode,
tmt.supply_node_id, tmt.supply_node_name, tmt.supply_node_code,
tmt.supplying_quantity, tmt.supplying_buffer_norm, tmt.green_zone_qty,
tmt.yellow_zone_qty, tmt.red_zone_qty, tmt.closing_stock_zone,
tmt.closing_stock_zone_sort, tmt.in_transit_zone, tmt.in_transit_zone_sort,
tmt.supplying_node_zone, tmt.supplying_node_zone_sort,
tmt.replenishment_quantity, tmt.final_quantity, tmt.mrq,
tmt.transaction_comment, tmt.db_sync, tmt.mongo_sync,
tmt.open_stock_transfer_order, tmt.open_planned_order, tmt.open_purchase_request,
tmt.open_production_order, tmt.open_purchase_order, tmt.field1, tmt.field2,
tmt.field3, tmt.field4, tmt.field5, tmt.field6, tmt.field7, tmt.field8, tmt.field9,
tmt.field10, CASE WHEN IFNULL(tmt.closing_quantity,0) > 0 THEN
tmt.closing_quantity ELSE IFNULL((SELECT tcl.closing_quantity FROM
TRANSACTION tcl WHERE tcl.transaction_date < tmt.transaction_date AND
tcl.sku_id = tmt.sku_id AND tcl.node_id = tmt.node_id ORDER BY
tcl.transaction_date DESC LIMIT 1), 0) END AS closing_quantity,
IFNULL((SELECT SUM(tms.sales) FROM TRANSACTION tms USE INDEX
(inx_tdt_sku_node_sales) WHERE tms.transaction_date <= tmt.transaction_date
AND tms.transaction_date >= DATE_FORMAT(tmt.transaction_date,'%Y-%m-01') AND
tms.sku_id = tmt.sku_id AND tms.node_id = tmt.node_id), 0) AS mtd_sales,
IFNULL((SELECT SUM(tmg.grn) FROM TRANSACTION tmg USE INDEX (inx_tdt_sku_node_grn)
WHERE tmg.transaction_date <= tmt.transaction_date AND tmg.transaction_date >=
DATE_FORMAT(tmt.transaction_date,'%Y-%m-01') AND tmg.sku_id = tmt.sku_id AND
tmg.node_id = tmt.node_id), 0) AS mtd_grn FROM (SELECT
tr.transaction_id, tr.transaction_date, DATE_FORMAT(tr.transaction_date,'%d/%m/%Y')
AS display_date, DATE_FORMAT(tr.transaction_date,'%Y%m%d') AS transfilter_date,
tr.sku_id, s.sku_code, s.sku_name, tr.node_id, n.node_code, n.node_name,
sc.category_id, cat.category_code, cat.category_name, IFNULL(bn.buffer_norm,
0) AS buffer_norm, IFNULL(tr.closing_quantity, 0) AS closing_quantity,
IFNULL(tr.grn,0) AS grn, IFNULL(tr.in_transit, 0) AS in_transit, IFNULL(tr.sales,
0) AS sales, IFNULL(tr.inst_hold, 0) AS inst_hold, IFNULL(tr.quality_hold,
0) AS quality_hold, IFNULL(tr.qa_hold, 0) AS qa_hold,
IFNULL(tr.pending_orders, 0) AS pending_orders, IFNULL(tr.orders_in_hand, 0) AS
orders_in_hand, IFNULL(tr.transport_mode, '') AS transport_mode, CASE WHEN
IFNULL(tr.supply_node_id,0) > 0 THEN IFNULL(tr.supply_node_id,0) ELSE
IFNULL(nsm.supplier_node_id,0) END AS supply_node_id, sn.node_name AS
supply_node_name, sn.node_code AS supply_node_code,
IFNULL(str.closing_quantity, 0) AS supplying_quantity,
IFNULL(sbn.buffer_norm, 0) AS supplying_buffer_norm,
ROUND(IFNULL(bn.buffer_norm, 0),2) AS 'green_zone_qty', CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2)
END AS 'yellow_zone_qty', CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END AS 'red_zone_qty', CASE
WHEN IFNULL(bn.buffer_norm, 0) = 0 THEN 'White' WHEN
(IFNULL(tr.closing_quantity, 0) <= 0 AND IFNULL(bn.buffer_norm, 0) > 0) THEN
'Black' WHEN (IFNULL(tr.closing_quantity, 0) > IFNULL(bn.buffer_norm, 0) AND
IFNULL(bn.buffer_norm, 0) > 0) THEN 'Blue' WHEN (IFNULL(tr.closing_quantity,
0) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(tr.closing_quantity,
0) <= IFNULL(bn.buffer_norm, 0) AND IFNULL(bn.buffer_norm, 0) > 0) THEN 'Green'
WHEN (IFNULL(tr.closing_quantity, 0) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(tr.closing_quantity, 0) <=
(CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(bn.buffer_norm, 0) >
0) THEN 'Yellow' WHEN (IFNULL(tr.closing_quantity, 0) > 0 AND
IFNULL(tr.closing_quantity, 0) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(bn.buffer_norm, 0) > 0) THEN
'Red' END AS 'closing_stock_zone', CASE WHEN
IFNULL(bn.buffer_norm, 0) = 0 THEN 6 WHEN (IFNULL(tr.closing_quantity, 0) <=
0 AND IFNULL(bn.buffer_norm, 0) > 0) THEN 1 WHEN
(IFNULL(tr.closing_quantity, 0) > IFNULL(bn.buffer_norm, 0) AND
IFNULL(bn.buffer_norm, 0) > 0) THEN 2 WHEN (IFNULL(tr.closing_quantity, 0) >
(CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(tr.closing_quantity,
0) <= IFNULL(bn.buffer_norm, 0) AND IFNULL(bn.buffer_norm, 0) > 0) THEN 4
WHEN (IFNULL(tr.closing_quantity, 0) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(tr.closing_quantity, 0) <=
(CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(bn.buffer_norm, 0) >
0) THEN 3 WHEN (IFNULL(tr.closing_quantity, 0) > 0 AND
IFNULL(tr.closing_quantity, 0) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(bn.buffer_norm, 0) > 0) THEN
5 END AS 'closing_stock_zone_sort', CASE WHEN
IFNULL(bn.buffer_norm, 0) = 0 THEN 'White' WHEN
((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) <= 0 AND IFNULL(bn.buffer_norm, 0) > 0) THEN 'Black'
WHEN ((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > IFNULL(bn.buffer_norm, 0) AND
IFNULL(bn.buffer_norm, 0) > 0) THEN 'Blue' WHEN
((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND
(IFNULL(tr.closing_quantity, 0) + tr.in_transit - tr.pending_orders) <=
IFNULL(bn.buffer_norm, 0) AND IFNULL(bn.buffer_norm, 0) > 0) THEN 'Green'
WHEN ((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND (tr.closing_quantity +
tr.in_transit - tr.pending_orders) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2)
ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(bn.buffer_norm,
0) > 0) THEN 'Yellow' WHEN ((IFNULL(tr.closing_quantity, 0) +
IFNULL(tr.in_transit, 0) - IFNULL(tr.pending_orders, 0)) > 0 AND
(IFNULL(tr.closing_quantity, 0) + tr.in_transit - tr.pending_orders) <= (CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND
IFNULL(bn.buffer_norm, 0) > 0) THEN 'Red' END AS 'in_transit_zone',
CASE WHEN IFNULL(bn.buffer_norm, 0) = 0 THEN 6 WHEN
((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) <= 0 AND IFNULL(bn.buffer_norm, 0) > 0) THEN 1
WHEN ((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > IFNULL(bn.buffer_norm, 0) AND
IFNULL(bn.buffer_norm,
0) > 0) THEN 2 WHEN ((IFNULL(tr.closing_quantity, 0) +
IFNULL(tr.in_transit, 0) - IFNULL(tr.pending_orders, 0)) > (CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2)
END) AND (IFNULL(tr.closing_quantity, 0) + tr.in_transit - tr.pending_orders) <=
IFNULL(bn.buffer_norm, 0) AND IFNULL(bn.buffer_norm, 0) > 0) THEN 4 WHEN
((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND (IFNULL(tr.closing_quantity, 0) +
tr.in_transit - tr.pending_orders) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2)
ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(bn.buffer_norm,
0) > 0) THEN 3 WHEN ((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit,
0) - IFNULL(tr.pending_orders, 0)) > 0 AND (IFNULL(tr.closing_quantity, 0) +
tr.in_transit - tr.pending_orders) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(bn.buffer_norm, 0) > 0) THEN
5 END AS 'in_transit_zone_sort', CASE WHEN
IFNULL(sbn.buffer_norm, 0) = 0 THEN 'White' WHEN
(IFNULL(str.closing_quantity, 0) <= 0 AND IFNULL(sbn.buffer_norm, 0) > 0) THEN
'Black' WHEN (IFNULL(str.closing_quantity, 0) > IFNULL(sbn.buffer_norm, 0)
AND IFNULL(sbn.buffer_norm, 0) > 0) THEN 'Blue' WHEN
(IFNULL(str.closing_quantity, 0) > (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) AND
IFNULL(str.closing_quantity, 0) <= IFNULL(sbn.buffer_norm, 0) AND
IFNULL(sbn.buffer_norm, 0) > 0) THEN 'Green' WHEN
(IFNULL(str.closing_quantity, 0) > (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) AND IFNULL(str.closing_quantity, 0) <=
(CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) AND IFNULL(sbn.buffer_norm, 0)
> 0) THEN 'Yellow' WHEN (IFNULL(str.closing_quantity, 0) > 0 AND
IFNULL(str.closing_quantity, 0) <= (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) AND IFNULL(sbn.buffer_norm, 0) > 0)
THEN 'Red' END AS 'supplying_node_zone', CASE WHEN
IFNULL(sbn.buffer_norm, 0) = 0 THEN 6 WHEN (IFNULL(str.closing_quantity, 0)
<= 0 AND IFNULL(sbn.buffer_norm, 0) > 0) THEN 1 WHEN
(IFNULL(str.closing_quantity, 0) > IFNULL(sbn.buffer_norm, 0) AND
IFNULL(sbn.buffer_norm, 0) > 0) THEN 2 WHEN (IFNULL(str.closing_quantity, 0)
> (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) AND
IFNULL(str.closing_quantity, 0) <= IFNULL(sbn.buffer_norm, 0) AND
IFNULL(sbn.buffer_norm, 0) > 0) THEN 4 WHEN (IFNULL(str.closing_quantity, 0)
> (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) AND IFNULL(str.closing_quantity, 0) <=
(CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) AND IFNULL(sbn.buffer_norm, 0)
> 0) THEN 3 WHEN (IFNULL(str.closing_quantity, 0) > 0 AND
IFNULL(str.closing_quantity, 0) <= (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) AND IFNULL(sbn.buffer_norm, 0) > 0)
THEN 5 END AS 'supplying_node_zone_sort', CASE WHEN
((IFNULL(bn.buffer_norm, 0) - IFNULL(tr.closing_quantity, 0) -
IFNULL(tr.in_transit, 0)) + IFNULL(tr.pending_orders, 0)) -
(IFNULL(tr.open_planned_order, 0) + IFNULL(tr.open_purchase_request, 0) +
IFNULL(tr.open_production_order, 0) + IFNULL(tr.open_purchase_order, 0)) <= 0 THEN
0 ELSE ((IFNULL(bn.buffer_norm, 0) - IFNULL(tr.closing_quantity, 0) -
IFNULL(tr.in_transit, 0)) + IFNULL(tr.pending_orders, 0)) -
(IFNULL(tr.open_planned_order, 0) + IFNULL(tr.open_purchase_request, 0) +
IFNULL(tr.open_production_order, 0) + IFNULL(tr.open_purchase_order, 0)) END
AS 'replenishment_quantity', CASE WHEN (IFNULL(tr.closing_quantity,
0) + IFNULL(tr.in_transit, 0) + IFNULL(tr.open_planned_order, 0) +
IFNULL(tr.open_purchase_request, 0) + IFNULL(tr.open_production_order, 0) +
IFNULL(tr.open_purchase_order, 0) ) - IFNULL(tr.pending_orders, 0) <= 0 THEN 0
ELSE (IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) +
IFNULL(tr.open_planned_order, 0) + IFNULL(tr.open_purchase_request, 0) +
IFNULL(tr.open_production_order, 0) + IFNULL(tr.open_purchase_order, 0) ) -
IFNULL(tr.pending_orders, 0) END AS 'final_quantity', CASE
WHEN IFNULL(bn.buffer_norm, 0) = 0 THEN 0 ELSE (CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END)
END AS 'mrq', (SELECT COUNT(1) FROM transaction_comment WHERE
transaction_id = tr.transaction_id) AS 'transaction_comment', 0 AS db_sync, 0 AS
mongo_sync, IFNULL(tr.open_stock_transfer_order, 0) AS
open_stock_transfer_order, IFNULL(tr.open_planned_order, 0) AS open_planned_order,
IFNULL(tr.open_purchase_request, 0) AS open_purchase_request,
IFNULL(tr.open_production_order, 0) AS open_production_order,
IFNULL(tr.open_purchase_order, 0) AS open_purchase_order, tr.field1,
tr.field2, tr.field3, tr.field4, tr.field5, tr.field6, tr.field7, tr.field8,
tr.field9, tr.field10 from ( select tt.transaction_id from
transaction tt use index (transaction_date) inner join update_transaction ut
use index (inx_transactionid) on ut.transaction_id = tt.transaction_id
where tt.transaction_date = ?param0 ORDER BY tt.sku_id limit ?
param1 , ?param2 ) otr join transaction tr on
tr.transaction_id = otr.transaction_id LEFT JOIN buffer_norm bn USE INDEX
(inx_sku_node_efdt) ON bn.sku_id = tr.sku_id AND bn.node_id =
tr.node_id AND bn.effective_from = ( SELECT MAX(effective_from) FROM
buffer_norm WHERE effective_from <= tr.transaction_date AND sku_id =
tr.sku_id AND node_id = tr.node_id) LEFT JOIN sku s ON
s.sku_id = tr.sku_id LEFT JOIN sku_category sc ON
sc.sku_category_id = (SELECT sku_category_id FROM sku_category WHERE sku_id =
tr.sku_id LIMIT 1) LEFT JOIN category cat ON cat.category_id =
sc.category_id LEFT JOIN node n ON n.node_id = tr.node_id
LEFT OUTER JOIN node_sku_mapping nsm USE INDEX (inx_sku_receiver_node_efdt)
ON nsm.receiver_node_id = tr.node_id AND nsm.sku_id = tr.sku_id AND
nsm.effective_date = ( SELECT MAX(effective_date) FROM node_sku_mapping
WHERE effective_date <= tr.transaction_date AND sku_id = tr.sku_id
AND receiver_node_id = tr.node_id) LEFT JOIN node sn ON CASE WHEN
IFNULL(tr.supply_node_id,0) > 0 THEN sn.node_id = tr.supply_node_id ELSE
sn.node_id = nsm.supplier_node_id END LEFT JOIN buffer_norm sbn USE INDEX
(inx_sku_node_efdt) ON sbn.sku_id = tr.sku_id AND CASE WHEN
IFNULL(tr.supply_node_id,0) > 0 THEN sbn.node_id = tr.supply_node_id ELSE
sbn.node_id = nsm.supplier_node_id END AND sbn.effective_from =
( SELECT MAX(effective_from) FROM buffer_norm WHERE effective_from <=
tr.transaction_date AND sku_id = tr.sku_id AND node_id = tr.node_id)
LEFT JOIN TRANSACTION str USE INDEX (inx_tdt_sku_node_snode) ON
str.transaction_date = tr.transaction_date AND str.sku_id = tr.sku_id
AND CASE WHEN IFNULL(tr.supply_node_id,0) > 0 THEN str.node_id =
IFNULL(tr.supply_node_id,0) ELSE str.node_id = nsm.supplier_node_id END
GROUP BY tr.transaction_id ORDER BY tr.transaction_id) tmt ON
DUPLICATE KEY UPDATE category_id=VALUES(category_id),
category_code=VALUES(category_code), category_name=VALUES(category_name),
buffer_norm=VALUES(buffer_norm), closing_quantity=VALUES(closing_quantity),
grn=VALUES(grn), in_transit=VALUES(in_transit), sales=VALUES(sales),
inst_hold=VALUES(inst_hold), quality_hold=VALUES(quality_hold),
qa_hold=VALUES(qa_hold), pending_orders=VALUES(pending_orders),
orders_in_hand=VALUES(orders_in_hand), mtd_sales=VALUES(mtd_sales),
mtd_grn=VALUES(mtd_grn), transport_mode=VALUES(transport_mode),
supply_node_id=VALUES(supply_node_id), supply_node_name=VALUES(supply_node_name),
supply_node_code=VALUES(supply_node_code),
supplying_quantity=VALUES(supplying_quantity),
supplying_buffer_norm=VALUES(supplying_buffer_norm),
green_zone_qty=VALUES(green_zone_qty), yellow_zone_qty=VALUES(yellow_zone_qty),
red_zone_qty=VALUES(red_zone_qty), closing_stock_zone=VALUES(closing_stock_zone),
closing_stock_zone_sort=VALUES(closing_stock_zone_sort),
in_transit_zone=VALUES(in_transit_zone),
in_transit_zone_sort=VALUES(in_transit_zone_sort),
supplying_node_zone=VALUES(supplying_node_zone),
supplying_node_zone_sort=VALUES(supplying_node_zone_sort),
replenishment_quantity=VALUES(replenishment_quantity),
final_quantity=VALUES(final_quantity), mrq=VALUES(mrq), db_sync=VALUES(db_sync),
mongo_sync=VALUES(mongo_sync),
open_stock_transfer_order=VALUES(open_stock_transfer_order),
open_planned_order=VALUES(open_planned_order),
open_purchase_request=VALUES(open_purchase_request),
open_production_order=VALUES(open_production_order),
open_purchase_order=VALUES(open_purchase_order), field1=VALUES(field1),
field2=VALUES(field2), field3=VALUES(field3), field4=VALUES(field4),
field5=VALUES(field5), field6=VALUES(field6), field7=VALUES(field7),
field8=VALUES(field8), field9=VALUES(field9), field10=VALUES(field10);]
2018-03-15 10:55:11,693-Statement Id: [InsertReplenishmentListFullSync] Prepared
SQL: [insert into replenishment (transaction_id, transaction_date,
display_date, transfilter_date, sku_id, sku_code, sku_name, node_id, node_code,
node_name, category_id, category_code, category_name, buffer_norm,
closing_quantity, in_transit, sales, inst_hold, quality_hold, qa_hold,
pending_orders, orders_in_hand, transport_mode, supply_node_id,
supply_node_name, supply_node_code, supplying_quantity, supplying_buffer_norm,
green_zone_qty, yellow_zone_qty, red_zone_qty, closing_stock_zone,
closing_stock_zone_sort, in_transit_zone, in_transit_zone_sort,
supplying_node_zone, supplying_node_zone_sort, replenishment_quantity,
final_quantity, mrq, transaction_comment, db_sync, mongo_sync,
open_stock_transfer_order, open_planned_order, open_purchase_request,
open_production_order, open_purchase_order, field1, field2, field3, field4, field5,
field6, field7, field8, field9, field10 ) SELECT tr.transaction_id,
tr.transaction_date, DATE_FORMAT(tr.transaction_date,'%d/%m/%Y') AS display_date,
DATE_FORMAT(tr.transaction_date,'%Y%m%d') AS transfilter_date, tr.sku_id,
s.sku_code, s.sku_name, tr.node_id, n.node_code, n.node_name, sc.category_id,
cat.category_code, cat.category_name, IFNULL(bn.buffer_norm, 0) AS
buffer_norm, IFNULL(tr.closing_quantity, 0) AS closing_quantity,
IFNULL(tr.in_transit, 0) AS in_transit, IFNULL(tr.sales, 0) AS sales,
IFNULL(tr.inst_hold, 0) AS inst_hold, IFNULL(tr.quality_hold, 0) AS quality_hold,
IFNULL(tr.qa_hold, 0) AS qa_hold, IFNULL(tr.pending_orders, 0) AS
pending_orders, IFNULL(tr.orders_in_hand, 0) AS orders_in_hand,
IFNULL(tr.transport_mode, '') AS transport_mode, CASE WHEN
IFNULL(tr.supply_node_id,0) > 0 THEN IFNULL(tr.supply_node_id,0) ELSE
IFNULL(nsm.supplier_node_id,0) END AS supply_node_id, sn.node_name AS
supply_node_name, sn.node_code AS supply_node_code,
IFNULL(str.closing_quantity, 0) AS supplying_quantity,
IFNULL(sbn.buffer_norm, 0) AS supplying_buffer_norm,
ROUND(IFNULL(bn.buffer_norm, 0),2) AS 'green_zone_qty', CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2)
END AS 'yellow_zone_qty', CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END AS 'red_zone_qty', CASE
WHEN IFNULL(bn.buffer_norm, 0) = 0 THEN 'White' WHEN
(IFNULL(tr.closing_quantity, 0) <= 0 AND IFNULL(bn.buffer_norm, 0) > 0) THEN
'Black' WHEN (IFNULL(tr.closing_quantity, 0) > IFNULL(bn.buffer_norm, 0) AND
IFNULL(bn.buffer_norm, 0) > 0) THEN 'Blue' WHEN (IFNULL(tr.closing_quantity,
0) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(tr.closing_quantity,
0) <= IFNULL(bn.buffer_norm, 0) AND IFNULL(bn.buffer_norm, 0) > 0) THEN 'Green'
WHEN (IFNULL(tr.closing_quantity, 0) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(tr.closing_quantity, 0) <=
(CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(bn.buffer_norm, 0) >
0) THEN 'Yellow' WHEN (IFNULL(tr.closing_quantity, 0) > 0 AND
IFNULL(tr.closing_quantity, 0) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(bn.buffer_norm, 0) > 0) THEN
'Red' END AS 'closing_stock_zone', CASE WHEN
IFNULL(bn.buffer_norm, 0) = 0 THEN 6 WHEN (IFNULL(tr.closing_quantity, 0) <=
0 AND IFNULL(bn.buffer_norm, 0) > 0) THEN 1 WHEN
(IFNULL(tr.closing_quantity, 0) > IFNULL(bn.buffer_norm, 0) AND
IFNULL(bn.buffer_norm, 0) > 0) THEN 2 WHEN (IFNULL(tr.closing_quantity, 0) >
(CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(tr.closing_quantity,
0) <= IFNULL(bn.buffer_norm, 0) AND IFNULL(bn.buffer_norm, 0) > 0) THEN 4
WHEN (IFNULL(tr.closing_quantity, 0) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(tr.closing_quantity, 0) <=
(CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(bn.buffer_norm, 0) >
0) THEN 3 WHEN (IFNULL(tr.closing_quantity, 0) > 0 AND
IFNULL(tr.closing_quantity, 0) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(bn.buffer_norm, 0) > 0) THEN
5 END AS 'closing_stock_zone_sort', CASE WHEN
IFNULL(bn.buffer_norm, 0) = 0 THEN 'White' WHEN
((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) <= 0 AND IFNULL(bn.buffer_norm, 0) > 0) THEN 'Black'
WHEN ((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > IFNULL(bn.buffer_norm, 0) AND
IFNULL(bn.buffer_norm, 0) > 0) THEN 'Blue' WHEN
((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND
(IFNULL(tr.closing_quantity, 0) + tr.in_transit - tr.pending_orders) <=
IFNULL(bn.buffer_norm, 0) AND IFNULL(bn.buffer_norm, 0) > 0) THEN 'Green'
WHEN ((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND (tr.closing_quantity +
tr.in_transit - tr.pending_orders) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2)
ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(bn.buffer_norm,
0) > 0) THEN 'Yellow' WHEN ((IFNULL(tr.closing_quantity, 0) +
IFNULL(tr.in_transit, 0) - IFNULL(tr.pending_orders, 0)) > 0 AND
(IFNULL(tr.closing_quantity, 0) + tr.in_transit - tr.pending_orders) <= (CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND
IFNULL(bn.buffer_norm, 0) > 0) THEN 'Red' END AS 'in_transit_zone',
CASE WHEN IFNULL(bn.buffer_norm, 0) = 0 THEN 6 WHEN
((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) <= 0 AND IFNULL(bn.buffer_norm, 0) > 0) THEN 1
WHEN ((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > IFNULL(bn.buffer_norm, 0) AND
IFNULL(bn.buffer_norm, 0) > 0) THEN 2 WHEN ((IFNULL(tr.closing_quantity, 0)
+ IFNULL(tr.in_transit, 0) - IFNULL(tr.pending_orders, 0)) > (CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2)
END) AND (IFNULL(tr.closing_quantity, 0) + tr.in_transit - tr.pending_orders) <=
IFNULL(bn.buffer_norm, 0) AND IFNULL(bn.buffer_norm, 0) > 0) THEN 4 WHEN
((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) -
IFNULL(tr.pending_orders, 0)) > (CASE WHEN IFNULL(bn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND (IFNULL(tr.closing_quantity, 0) +
tr.in_transit - tr.pending_orders) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.yellow_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2)
ELSE ROUND(((2 / 3) * IFNULL(bn.buffer_norm, 0)),2) END) AND IFNULL(bn.buffer_norm,
0) > 0) THEN 3 WHEN ((IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit,
0) - IFNULL(tr.pending_orders, 0)) > 0 AND (IFNULL(tr.closing_quantity, 0) +
tr.in_transit - tr.pending_orders) <= (CASE WHEN IFNULL(bn.is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) * IFNULL(bn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END) AND IFNULL(bn.buffer_norm, 0) > 0) THEN
5 END AS 'in_transit_zone_sort', CASE WHEN
IFNULL(sbn.buffer_norm, 0) = 0 THEN 'White' WHEN
(IFNULL(str.closing_quantity, 0) <= 0 AND IFNULL(sbn.buffer_norm, 0) > 0) THEN
'Black' WHEN (IFNULL(str.closing_quantity, 0) > IFNULL(sbn.buffer_norm, 0)
AND IFNULL(sbn.buffer_norm, 0) > 0) THEN 'Blue' WHEN
(IFNULL(str.closing_quantity, 0) > (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) AND
IFNULL(str.closing_quantity, 0) <= IFNULL(sbn.buffer_norm, 0) AND
IFNULL(sbn.buffer_norm, 0) > 0) THEN 'Green' WHEN
(IFNULL(str.closing_quantity, 0) > (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.red_zone,0)
/ 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE ROUND(IFNULL(sbn.buffer_norm, 0) /
3,2) END) AND IFNULL(str.closing_quantity, 0) <= (CASE WHEN
IFNULL(sbn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(sbn.yellow_zone,0) / 100)
* IFNULL(sbn.buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(sbn.buffer_norm,
0)),2) END) AND IFNULL(sbn.buffer_norm, 0) > 0) THEN 'Yellow' WHEN
(IFNULL(str.closing_quantity, 0) > 0 AND IFNULL(str.closing_quantity, 0) <= (CASE
WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(sbn.red_zone,0) /
100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2)
END) AND IFNULL(sbn.buffer_norm, 0) > 0) THEN 'Red' END AS
'supplying_node_zone', CASE WHEN IFNULL(sbn.buffer_norm, 0) = 0
THEN 6 WHEN (IFNULL(str.closing_quantity, 0) <= 0 AND
IFNULL(sbn.buffer_norm, 0) > 0) THEN 1 WHEN (IFNULL(str.closing_quantity, 0)
> IFNULL(sbn.buffer_norm, 0) AND IFNULL(sbn.buffer_norm, 0) > 0) THEN 2 WHEN
(IFNULL(str.closing_quantity, 0) > (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) AND
IFNULL(str.closing_quantity, 0) <= IFNULL(sbn.buffer_norm, 0) AND
IFNULL(sbn.buffer_norm, 0) > 0) THEN 4 WHEN (IFNULL(str.closing_quantity, 0)
> (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) AND IFNULL(str.closing_quantity, 0) <=
(CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(sbn.yellow_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(sbn.buffer_norm, 0)),2) END) AND IFNULL(sbn.buffer_norm, 0)
> 0) THEN 3 WHEN (IFNULL(str.closing_quantity, 0) > 0 AND
IFNULL(str.closing_quantity, 0) <= (CASE WHEN IFNULL(sbn.is_default_zone,'Y') = 'N'
THEN ROUND(((IFNULL(sbn.red_zone,0) / 100) * IFNULL(sbn.buffer_norm, 0)),2) ELSE
ROUND(IFNULL(sbn.buffer_norm, 0) / 3,2) END) AND IFNULL(sbn.buffer_norm, 0) > 0)
THEN 5 END AS 'supplying_node_zone_sort', CASE WHEN
((IFNULL(bn.buffer_norm, 0) - IFNULL(tr.closing_quantity, 0) -
IFNULL(tr.in_transit, 0)) + IFNULL(tr.pending_orders, 0)) -
(IFNULL(tr.open_planned_order, 0) + IFNULL(tr.open_purchase_request, 0) +
IFNULL(tr.open_production_order, 0) + IFNULL(tr.open_purchase_order, 0)) <= 0 THEN
0 ELSE ((IFNULL(bn.buffer_norm, 0) - IFNULL(tr.closing_quantity, 0) -
IFNULL(tr.in_transit, 0)) + IFNULL(tr.pending_orders, 0)) -
(IFNULL(tr.open_planned_order, 0) + IFNULL(tr.open_purchase_request, 0) +
IFNULL(tr.open_production_order, 0) + IFNULL(tr.open_purchase_order, 0)) END
AS 'replenishment_quantity', CASE WHEN (IFNULL(tr.closing_quantity,
0) + IFNULL(tr.in_transit, 0) + IFNULL(tr.open_planned_order, 0) +
IFNULL(tr.open_purchase_request, 0) + IFNULL(tr.open_production_order, 0) +
IFNULL(tr.open_purchase_order, 0) ) - IFNULL(tr.pending_orders, 0) <= 0 THEN 0
ELSE (IFNULL(tr.closing_quantity, 0) + IFNULL(tr.in_transit, 0) +
IFNULL(tr.open_planned_order, 0) + IFNULL(tr.open_purchase_request, 0) +
IFNULL(tr.open_production_order, 0) + IFNULL(tr.open_purchase_order, 0) ) -
IFNULL(tr.pending_orders, 0) END AS 'final_quantity', CASE
WHEN IFNULL(bn.buffer_norm, 0) = 0 THEN 0 ELSE (CASE WHEN
IFNULL(bn.is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(bn.red_zone,0) / 100) *
IFNULL(bn.buffer_norm, 0)),2) ELSE ROUND(IFNULL(bn.buffer_norm, 0) / 3,2) END)
END AS 'mrq', (SELECT COUNT(1) FROM transaction_comment WHERE
transaction_id = tr.transaction_id) AS 'transaction_comment', 0 AS db_sync, 0 AS
mongo_sync, IFNULL(tr.open_stock_transfer_order, 0),
IFNULL(tr.open_planned_order, 0), IFNULL(tr.open_purchase_request,
0),IFNULL(tr.open_production_order, 0), IFNULL(tr.open_purchase_order, 0),
tr.field1, tr.field2, tr.field3, tr.field4, tr.field5, tr.field6, tr.field7,
tr.field8, tr.field9, tr.field10 from ( select tt.transaction_id
from transaction tt use index (transaction_date) where
tt.transaction_date = ?param0 ORDER BY tt.sku_id limit ?
param1 , ?param2 ) otr join transaction tr on
tr.transaction_id = otr.transaction_id LEFT JOIN buffer_norm bn USE INDEX
(inx_sku_node_efdt) ON bn.sku_id = tr.sku_id AND bn.node_id =
tr.node_id AND bn.effective_from = ( SELECT MAX(effective_from) FROM
buffer_norm WHERE effective_from <= tr.transaction_date AND sku_id =
tr.sku_id AND node_id = tr.node_id) LEFT JOIN sku s ON
s.sku_id = tr.sku_id LEFT JOIN sku_category sc ON
sc.sku_category_id = (SELECT sku_category_id FROM sku_category WHERE sku_id =
tr.sku_id LIMIT 1) LEFT JOIN category cat ON cat.category_id =
sc.category_id LEFT JOIN node n ON n.node_id = tr.node_id
LEFT OUTER JOIN node_sku_mapping nsm USE INDEX (inx_sku_receiver_node_efdt)
ON nsm.receiver_node_id = tr.node_id AND nsm.sku_id = tr.sku_id AND
nsm.effective_date = ( SELECT MAX(effective_date) FROM node_sku_mapping
WHERE effective_date <= tr.transaction_date AND sku_id = tr.sku_id
AND receiver_node_id = tr.node_id) LEFT JOIN node sn ON CASE WHEN
IFNULL(tr.supply_node_id,0) > 0 THEN sn.node_id = tr.supply_node_id ELSE
sn.node_id = nsm.supplier_node_id END LEFT JOIN buffer_norm sbn USE INDEX
(inx_sku_node_efdt) ON sbn.sku_id = tr.sku_id AND CASE WHEN
IFNULL(tr.supply_node_id,0) > 0 THEN sbn.node_id = tr.supply_node_id ELSE
sbn.node_id = nsm.supplier_node_id END AND sbn.effective_from =
( SELECT MAX(effective_from) FROM buffer_norm WHERE effective_from <=
tr.transaction_date AND sku_id = tr.sku_id AND node_id = tr.node_id)
LEFT JOIN TRANSACTION str USE INDEX (inx_tdt_sku_node_snode) ON
str.transaction_date = tr.transaction_date AND str.sku_id = tr.sku_id
AND CASE WHEN IFNULL(tr.supply_node_id,0) > 0 THEN str.node_id =
IFNULL(tr.supply_node_id,0) ELSE str.node_id = nsm.supplier_node_id END
GROUP BY tr.transaction_id ORDER BY tr.transaction_id]
2018-03-15 10:55:11,697-Adding file [UserHelper.xml] to list of watched files.
2018-03-15 10:55:11,698-Statement Id: [SelectUserNameDuplicate] Prepared SQL:
[select user_id, user_name, first_name, middle_name, last_name, email, mobile,
description, password, status, approved, locked, role_id, region_id,
created_by, created_on, modified_by, modified_on from user where user_name =
?param0 and user_id != ?param1]
2018-03-15 10:55:11,698-Statement Id: [SelectUserMobileDuplicate] Prepared SQL:
[select user_id, user_name, first_name, middle_name, last_name, email, mobile,
description, password, status, approved, locked, role_id, region_id,
created_by, created_on, modified_by, modified_on from user where mobile = ?
param0 and user_id != ?param1]
2018-03-15 10:55:11,698-Statement Id: [SelectUserCheckAuthenticate] Prepared SQL:
[select user_id, user_name, first_name, middle_name, last_name, email, mobile,
description, password, status, approved, locked, role_id, region_id,
created_by, created_on, modified_by, modified_on from user where user_name =
?param0 and password = ?param1 and status = 1]
2018-03-15 10:55:11,698-Statement Id: [SelectUserCheckLocked] Prepared SQL: [select
user_id, user_name, first_name, middle_name, last_name, email, mobile, description,
password, status, approved, locked, role_id, region_id, created_by,
created_on, modified_by, modified_on from user where user_name = ?param0]
2018-03-15 10:55:11,698-Statement Id: [InsertUser] Prepared SQL: [insert into user
(user_name, first_name, middle_name, last_name, email, mobile, description,
password, status, approved, locked, role_id, region_id, created_by,
created_on) values ( ?param0 , ?param1 , ?param2 , ?param3 , ?
param4 , ?param5 , ?param6 , ?param7 , ?param8 , ?param9 , ?param10 ,
?param11 , ?param12 , ?param13 , NOW());]
2018-03-15 10:55:11,698-Statement Id: [InsertUser.SelectKey] Prepared SQL: [select
last_insert_id() as value]
2018-03-15 10:55:11,698-Statement Id: [UpdateUser] Prepared SQL: [update user set
user_name = ?param0 , first_name = ?param1 , middle_name = ?param2
, last_name = ?param3 , email = ?param4 , mobile = ?
param5 , description = ?param6 , password = ?param7 , status
= ?param8 , approved = ?param9 , locked = ?param10 ,
role_id = ?param11 , region_id = ?param12 , modified_by = ?param13
, modified_on = NOW() where user_id = ?param14]
2018-03-15 10:55:11,698-Statement Id: [DeleteUser] Prepared SQL: [delete from user
where user_id = ?param0]
2018-03-15 10:55:11,698-Adding file [UserModuleHelper.xml] to list of watched
files.
2018-03-15 10:55:11,698-Statement Id: [InsertUserModule] Prepared SQL: [insert into
user_module (role_id, module_id, created_by, created_on) values
( ?param0 , ?param1 , ?param2 , NOW());]
2018-03-15 10:55:11,698-Statement Id: [InsertUserModule.SelectKey] Prepared SQL:
[select last_insert_id() as value]
2018-03-15 10:55:11,698-Statement Id: [DeleteUserModule] Prepared SQL: [delete from
user_module where user_module_id = ?param0]
2018-03-15 10:55:11,698-Statement Id: [DeleteModuleByRole] Prepared SQL: [delete
from user_module where role_id = ?param0]
2018-03-15 10:55:11,698-Adding file [SKUGridHelper.xml] to list of watched files.
2018-03-15 10:55:11,725-Statement Id: [SelectSKUGrid] Prepared SQL: [select
s.sku_name, n.node_name, c.category_id, c.category_name, sku_grid.*, case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (1 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(1 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (1 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (1 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (1 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (1 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (1 * avg_sales)) > 0 and (closing_quantity - (1 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(red_zone,0) /
100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and
buffer_norm > 0) then 'Red' end as 'one', case when (closing_quantity
- (1 * avg_sales)) <= 0 then 0 else (closing_quantity - (1 * avg_sales)) end as
'one_qty', case when ifnull(buffer_norm, 0) = 0 then 'White'
when ((closing_quantity - (2 * avg_sales)) <= 0 and buffer_norm > 0) then 'Black'
when ((closing_quantity - (2 * avg_sales)) > buffer_norm and buffer_norm > 0) then
'Blue' when ((closing_quantity - (2 * avg_sales)) > (CASE WHEN
IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) *
IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END)
and (closing_quantity - (2 * avg_sales)) <= buffer_norm and buffer_norm > 0) then
'Green' when ((closing_quantity - (2 * avg_sales)) > (CASE WHEN
IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(red_zone,0) / 100) *
IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and
(closing_quantity - (2 * avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow'
when ((closing_quantity - (2 * avg_sales)) > 0 and (closing_quantity - (2 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'two', case when (closing_quantity - (2 * avg_sales)) <= 0 then 0 else
(closing_quantity - (2 * avg_sales)) end as 'two_qty', case when
ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (3 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(3 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (3 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (3 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (3 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (3 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (3 * avg_sales)) > 0 and (closing_quantity - (3 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(red_zone,0) /
100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and
buffer_norm > 0) then 'Red' end as 'three', case when
(closing_quantity - (3 * avg_sales)) <= 0 then 0 else (closing_quantity - (3 *
avg_sales)) end as 'three_qty', case when ifnull(buffer_norm, 0) = 0
then 'White' when ((closing_quantity - (4 * avg_sales)) <= 0 and buffer_norm
> 0) then 'Black' when ((closing_quantity - (4 * avg_sales)) > buffer_norm
and buffer_norm > 0) then 'Blue' when ((closing_quantity - (4 * avg_sales))
> (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(yellow_zone,0) /
100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2)
END) and (closing_quantity - (4 * avg_sales)) <= buffer_norm and buffer_norm > 0)
then 'Green' when ((closing_quantity - (4 * avg_sales)) > (CASE WHEN
IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(red_zone,0) / 100) *
IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and
(closing_quantity - (4 * avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow'
when ((closing_quantity - (4 * avg_sales)) > 0 and (closing_quantity - (4 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'four', case when (closing_quantity - (4 * avg_sales)) <= 0 then 0 else
(closing_quantity - (4 * avg_sales)) end as 'four_qty', case when
ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (5 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(5 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (5 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (5 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (5 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (5 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (5 * avg_sales)) > 0 and (closing_quantity - (5 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(red_zone,0) /
100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and
buffer_norm > 0) then 'Red' end as 'five', case when
(closing_quantity - (5 * avg_sales)) <= 0 then 0 else (closing_quantity - (5 *
avg_sales)) end as 'five_qty', case when ifnull(buffer_norm, 0) = 0
then 'White' when ((closing_quantity - (6 * avg_sales)) <= 0 and buffer_norm
> 0) then 'Black' when ((closing_quantity - (6 * avg_sales)) > buffer_norm
and buffer_norm > 0) then 'Blue' when ((closing_quantity - (6 * avg_sales))
> (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(yellow_zone,0) /
100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2)
END) and (closing_quantity - (6 * avg_sales)) <= buffer_norm and buffer_norm > 0)
then 'Green' when ((closing_quantity - (6 * avg_sales)) > (CASE WHEN
IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(red_zone,0) / 100) *
IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and
(closing_quantity - (6 * avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow'
when ((closing_quantity - (6 * avg_sales)) > 0 and (closing_quantity - (6 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'six', case when (closing_quantity - (6 * avg_sales)) <= 0 then 0 else
(closing_quantity - (6 * avg_sales)) end as 'six_qty', case when
ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (7 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(7 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (7 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (7 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (7 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (7 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm
> 0) then 'Yellow' when ((closing_quantity - (7 * avg_sales)) > 0 and
(closing_quantity - (7 * avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'seven', case when (closing_quantity - (7 * avg_sales)) <= 0 then 0 else
(closing_quantity - (7 * avg_sales)) end as 'seven_qty', case when
ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (8 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(8 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (8 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (8 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (8 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (8 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (8 * avg_sales)) > 0 and (closing_quantity - (8 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(red_zone,0) /
100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and
buffer_norm > 0) then 'Red' end as 'eight', case when
(closing_quantity - (8 * avg_sales)) <= 0 then 0 else (closing_quantity - (8 *
avg_sales)) end as 'eight_qty', case when ifnull(buffer_norm, 0) = 0
then 'White' when ((closing_quantity - (9 * avg_sales)) <= 0 and buffer_norm
> 0) then 'Black' when ((closing_quantity - (9 * avg_sales)) > buffer_norm
and buffer_norm > 0) then 'Blue' when ((closing_quantity - (9 * avg_sales))
> (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(yellow_zone,0) /
100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2)
END) and (closing_quantity - (9 * avg_sales)) <= buffer_norm and buffer_norm > 0)
then 'Green' when ((closing_quantity - (9 * avg_sales)) > (CASE WHEN
IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(red_zone,0) / 100) *
IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and
(closing_quantity - (9 * avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow'
when ((closing_quantity - (9 * avg_sales)) > 0 and (closing_quantity - (9 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'nine', case when (closing_quantity - (9 * avg_sales)) <= 0 then 0 else
(closing_quantity - (9 * avg_sales)) end as 'nine_qty', case when
ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (10 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(10 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (10 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (10 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (10 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (10 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (10 * avg_sales)) > 0 and (closing_quantity - (10 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'ten', case when (closing_quantity - (10 * avg_sales)) <= 0 then 0 else
(closing_quantity - (10 * avg_sales)) end as 'ten_qty', case when
ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (11 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(11 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (11 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (11 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (11 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (11 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (11 * avg_sales)) > 0 and (closing_quantity - (11 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'eleven', case when (closing_quantity - (11 * avg_sales)) <= 0 then 0
else (closing_quantity - (11 * avg_sales)) end as 'eleven_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (12 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(12 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (12 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (12 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (12 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (12 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (12 * avg_sales)) > 0 and (closing_quantity - (12 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twelve', case when (closing_quantity - (12 * avg_sales)) <= 0 then 0
else (closing_quantity - (12 * avg_sales)) end as 'twelve_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (13 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(13 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (13 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (13 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (13 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (13 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (13 * avg_sales)) > 0 and (closing_quantity - (13 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'thirteen', case when (closing_quantity - (13 * avg_sales)) <= 0 then 0
else (closing_quantity - (13 * avg_sales)) end as 'thirteen_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (14 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(14 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (14 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (14 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (14 * avg_sales)) > (CASE
WHEN IFNULL(is_default_zone,'Y') = 'N' THEN ROUND(((IFNULL(red_zone,0) / 100) *
IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and
(closing_quantity - (14 * avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow'
when ((closing_quantity - (14 * avg_sales)) > 0 and (closing_quantity - (14 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'fourteen', case when (closing_quantity - (14 * avg_sales)) <= 0 then 0
else (closing_quantity - (14 * avg_sales)) end as 'fourteen_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (15 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(15 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (15 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (15 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (15 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (15 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (15 * avg_sales)) > 0 and (closing_quantity - (15 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'fifteen', case when (closing_quantity - (15 * avg_sales)) <= 0 then 0
else (closing_quantity - (15 * avg_sales)) end as 'fifteen_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (16 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(16 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (16 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (16 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (16 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (16 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (16 * avg_sales)) > 0 and (closing_quantity - (16 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'sixteen', case when (closing_quantity - (16 * avg_sales)) <= 0 then 0
else (closing_quantity - (16 * avg_sales)) end as 'sixteen_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (17 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(17 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (17 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (17 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (17 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (17 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (17 * avg_sales)) > 0 and (closing_quantity - (17 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'seventeen', case when (closing_quantity - (17 * avg_sales)) <= 0 then 0
else (closing_quantity - (17 * avg_sales)) end as 'seventeen_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (18 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(18 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (18 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (18 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (18 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (18 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (18 * avg_sales)) > 0 and (closing_quantity - (18 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'eighteen', case when (closing_quantity - (18 * avg_sales)) <= 0 then 0
else (closing_quantity - (18 * avg_sales)) end as 'eighteen_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (19 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(19 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (19 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (19 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (19 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (19 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (19 * avg_sales)) > 0 and (closing_quantity - (19 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'nineteen', case when (closing_quantity - (19 * avg_sales)) <= 0 then 0
else (closing_quantity - (19 * avg_sales)) end as 'nineteen_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (20 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(20 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (20 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (20 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (20 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (20 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (20 * avg_sales)) > 0 and (closing_quantity - (20 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twenty', case when (closing_quantity - (20 * avg_sales)) <= 0 then 0
else (closing_quantity - (20 * avg_sales)) end as 'twenty_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (21 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity
- (21 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (21 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (21 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (21 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (21 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (21 * avg_sales)) > 0 and (closing_quantity - (21 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twentyone', case when (closing_quantity - (21 * avg_sales)) <= 0 then 0
else (closing_quantity - (21 * avg_sales)) end as 'twentyone_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (22 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(22 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (22 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (22 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (22 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (22 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (22 * avg_sales)) > 0 and (closing_quantity - (22 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twentytwo', case when (closing_quantity - (22 * avg_sales)) <= 0 then 0
else (closing_quantity - (22 * avg_sales)) end as 'twentytwo_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (23 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(23 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (23 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (23 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (23 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (23 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (23 * avg_sales)) > 0 and (closing_quantity - (23 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twentythree', case when (closing_quantity - (23 * avg_sales)) <= 0 then
0 else (closing_quantity - (23 * avg_sales)) end as 'twentythree_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (24 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(24 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (24 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (24 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (24 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (24 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (24 * avg_sales)) > 0 and (closing_quantity - (24 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twentyfour', case when (closing_quantity - (24 * avg_sales)) <= 0 then 0
else (closing_quantity - (24 * avg_sales)) end as 'twentyfour_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (25 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(25 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (25 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (25 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (25 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (25 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (25 * avg_sales)) > 0 and (closing_quantity - (25 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twentyfive', case when (closing_quantity - (25 * avg_sales)) <= 0 then 0
else (closing_quantity - (25 * avg_sales)) end as 'twentyfive_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (26 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(26 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (26 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (26 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (26 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (26 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (26 * avg_sales)) > 0 and (closing_quantity - (26 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twentysix', case when (closing_quantity - (26 * avg_sales)) <= 0 then 0
else (closing_quantity - (26 * avg_sales)) end as 'twentysix_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (27 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(27 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (27 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (27 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (27 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (27 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (27 * avg_sales)) > 0 and (closing_quantity - (27 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0)
/ 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(IFNULL(buffer_norm, 0) / 3,2) END)
and buffer_norm > 0) then 'Red' end as 'twentyseven', case when
(closing_quantity - (27 * avg_sales)) <= 0 then 0 else (closing_quantity - (27 *
avg_sales)) end as 'twentyseven_qty', case when ifnull(buffer_norm,
0) = 0 then 'White' when ((closing_quantity - (28 * avg_sales)) <= 0 and
buffer_norm > 0) then 'Black' when ((closing_quantity - (28 * avg_sales)) >
buffer_norm and buffer_norm > 0) then 'Blue' when ((closing_quantity - (28 *
avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (28 * avg_sales)) <=
buffer_norm and buffer_norm > 0) then 'Green' when ((closing_quantity - (28
* avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (28 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (28 * avg_sales)) > 0 and (closing_quantity - (28 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twentyeight', case when (closing_quantity - (28 * avg_sales)) <= 0 then
0 else (closing_quantity - (28 * avg_sales)) end as 'twentyeight_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (29 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(29 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (29 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (29 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (29 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (29 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (29 * avg_sales)) > 0 and (closing_quantity - (29 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'twentynine', case when (closing_quantity - (29 * avg_sales)) <= 0 then 0
else (closing_quantity - (29 * avg_sales)) end as 'twentynine_qty', case
when ifnull(buffer_norm, 0) = 0 then 'White' when ((closing_quantity - (30 *
avg_sales)) <= 0 and buffer_norm > 0) then 'Black' when ((closing_quantity -
(30 * avg_sales)) > buffer_norm and buffer_norm > 0) then 'Blue' when
((closing_quantity - (30 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(((2 / 3) * IFNULL(buffer_norm, 0)),2) END) and (closing_quantity - (30 *
avg_sales)) <= buffer_norm and buffer_norm > 0) then 'Green' when
((closing_quantity - (30 * avg_sales)) > (CASE WHEN IFNULL(is_default_zone,'Y') =
'N' THEN ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and (closing_quantity - (30 * avg_sales))
<= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(yellow_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE ROUND(((2 /
3) * IFNULL(buffer_norm, 0)),2) END) and buffer_norm > 0) then 'Yellow' when
((closing_quantity - (30 * avg_sales)) > 0 and (closing_quantity - (30 *
avg_sales)) <= (CASE WHEN IFNULL(is_default_zone,'Y') = 'N' THEN
ROUND(((IFNULL(red_zone,0) / 100) * IFNULL(buffer_norm, 0)),2) ELSE
ROUND(IFNULL(buffer_norm, 0) / 3,2) END) and buffer_norm > 0) then 'Red' end
as 'thirty', case when (closing_quantity - (30 * avg_sales)) <= 0 then 0
else (closing_quantity - (30 * avg_sales)) end as 'thirty_qty' from (
select tr.sku_id, tr.node_id, round(sum(tr.sales) / 15, 2) as avg_sales,
t.closing_quantity, ifnull(bn.buffer_norm, (select buffer_norm from
buffer_norm use index(inx_sku_node_efdt) where effective_from < tr.transaction_date
and sku_id = tr.sku_id and node_id = tr.node_id order by effective_from desc limit
1)) as buffer_norm, ifnull(bn.is_default_zone,'Y') as is_default_zone,
ifnull(bn.yellow_zone,0) as yellow_zone, ifnull(bn.red_zone,0) as red_zone,
case when (t.closing_quantity + t.in_transit - t.pending_orders) <= 0 then 0
else (t.closing_quantity + t.in_transit - t.pending_orders) end as
'final_quantity' from transaction tr inner join transaction t
on t.transaction_date = ?param0 and t.sku_id = tr.sku_id and
t.node_id = tr.node_id left join buffer_norm bn use
index(inx_sku_node_efdt) on bn.sku_id = tr.sku_id and bn.node_id =
tr.node_id and bn.effective_from = ?param0 where tr.sku_id = ?
param1 and tr.node_id = ?param2 and tr.transaction_date > ?param3 group
by tr.sku_id, tr.node_id ) as sku_grid inner join sku s on
s.sku_id = sku_grid.sku_id inner join node n on n.node_id =
sku_grid.node_id inner join sku_category sc on sc.sku_category_id =
(select sku_category_id from sku_category where sku_id = sku_grid.sku_id limit 1)
inner join category c on c.category_id = sc.category_id]
2018-03-15 10:55:11,730-Adding file [ExcessInventoryHelper.xml] to list of watched
files.
2018-03-15 10:55:11,731-Adding file [StockoutAvailabilityChartHelper.xml] to list
of watched files.
2018-03-15 10:55:11,733-Adding file [InventoryTurnsHelper.xml] to list of watched
files.
2018-03-15 10:55:11,733-Statement Id: [SelectInventoryTurns] Prepared SQL: [select
rpl.transaction_date, rpl.category_id, rpl.category_name,
date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date, sum(1) as
count, sum(rpl.closing_quantity) as closing_quantity, sum(rpl.sales) as sales
from replenishment rpl where rpl.category_id is not null and
rpl.transaction_date = ?param0 group by rpl.transaction_date,
rpl.category_id]
2018-03-15 10:55:11,733-Statement Id: [SelectInventoryTurnsSKU] Prepared SQL:
[select rpl.transaction_date, rpl.category_id, rpl.sku_id, rpl.category_name,
date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date, sum(1) as
count, sum(rpl.closing_quantity) as closing_quantity, sum(rpl.sales) as sales
from replenishment rpl where rpl.category_id is not null and
rpl.transaction_date = ?param0 group by rpl.transaction_date,
rpl.category_id, rpl.sku_id]
2018-03-15 10:55:11,734-Adding file [CntQtyFillRateChartHelper.xml] to list of
watched files.
2018-03-15 10:55:11,734-Statement Id: [SelectCntQtyFillRateChart] Prepared SQL:
[select rpl.transaction_date, rpl.closing_stock_zone,
group_concat(distinct(rpl.sku_id) SEPARATOR ',') as str_sku_ids,
date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date,
sum(rpl.closing_quantity) as closing_quantity, sum(rpl.buffer_norm) as buffer_norm
from replenishment rpl where rpl.closing_stock_zone != "White" and
rpl.transaction_date = ?param0 group by rpl.transaction_date,
rpl.closing_stock_zone]
2018-03-15 10:55:11,734-Statement Id: [SelectCntQtyFillRateChartNode] Prepared SQL:
[select rpl.transaction_date, rpl.closing_stock_zone, rpl.node_id,
group_concat(distinct(rpl.sku_id) SEPARATOR ',') as str_sku_ids,
date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date,
sum(rpl.closing_quantity) as closing_quantity, sum(rpl.buffer_norm) as buffer_norm
from replenishment rpl where rpl.closing_stock_zone != "White" and
rpl.transaction_date = ?param0 group by rpl.transaction_date,
rpl.closing_stock_zone, rpl.node_id]
2018-03-15 10:55:11,734-Statement Id: [SelectCntQtyFillRateChartCategory] Prepared
SQL: [select rpl.transaction_date, rpl.closing_stock_zone, rpl.category_id,
group_concat(distinct(rpl.sku_id) SEPARATOR ',') as str_sku_ids,
date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date,
sum(rpl.closing_quantity) as closing_quantity, sum(rpl.buffer_norm) as buffer_norm
from replenishment rpl where rpl.closing_stock_zone != "White" and
rpl.transaction_date = ?param0 group by rpl.transaction_date,
rpl.closing_stock_zone, rpl.category_id]
2018-03-15 10:55:11,735-Statement Id: [SelectCntQtyFillRateChartSKU] Prepared SQL:
[select rpl.transaction_date, rpl.closing_stock_zone, rpl.sku_id,
group_concat(distinct(rpl.sku_id) SEPARATOR ',') as str_sku_ids,
date_format(rpl.transaction_date,'%d/%m/%Y') as display_date,
date_format(rpl.transaction_date,'%Y%m%d') as transfilter_date,
sum(rpl.closing_quantity) as closing_quantity, sum(rpl.buffer_norm) as buffer_norm
from replenishment rpl where rpl.closing_stock_zone != "White" and
rpl.transaction_date = ?param0 group by rpl.transaction_date,
rpl.closing_stock_zone, rpl.sku_id]
2018-03-15 10:55:11,735-Adding file [UserDataPermissionHelper.xml] to list of
watched files.
2018-03-15 10:55:11,736-Statement Id: [SelectDataPermissionByRole] Prepared SQL:
[select user_data_id, role_id, object_type, object_id, chk_state, created_by,
created_on from user_data_permissions WHERE role_id = ?param0 AND
object_type = ?param1]
2018-03-15 10:55:11,736-Statement Id: [InsertUserDataPermission] Prepared SQL:
[insert into user_data_permissions (role_id, object_type, object_id,
chk_state, created_by, created_on) values ( ?param0 , ?param1 , ?
param2 , ?param3 , ?param4 , NOW());]
2018-03-15 10:55:11,736-Statement Id: [InsertUserDataPermission.SelectKey] Prepared
SQL: [select last_insert_id() as value]
2018-03-15 10:55:11,736-Statement Id: [DeleteDataPermissionByRole] Prepared SQL:
[delete from user_data_permissions where role_id = ?param0]
2018-03-15 10:55:11,736-Adding file [RoleHelper.xml] to list of watched files.
2018-03-15 10:55:11,736-Statement Id: [SelectRoleNameDuplicate] Prepared SQL:
[select role_id,role_name,status,created_by,created_on,modified_by,modified_on
from role where role_name = ?param0 and role_id != ?param1]
2018-03-15 10:55:11,736-Statement Id: [InsertRole] Prepared SQL: [insert into role
(role_name,status,created_by,created_on) values ( ?param0 , ?
param1 , ?param2 , NOW());]
2018-03-15 10:55:11,736-Statement Id: [InsertRole.SelectKey] Prepared SQL: [select
last_insert_id() as value]
2018-03-15 10:55:11,737-Statement Id: [UpdateRole] Prepared SQL: [update role set
role_name = ?param0 , status = ?param1 , modified_by = ?param2 ,
modified_on = NOW() where role_id = ?param3]
2018-03-15 10:55:11,737-Adding file [BOMHelper.xml] to list of watched files.
2018-03-15 10:55:11,737-Statement Id: [SelectBOMDictionary] Prepared SQL: [SELECT
DISTINCT sk.sku_code, bm.sku_id FROM sku sk INNER JOIN bom bm ON bm.sku_id =
sk.sku_id]
2018-03-15 10:55:11,738-Adding file [Matrix1Helper.xml] to list of watched files.
2018-03-15 10:55:11,742-Statement Id: [SelectUserCheckAuthenticate]
PreparedStatement : [select user_id, user_name, first_name, middle_name,
last_name, email, mobile, description, password, status, approved, locked,
role_id, region_id, created_by, created_on, modified_by, modified_on from
user where user_name = ?param0 and password = ?param1 and status = 1]
2018-03-15 10:55:11,742-Statement Id: [SelectUserCheckAuthenticate] Parameters: [?
param0=[user_name,Admin], ?param1=[password,Ennovate789]]
2018-03-15 10:55:11,742-Statement Id: [SelectUserCheckAuthenticate] Types: [?
param0=[String, System.String], ?param1=[String, System.String]]
2018-03-15 10:55:11,746-Open Connection "14376342" to "MySQL, MySQL provider ver
6:5:4:0".
2018-03-15 10:55:11,748-Close Connection "14376342" to "MySQL, MySQL provider ver
6:5:4:0".

You might also like