Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DELIMITER $$
- CREATE DEFINER=`root`@`%` PROCEDURE `product_validate_input`(IN jss json)
- proc_label:begin
- declare eat_code nvarchar(100) COLLATE utf8_unicode_ci;
- declare template_exists int;
- declare final_json mediumtext CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
- declare js_product_name mediumtext CHARACTER SET utf8 COLLATE utf8_unicode_ci default '';
- declare js_trade_name mediumtext CHARACTER SET utf8 COLLATE utf8_unicode_ci default '';
- declare js_manifacturer_country mediumtext CHARACTER SET utf8 COLLATE utf8_unicode_ci default '';
- declare js_manufacturer_name mediumtext CHARACTER SET utf8 COLLATE utf8_unicode_ci default '';
- declare js_brand_name_product_offer mediumtext CHARACTER SET utf8 COLLATE utf8_unicode_ci default '';
- declare js_Offer_number_TRU_supplier mediumtext CHARACTER SET utf8 COLLATE utf8_unicode_ci default '';
- declare js_extra_features_name0 mediumtext CHARACTER SET utf8 COLLATE utf8_unicode_ci default '';
- declare js_extra_features_qualityValueSet0 mediumtext CHARACTER SET utf8 COLLATE utf8_unicode_ci default '';
- declare js_extra_features_name1 mediumtext CHARACTER SET utf8 COLLATE utf8_unicode_ci default '';
- declare js_extra_features_qualityValueSet1 mediumtext CHARACTER SET utf8 COLLATE utf8_unicode_ci default '';
- declare js_delivery_places mediumtext CHARACTER SET utf8 COLLATE utf8_unicode_ci default '';
- declare js_documents_name mediumtext CHARACTER SET utf8 COLLATE utf8_unicode_ci default '';
- declare js_documents_department mediumtext CHARACTER SET utf8 COLLATE utf8_unicode_ci default '';
- declare js_documents_number mediumtext CHARACTER SET utf8 COLLATE utf8_unicode_ci default '';
- declare js_documents_filename mediumtext CHARACTER SET utf8 COLLATE utf8_unicode_ci default '';
- declare js_documents_range mediumtext CHARACTER SET utf8 COLLATE utf8_unicode_ci default '';
- declare js_documents_dop_name mediumtext CHARACTER SET utf8 COLLATE utf8_unicode_ci default '';
- declare js_documents_dop_filename mediumtext CHARACTER SET utf8 COLLATE utf8_unicode_ci default '';
- declare violations mediumtext CHARACTER SET utf8 COLLATE utf8_unicode_ci;
- SET @enabled = true;
- #set final_json = '';
- #call debug_msg(@enabled, (select concat('json is:', js)) );
- #if (js = '') then
- #select 'Пустая строка';
- #LEAVE proc_label;
- #end if;
- DROP TEMPORARY TABLE IF EXISTS jsonDat;
- CREATE TEMPORARY TABLE jsonDat
- AS (
- SELECT
- CAST(json_unquote(json_extract(jss, '$."Product_name"."<all_channels>"."<all_locales>"')) as char(300) CHARSET utf8) collate utf8_unicode_ci as product_name,
- CAST(json_unquote(json_extract(jss, '$."trade_name"."<all_channels>"."<all_locales>"')) as char(300) CHARSET utf8) collate utf8_unicode_ci as trade_name,
- CAST(json_unquote(json_extract(jss, '$."manufacturer_country"."<all_channels>"."<all_locales>"')) as char(300) CHARSET utf8) collate utf8_unicode_ci as manifacturer_country,
- CAST(json_unquote(json_extract(jss, '$."manufacturer_name"."<all_channels>"."<all_locales>"')) as char(300) CHARSET utf8) collate utf8_unicode_ci as manufacturer_name,
- CAST(json_unquote(json_extract(jss, '$."brand_name_product_offer"."<all_channels>"."<all_locales>"')) as char(300) CHARSET utf8) collate utf8_unicode_ci as brand_name_product_offer,
- CAST(json_unquote(json_extract(jss, '$."Offer_number_TRU_supplier"."<all_channels>"."<all_locales>"')) as char(300) CHARSET utf8) collate utf8_unicode_ci as Offer_number_TRU_supplier,
- CAST(json_unquote(json_extract(json_unquote(json_extract(jss, '$."extra_features"."<all_channels>"."<all_locales>"')),'$[0]."name"')) as char(300) CHARSET utf8) collate utf8_unicode_ci as extra_features_name0,
- CAST(json_unquote(json_extract(json_unquote(json_extract(jss, '$."extra_features"."<all_channels>"."<all_locales>"')),'$[0]."qualityValueSet"')) as char(300) CHARSET utf8) collate utf8_unicode_ci as extra_features_qualityValueSet0,
- CAST(json_unquote(json_extract(json_unquote(json_extract(jss, '$."extra_features"."<all_channels>"."<all_locales>"')),'$[1]."name"')) as char(300) CHARSET utf8) collate utf8_unicode_ci as extra_features_name1,
- CAST(json_unquote(json_extract(json_unquote(json_extract(jss, '$."extra_features"."<all_channels>"."<all_locales>"')),'$[1]."qualityValueSet"')) as char(300) CHARSET utf8) collate utf8_unicode_ci as extra_features_qualityValueSet1,
- json_unquote(json_extract(jss, '$."delivery_places"."<all_channels>"."<all_locales>"')) as delivery_places,
- CAST(json_unquote(json_extract(json_unquote(json_extract(json_unquote(json_extract(jss, '$."documents"."<all_channels>"."<all_locales>"')),'$[0]')),'$[0]."name"')) as char(300) CHARSET utf8) collate utf8_unicode_ci as documents_name,
- CAST(json_unquote(json_extract(json_unquote(json_extract(json_unquote(json_extract(jss, '$."documents"."<all_channels>"."<all_locales>"')),'$[0]')),'$[0]."department"')) as char(300) CHARSET utf8) collate utf8_unicode_ci as documents_department,
- CAST(json_unquote(json_extract(json_unquote(json_extract(json_unquote(json_extract(jss, '$."documents"."<all_channels>"."<all_locales>"')),'$[0]')),'$[0]."number"')) as char(300) CHARSET utf8) collate utf8_unicode_ci as documents_number,
- CAST(json_unquote(json_extract(json_unquote(json_extract(json_unquote(json_extract(json_unquote(json_extract(jss, '$."documents"."<all_channels>"."<all_locales>"')),'$[0]')),'$[0]."fileRef"')),'$."fileName"')) as char(300) CHARSET utf8) collate utf8_unicode_ci as documents_filename,
- CAST(json_unquote(json_extract(json_unquote(json_extract(json_unquote(json_extract(jss, '$."documents"."<all_channels>"."<all_locales>"')),'$[0]')),'$[0]."range"')) as char(300) CHARSET utf8) collate utf8_unicode_ci as documents_range,
- CAST(json_unquote(json_extract(json_unquote(json_extract(json_unquote(json_extract(jss, '$."documents_dop"."<all_channels>"."<all_locales>"')),'$[0]')),'$[0]."name"')) as char(300) CHARSET utf8) collate utf8_unicode_ci as documents_dop_name,
- CAST(json_unquote(json_extract(json_unquote(json_extract(json_unquote(json_extract(json_unquote(json_extract(jss, '$."documents_dop"."<all_channels>"."<all_locales>"')),'$[0]')),'$[0]."fileRef"')),'$."fileName"')) as char(300) CHARSET utf8) collate utf8_unicode_ci as documents_dop_filename
- );
- set final_json = '';
- #реализовать проверку на наличие товара с кодом классификатора
- #выход из процедуры, если грузим шаблон
- if ( select json_unquote(json_extract(jss, '$."is_ticker"."<all_channels>"."<all_locales>"' )) = 'true')
- then
- set final_json = '[{"code": "is-template"}]';
- select final_json;
- leave proc_label;
- end if;
- set eat_code = ( select IFNULL(json_unquote(json_extract(jss, '$."code"."<all_channels>"."<all_locales>"')), '' ) );
- select count(*) into template_exists from pim_catalog_product
- where json_unquote(json_extract(raw_values, '$."code"."<all_channels>"."<all_locales>"')) = eat_code
- and json_unquote(json_extract(raw_values, '$."is_ticker"."<all_channels>"."<all_locales>"')) = 'true';
- if ( eat_code = '' )
- then
- set final_json = CONCAT( IF ( final_json = '', '', CONCAT(final_json,',') ), '{"code": "code-empty"}');
- elseif (template_exists = 0)
- then
- set final_json = CONCAT( IF ( final_json = '', '', CONCAT(final_json,',') ), '{"code": "not-in-classifier"}');
- end if;
- #проверка на цену > 0
- if ( (select IFNULL(json_unquote(json_extract(jss, '$."price"."<all_channels>"."<all_locales>"')), 0) <= 0) OR (select json_unquote(json_extract(jss, '$."price"."<all_channels>"."<all_locales>"')) = ''))
- then
- set final_json = CONCAT( IF ( final_json = '', '', CONCAT(final_json,',') ), '{"code": "price-empty"}');
- end if;
- #будем проверять все колонки на вхождение в стоп-лист словарь и сразу результат запихивать в свою переменную
- select group_concat(js separator ',') into js_product_name from
- (select
- CONCAT( '{"code":"stop-word",
- "stopWord": { "id": ',k.id,',
- "text": "',k.name,'"},
- "attribute": {"id" : "-5",
- "code":"product_name",
- "label":"Полное наименование"}
- }' ) as js
- from (select lower(product_name) as w from jsonDat) as t
- inner join kt_stop_word as k
- on (t.w = lower_name or instr(t.w, BINARY k.lower_name) > 0 ) AND
- t.w NOT REGEXP CONCAT('[[:alpha:]](',k.lower_name,')$|^(',k.lower_name,')[[:alpha:]]|[[:alpha:]](',k.lower_name,')[[:alpha:]]|[[:alpha:]](',k.lower_name,')[^[:alpha:]]|[^[:alpha:]](',k.lower_name,')[[:alpha:]]')
- where k.isActive = 1 ) as g;
- #call debug_msg(@enabled, (select concat(js_product_name, ' AFTER INSERT') from jsonDat) );
- select group_concat(js separator ',') into js_trade_name from
- (select
- CONCAT( '{"code":"stop-word",
- "stopWord": { "id": ',k.id,',
- "text": "',k.name,'"},
- "attribute": {"id" : "-5",
- "code":"trade_name",
- "label":"Торговое наименование"}
- }' ) as js
- from (select lower(trade_name) as w from jsonDat) as t
- inner join kt_stop_word as k
- on (t.w = lower_name or instr(t.w, BINARY k.lower_name) > 0 ) AND
- t.w NOT REGEXP CONCAT('[[:alpha:]](',k.lower_name,')$|^(',k.lower_name,')[[:alpha:]]|[[:alpha:]](',k.lower_name,')[[:alpha:]]|[[:alpha:]](',k.lower_name,')[^[:alpha:]]|[^[:alpha:]](',k.lower_name,')[[:alpha:]]')
- where k.isActive = 1 ) as g;
- select group_concat(js separator ',') into js_manifacturer_country from
- (select
- CONCAT( '{"code":"stop-word",
- "stopWord": { "id": ',k.id,',
- "text": "',k.name,'"},
- "attribute": {"id" : "-5",
- "code":"manifacturer_country",
- "label":"Наименование места происхождения товара"}
- }' ) as js
- from (select lower(manifacturer_country) as w from jsonDat) as t
- inner join kt_stop_word as k
- on (t.w = lower_name or instr(t.w, BINARY k.lower_name) > 0 ) AND
- t.w NOT REGEXP CONCAT('[[:alpha:]](',k.lower_name,')$|^(',k.lower_name,')[[:alpha:]]|[[:alpha:]](',k.lower_name,')[[:alpha:]]|[[:alpha:]](',k.lower_name,')[^[:alpha:]]|[^[:alpha:]](',k.lower_name,')[[:alpha:]]')
- where k.isActive = 1 ) as g;
- select group_concat(js separator ',') into js_manufacturer_name from
- (select
- CONCAT( '{"code":"stop-word",
- "stopWord": { "id": ',k.id,',
- "text": "',k.name,'"},
- "attribute": {"id" : "-5",
- "code":"manufacturer_name",
- "label":"Информация о производителе товара"}
- }' ) as js
- from (select lower(manufacturer_name) as w from jsonDat) as t
- inner join kt_stop_word as k
- on (t.w = lower_name or instr(t.w, BINARY k.lower_name) > 0 ) AND
- t.w NOT REGEXP CONCAT('[[:alpha:]](',k.lower_name,')$|^(',k.lower_name,')[[:alpha:]]|[[:alpha:]](',k.lower_name,')[[:alpha:]]|[[:alpha:]](',k.lower_name,')[^[:alpha:]]|[^[:alpha:]](',k.lower_name,')[[:alpha:]]')
- where k.isActive = 1 ) as g;
- select group_concat(js separator ',') into js_brand_name_product_offer from
- (select
- CONCAT( '{"code":"stop-word",
- "stopWord": { "id": ',k.id,',
- "text": "',k.name,'"},
- "attribute": {"id" : "-5",
- "code":"brand_name_product_offer",
- "label":"Фирменное наименование"}
- }' ) as js
- from (select lower(brand_name_product_offer) as w from jsonDat) as t
- inner join kt_stop_word as k
- on (t.w = lower_name or instr(t.w, BINARY k.lower_name) > 0 ) AND
- t.w NOT REGEXP CONCAT('[[:alpha:]](',k.lower_name,')$|^(',k.lower_name,')[[:alpha:]]|[[:alpha:]](',k.lower_name,')[[:alpha:]]|[[:alpha:]](',k.lower_name,')[^[:alpha:]]|[^[:alpha:]](',k.lower_name,')[[:alpha:]]')
- where k.isActive = 1 ) as g;
- select group_concat(js separator ',') into js_Offer_number_TRU_supplier from
- (select
- CONCAT( '{"code":"stop-word",
- "stopWord": { "id": ',k.id,',
- "text": "',k.name,'"},
- "attribute": {"id" : "-5",
- "code":"Offer_number_TRU_supplier",
- "label":"Номер Предложения ТРУ (Поставщика)"}
- }' ) as js
- from (select lower(Offer_number_TRU_supplier) as w from jsonDat) as t
- inner join kt_stop_word as k
- on (t.w = lower_name or instr(t.w, BINARY k.lower_name) > 0 ) AND
- t.w NOT REGEXP CONCAT('[[:alpha:]](',k.lower_name,')$|^(',k.lower_name,')[[:alpha:]]|[[:alpha:]](',k.lower_name,')[[:alpha:]]|[[:alpha:]](',k.lower_name,')[^[:alpha:]]|[^[:alpha:]](',k.lower_name,')[[:alpha:]]')
- where k.isActive = 1 ) as g;
- select group_concat(js separator ',') into js_extra_features_name0 from
- (select
- CONCAT( '{"code":"stop-word",
- "stopWord": { "id": ',k.id,',
- "text": "',k.name,'"},
- "attribute": {"id" : "-5",
- "code":"extra_features_name_block_1",
- "label":"Наименование характеристики"}
- }' ) as js
- from (select lower(extra_features_name0) as w from jsonDat) as t
- inner join kt_stop_word as k
- on (t.w = lower_name or instr(t.w, BINARY k.lower_name) > 0 ) AND
- t.w NOT REGEXP CONCAT('[[:alpha:]](',k.lower_name,')$|^(',k.lower_name,')[[:alpha:]]|[[:alpha:]](',k.lower_name,')[[:alpha:]]|[[:alpha:]](',k.lower_name,')[^[:alpha:]]|[^[:alpha:]](',k.lower_name,')[[:alpha:]]')
- where k.isActive = 1 ) as g;
- select group_concat(js separator ',') into js_extra_features_qualityValueSet0 from
- (select
- CONCAT( '{"code":"stop-word",
- "stopWord": { "id": ',k.id,',
- "text": "',k.name,'"},
- "attribute": {"id" : "-5",
- "code":"extra_features_qualityValueSet_block_1",
- "label":"Значение характеристики"}
- }' ) as js
- from (select lower(extra_features_qualityValueSet0) as w from jsonDat) as t
- inner join kt_stop_word as k
- on (t.w = lower_name or instr(t.w, BINARY k.lower_name) > 0 ) AND
- t.w NOT REGEXP CONCAT('[[:alpha:]](',k.lower_name,')$|^(',k.lower_name,')[[:alpha:]]|[[:alpha:]](',k.lower_name,')[[:alpha:]]|[[:alpha:]](',k.lower_name,')[^[:alpha:]]|[^[:alpha:]](',k.lower_name,')[[:alpha:]]')
- where k.isActive = 1 ) as g;
- select group_concat(js separator ',') into js_extra_features_name1 from
- (select
- CONCAT( '{"code":"stop-word",
- "stopWord": { "id": ',k.id,',
- "text": "',k.name,'"},
- "attribute": {"id" : "-5",
- "code":"extra_features_name_block_2",
- "label":"Наименование характеристики"}
- }' ) as js
- from (select lower(extra_features_name1) as w from jsonDat) as t
- inner join kt_stop_word as k
- on (t.w = lower_name or instr(t.w, BINARY k.lower_name) > 0 ) AND
- t.w NOT REGEXP CONCAT('[[:alpha:]](',k.lower_name,')$|^(',k.lower_name,')[[:alpha:]]|[[:alpha:]](',k.lower_name,')[[:alpha:]]|[[:alpha:]](',k.lower_name,')[^[:alpha:]]|[^[:alpha:]](',k.lower_name,')[[:alpha:]]')
- where k.isActive = 1 ) as g;
- select group_concat(js separator ',') into js_extra_features_qualityValueSet1 from
- (select
- CONCAT( '{"code":"stop-word",
- "stopWord": { "id": ',k.id,',
- "text": "',k.name,'"},
- "attribute": {"id" : "-5",
- "code":"extra_features_qualityValueSet_block_2",
- "label":"Значение характеристики"}
- }' ) as js
- from (select lower(extra_features_qualityValueSet1) as w from jsonDat) as t
- inner join kt_stop_word as k
- on (t.w = lower_name or instr(t.w, BINARY k.lower_name) > 0 ) AND
- t.w NOT REGEXP CONCAT('[[:alpha:]](',k.lower_name,')$|^(',k.lower_name,')[[:alpha:]]|[[:alpha:]](',k.lower_name,')[[:alpha:]]|[[:alpha:]](',k.lower_name,')[^[:alpha:]]|[^[:alpha:]](',k.lower_name,')[[:alpha:]]')
- where k.isActive = 1 ) as g;
- select group_concat(js separator ',') into js_delivery_places from
- (select
- CONCAT( '{"code":"stop-word",
- "stopWord": { "id": ',k.id,',
- "text": "',k.name,'"},
- "attribute": {"id" : "-5",
- "code":"delivery_places",
- "label":"Значение характеристики"}
- }' ) as js
- from (select lower(delivery_places) as w from jsonDat) as t
- inner join kt_stop_word as k
- on (t.w = lower_name or instr(t.w, BINARY k.lower_name) > 0 ) AND
- t.w NOT REGEXP CONCAT('[[:alpha:]](',k.lower_name,')$|^(',k.lower_name,')[[:alpha:]]|[[:alpha:]](',k.lower_name,')[[:alpha:]]|[[:alpha:]](',k.lower_name,')[^[:alpha:]]|[^[:alpha:]](',k.lower_name,')[[:alpha:]]')
- where k.isActive = 1 ) as g;
- select group_concat(js separator ',') into js_documents_name from
- (select
- CONCAT( '{"code":"stop-word",
- "stopWord": { "id": ',k.id,',
- "text": "',k.name,'"},
- "attribute": {"id" : "-5",
- "code":"documents_name",
- "label":"Наименование документа"}
- }' ) as js
- from (select lower(documents_name) as w from jsonDat) as t
- inner join kt_stop_word as k
- on (t.w = lower_name or instr(t.w, BINARY k.lower_name) > 0 ) AND
- t.w NOT REGEXP CONCAT('[[:alpha:]](',k.lower_name,')$|^(',k.lower_name,')[[:alpha:]]|[[:alpha:]](',k.lower_name,')[[:alpha:]]|[[:alpha:]](',k.lower_name,')[^[:alpha:]]|[^[:alpha:]](',k.lower_name,')[[:alpha:]]')
- where k.isActive = 1 ) as g;
- select group_concat(js separator ',') into js_documents_department from
- (select
- CONCAT( '{"code":"stop-word",
- "stopWord": { "id": ',k.id,',
- "text": "',k.name,'"},
- "attribute": {"id" : "-5",
- "code":"documents_department",
- "label":"Наименование органа, выдавшего документ"}
- }' ) as js
- from (select lower(documents_department) as w from jsonDat) as t
- inner join kt_stop_word as k
- on (t.w = lower_name or instr(t.w, BINARY k.lower_name) > 0 ) AND
- t.w NOT REGEXP CONCAT('[[:alpha:]](',k.lower_name,')$|^(',k.lower_name,')[[:alpha:]]|[[:alpha:]](',k.lower_name,')[[:alpha:]]|[[:alpha:]](',k.lower_name,')[^[:alpha:]]|[^[:alpha:]](',k.lower_name,')[[:alpha:]]')
- where k.isActive = 1 ) as g;
- select group_concat(js separator ',') into js_documents_number from
- (select
- CONCAT( '{"code":"stop-word",
- "stopWord": { "id": ',k.id,',
- "text": "',k.name,'"},
- "attribute": {"id" : "-5",
- "code":"documents_number",
- "label":"Номер документа"}
- }' ) as js
- from (select lower(documents_number) as w from jsonDat) as t
- inner join kt_stop_word as k
- on (t.w = lower_name or instr(t.w, BINARY k.lower_name) > 0 ) AND
- t.w NOT REGEXP CONCAT('[[:alpha:]](',k.lower_name,')$|^(',k.lower_name,')[[:alpha:]]|[[:alpha:]](',k.lower_name,')[[:alpha:]]|[[:alpha:]](',k.lower_name,')[^[:alpha:]]|[^[:alpha:]](',k.lower_name,')[[:alpha:]]')
- where k.isActive = 1 ) as g;
- select group_concat(js separator ',') into js_documents_filename from
- (select
- CONCAT( '{"code":"stop-word",
- "stopWord": { "id": ',k.id,',
- "text": "',k.name,'"},
- "attribute": {"id" : "-5",
- "code":"documents_filename",
- "label":"Файл (название файла)"}
- }' ) as js
- from (select lower(documents_filename) as w from jsonDat) as t
- inner join kt_stop_word as k
- on (t.w = lower_name or instr(t.w, BINARY k.lower_name) > 0 ) AND
- t.w NOT REGEXP CONCAT('[[:alpha:]](',k.lower_name,')$|^(',k.lower_name,')[[:alpha:]]|[[:alpha:]](',k.lower_name,')[[:alpha:]]|[[:alpha:]](',k.lower_name,')[^[:alpha:]]|[^[:alpha:]](',k.lower_name,')[[:alpha:]]')
- where k.isActive = 1 ) as g;
- select group_concat(js separator ',') into js_documents_range from
- (select
- CONCAT( '{"code":"stop-word",
- "stopWord": { "id": ',k.id,',
- "text": "',k.name,'"},
- "attribute": {"id" : "-5",
- "code":"documents_range",
- "label":"Срок действия документа"}
- }' ) as js
- from (select lower(documents_range) as w from jsonDat) as t
- inner join kt_stop_word as k
- on (t.w = lower_name or instr(t.w, BINARY k.lower_name) > 0 ) AND
- t.w NOT REGEXP CONCAT('[[:alpha:]](',k.lower_name,')$|^(',k.lower_name,')[[:alpha:]]|[[:alpha:]](',k.lower_name,')[[:alpha:]]|[[:alpha:]](',k.lower_name,')[^[:alpha:]]|[^[:alpha:]](',k.lower_name,')[[:alpha:]]')
- where k.isActive = 1 ) as g;
- select group_concat(js separator ',') into js_documents_dop_name from
- (select
- CONCAT( '{"code":"stop-word",
- "stopWord": { "id": ',k.id,',
- "text": "',k.name,'"},
- "attribute": {"id" : "-5",
- "code":"documents_dop_name",
- "label":"Наименование документа (атрибуты)"}
- }' ) as js
- from (select lower(documents_dop_name) as w from jsonDat) as t
- inner join kt_stop_word as k
- on (t.w = lower_name or instr(t.w, BINARY k.lower_name) > 0 ) AND
- t.w NOT REGEXP CONCAT('[[:alpha:]](',k.lower_name,')$|^(',k.lower_name,')[[:alpha:]]|[[:alpha:]](',k.lower_name,')[[:alpha:]]|[[:alpha:]](',k.lower_name,')[^[:alpha:]]|[^[:alpha:]](',k.lower_name,')[[:alpha:]]')
- where k.isActive = 1 ) as g;
- select group_concat(js separator ',') into js_documents_dop_filename from
- (select
- CONCAT( '{"code":"stop-word",
- "stopWord": { "id": ',k.id,',
- "text": "',k.name,'"},
- "attribute": {"id" : "-5",
- "code":"documents_dop_filename",
- "label":"Файл (название файла) (атрибуты)"}
- }' ) as js
- from (select lower(documents_dop_filename) as w from jsonDat) as t
- inner join kt_stop_word as k
- on (t.w = lower_name or instr(t.w, BINARY k.lower_name) > 0 ) AND
- t.w NOT REGEXP CONCAT('[[:alpha:]](',k.lower_name,')$|^(',k.lower_name,')[[:alpha:]]|[[:alpha:]](',k.lower_name,')[[:alpha:]]|[[:alpha:]](',k.lower_name,')[^[:alpha:]]|[^[:alpha:]](',k.lower_name,')[[:alpha:]]')
- where k.isActive = 1 ) as g;
- #не проверяем на нулл, тк concat_ws автоматом убирает нуллы + разделители
- #но т.к. была пустая строка в final_json, то заменим ее на нулл
- if final_json = ''
- then
- set final_json = null;
- end if;
- set violations = CONCAT( '[',
- CONCAT_WS(',',
- final_json,
- js_product_name,
- js_trade_name,
- js_manifacturer_country,
- js_manufacturer_name,
- js_brand_name_product_offer,
- js_Offer_number_TRU_supplier,
- js_extra_features_name0,
- js_extra_features_qualityValueSet0,
- js_extra_features_name1,
- js_extra_features_qualityValueSet1,
- js_delivery_places,
- js_documents_name,
- js_documents_department,
- js_documents_number,
- js_documents_filename,
- js_documents_range,
- js_documents_dop_name,
- js_documents_dop_filename
- ), ']');
- CREATE TABLE IF NOT EXISTS test_validation (
- dat timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
- js json DEFAULT NULL,
- violations json DEFAULT NULL
- ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
- insert into test_validation(js, violations)
- select jss, violations;
- DROP TEMPORARY TABLE IF EXISTS jsonDat;
- select violations;
- end$$
- DELIMITER ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement