Установка автозаказа — различия между версиями
Материал из wiki.standart-n.ru
Agk (обсуждение | вклад) |
Agk (обсуждение | вклад) |
||
Строка 20: | Строка 20: | ||
MGN_ID DM_ID_NULL, | MGN_ID DM_ID_NULL, | ||
INSERTDT DM_DATETIME); | INSERTDT DM_DATETIME); | ||
+ | |||
+ | CREATE SEQUENCE GEN_EXT_DATA_ID; | ||
+ | ALTER SEQUENCE GEN_EXT_DATA_ID RESTART WITH 0; | ||
+ | |||
+ | CREATE INDEX EXT_DATA_IDX1 ON EXT_DATA (ID); | ||
+ | CREATE INDEX EXT_DATA_IDX2 ON EXT_DATA (SNAME); | ||
+ | CREATE INDEX EXT_DATA_IDX3 ON EXT_DATA (MGN_ID); | ||
+ | |||
+ | CREATE OR ALTER TRIGGER EXT_DATA_BI FOR EXT_DATA | ||
+ | ACTIVE BEFORE INSERT POSITION 0 | ||
+ | as | ||
+ | begin | ||
+ | new.insertdt = 'now'; | ||
+ | if (new.id is null) then | ||
+ | new.id = gen_id(gen_ext_data_id,1); | ||
+ | end; | ||
</nowiki> | </nowiki> | ||
Строка 30: | Строка 46: | ||
</nowiki> | </nowiki> | ||
− | ==В | + | ==В виды VW_DOC_DETAIL и VW_WARES добавить поля== |
<nowiki> | <nowiki> | ||
MGN_NAME, | MGN_NAME, | ||
Строка 43: | Строка 59: | ||
</nowiki> | </nowiki> | ||
где w - таблица WARES | где w - таблица WARES | ||
+ | |||
+ | ==В вид VW_DOC_DETAIL_ACTIVE добавить поля== | ||
+ | <nowiki> | ||
+ | MGN_NAME, | ||
+ | MGN_ID, | ||
+ | MGN_SOURCE | ||
+ | </nowiki> | ||
+ | как | ||
+ | <nowiki> | ||
+ | (select mgn_name from wares where id = da.ware_id) as mgn_name, | ||
+ | (select mgn_id from wares where id = da.ware_id) as mgn_id, | ||
+ | (select mgn_source from wares where id = da.ware_id) as mgn_source | ||
+ | </nowiki> | ||
+ | |||
+ | ==В вид VW_WAREBASE добавить поле== | ||
+ | <nowiki> | ||
+ | MGN_NAME | ||
+ | </nowiki> | ||
+ | как | ||
+ | <nowiki> | ||
+ | (select mgn_name from wares where id = wb.ware_id) | ||
+ | </nowiki> | ||
+ | |||
+ | ==В триггер WARES_BU_DISTR и WARES_BU0 добавить условие== | ||
+ | <nowiki> | ||
+ | if (new.name_id <> old.name_id) then | ||
+ | begin | ||
+ | new.mgn_name = null; | ||
+ | new.mgn_id = 0; | ||
+ | end | ||
+ | </nowiki> | ||
+ | |||
+ | ==Создать таблицу ORDER_DATA== | ||
+ | <nowiki> | ||
+ | CREATE TABLE ORDER_DATA ( | ||
+ | ID DM_ID NOT NULL /* DM_ID = BIGINT */, | ||
+ | MGN_NAME DM_TEXT1024 /* DM_TEXT1024 = VARCHAR(1024) */, | ||
+ | ORDER_QUANT DM_DOUBLE /* DM_DOUBLE = DOUBLE PRECISION */, | ||
+ | SHORT_ORDER_QUANT DM_DOUBLE /* DM_DOUBLE = DOUBLE PRECISION */, | ||
+ | OPTIMAL_ORDER_QUANT DM_DOUBLE /* DM_DOUBLE = DOUBLE PRECISION */, | ||
+ | ASSORT_ORDER_QUANT DM_DOUBLE /* DM_DOUBLE = DOUBLE PRECISION */, | ||
+ | LAST_PRIHOD_QUANT SMALLINT, | ||
+ | REALQUANT DM_DOUBLE /* DM_DOUBLE = DOUBLE PRECISION */, | ||
+ | LAST_PRIHOD_DATE DM_DATETIME /* DM_DATETIME = TIMESTAMP */, | ||
+ | LAST_PRIHOD_PRICE DM_DOUBLE /* DM_DOUBLE = DOUBLE PRECISION */, | ||
+ | LAST_WEEK_SUM DM_DOUBLE /* DM_DOUBLE = DOUBLE PRECISION */, | ||
+ | LAST_2WEEKS_SUM DM_DOUBLE /* DM_DOUBLE = DOUBLE PRECISION */, | ||
+ | LAST_PERIOD_SUM DM_DOUBLE /* DM_DOUBLE = DOUBLE PRECISION */, | ||
+ | LAST_MONTH_SUM DM_DOUBLE /* DM_DOUBLE = DOUBLE PRECISION */, | ||
+ | SEASON_SUM DM_DOUBLE /* DM_DOUBLE = DOUBLE PRECISION */, | ||
+ | RASHOD_DOC_QUANT DM_STATUS /* DM_STATUS = INTEGER */, | ||
+ | PRIHOD_DOC_QUANT DM_STATUS /* DM_STATUS = INTEGER */, | ||
+ | LAST_OZ_DATE DM_DATETIME /* DM_DATETIME = TIMESTAMP */, | ||
+ | ELNAKL_QUANT DM_DOUBLE /* DM_DOUBLE = DOUBLE PRECISION */, | ||
+ | QUANT DM_DOUBLE /* DM_DOUBLE = DOUBLE PRECISION */, | ||
+ | LAST_OZ_QUANT DM_DOUBLE /* DM_DOUBLE = DOUBLE PRECISION */, | ||
+ | ACTIVE_PRIHOD_DOC_QUANT DM_DOUBLE /* DM_DOUBLE = DOUBLE PRECISION */, | ||
+ | LAST_OZ_PRICE DM_DOUBLE /* DM_DOUBLE = DOUBLE PRECISION */, | ||
+ | LAST_RASHOD_DATE DM_DATETIME, | ||
+ | ACTIVE_ORDER_QUANT DM_DOUBLE, | ||
+ | MGN_ID DM_ID_NULL /* DM_ID_NULL = BIGINT */, | ||
+ | BAD_FLAG DM_STATUS /* DM_STATUS = INTEGER */, | ||
+ | INSERTDT DM_DATETIME /* DM_DATETIME = TIMESTAMP */ | ||
+ | ); | ||
+ | |||
+ | CREATE GENERATOR GEN_ORDER_DATA_ID; | ||
+ | ALTER TABLE ORDER_DATA ADD CONSTRAINT PK_ORDER_DATA PRIMARY KEY (ID); | ||
+ | |||
+ | CREATE INDEX ORDER_DATA_IDX1 ON ORDER_DATA (MGN_NAME); | ||
+ | CREATE DESCENDING INDEX ORDER_DATA_IDX2 ON ORDER_DATA (MGN_NAME); | ||
+ | CREATE DESCENDING INDEX ORDER_DATA_IDX3 ON ORDER_DATA (ID); | ||
+ | |||
+ | CREATE OR ALTER TRIGGER ORDER_DATA_BI FOR ORDER_DATA | ||
+ | ACTIVE BEFORE INSERT POSITION 0 | ||
+ | as | ||
+ | begin | ||
+ | if (new.id is null) then | ||
+ | new.id = gen_id(gen_order_data_id,1); | ||
+ | end; | ||
+ | |||
+ | ==Проверка себя== |
Версия 13:14, 11 сентября 2014
Содержание
- 1 Заменить версию Менеджера
- 2 Создать таблицу ELNAKLS
- 3 Создать таблицу EXT_DATA
- 4 Добавить в таблицу WARES поля
- 5 В виды VW_DOC_DETAIL и VW_WARES добавить поля
- 6 В вид VW_DOC_DETAIL_ACTIVE добавить поля
- 7 В вид VW_WAREBASE добавить поле
- 8 В триггер WARES_BU_DISTR и WARES_BU0 добавить условие
- 9 Создать таблицу ORDER_DATA
Заменить версию Менеджера
Заменить ManagerXP2.exe на версию 2.272.25 от сентября 2014 г. или более новую.
Создать таблицу ELNAKLS
CREATE TABLE ELNAKLS(FILENAME DM_TEXT1024);
Создать таблицу EXT_DATA
CREATE TABLE EXT_DATA(ID DM_ID NOT NULL, SNAME DM_TEXT1024, ORIG_NAME DM_TEXT1024, MGN_SOURCE DM_TEXT1024, QUANT DM_DOUBLE, PRICE DM_DOUBLE, SUMMA DM_DOUBLE, SDOC_TYPE DM_TEXT1024, COMMITDATE DM_DATETIME, DOC_TYPE DM_STATUS, STATUS DM_STATUS, MGN_ID DM_ID_NULL, INSERTDT DM_DATETIME); CREATE SEQUENCE GEN_EXT_DATA_ID; ALTER SEQUENCE GEN_EXT_DATA_ID RESTART WITH 0; CREATE INDEX EXT_DATA_IDX1 ON EXT_DATA (ID); CREATE INDEX EXT_DATA_IDX2 ON EXT_DATA (SNAME); CREATE INDEX EXT_DATA_IDX3 ON EXT_DATA (MGN_ID); CREATE OR ALTER TRIGGER EXT_DATA_BI FOR EXT_DATA ACTIVE BEFORE INSERT POSITION 0 as begin new.insertdt = 'now'; if (new.id is null) then new.id = gen_id(gen_ext_data_id,1); end;
Добавить в таблицу WARES поля
ALTER TABLE WARES ADD SNAME DM_TEXT1024; ALTER TABLE WARES ADD MGN_NAME DM_TEXT1024; ALTER TABLE WARES ADD MGN_ID DM_ID_NULL; ALTER TABLE WARES ADD MGN_SOURCE DM_TEXT1024;
В виды VW_DOC_DETAIL и VW_WARES добавить поля
MGN_NAME, MGN_ID, MGN_SOURCE
как
w.mgn_name, w.mgn_id, w.mgn_source
где w - таблица WARES
В вид VW_DOC_DETAIL_ACTIVE добавить поля
MGN_NAME, MGN_ID, MGN_SOURCE
как
(select mgn_name from wares where id = da.ware_id) as mgn_name, (select mgn_id from wares where id = da.ware_id) as mgn_id, (select mgn_source from wares where id = da.ware_id) as mgn_source
В вид VW_WAREBASE добавить поле
MGN_NAME
как
(select mgn_name from wares where id = wb.ware_id)
В триггер WARES_BU_DISTR и WARES_BU0 добавить условие
if (new.name_id <> old.name_id) then begin new.mgn_name = null; new.mgn_id = 0; end
Создать таблицу ORDER_DATA
CREATE TABLE ORDER_DATA ( ID DM_ID NOT NULL /* DM_ID = BIGINT */, MGN_NAME DM_TEXT1024 /* DM_TEXT1024 = VARCHAR(1024) */, ORDER_QUANT DM_DOUBLE /* DM_DOUBLE = DOUBLE PRECISION */, SHORT_ORDER_QUANT DM_DOUBLE /* DM_DOUBLE = DOUBLE PRECISION */, OPTIMAL_ORDER_QUANT DM_DOUBLE /* DM_DOUBLE = DOUBLE PRECISION */, ASSORT_ORDER_QUANT DM_DOUBLE /* DM_DOUBLE = DOUBLE PRECISION */, LAST_PRIHOD_QUANT SMALLINT, REALQUANT DM_DOUBLE /* DM_DOUBLE = DOUBLE PRECISION */, LAST_PRIHOD_DATE DM_DATETIME /* DM_DATETIME = TIMESTAMP */, LAST_PRIHOD_PRICE DM_DOUBLE /* DM_DOUBLE = DOUBLE PRECISION */, LAST_WEEK_SUM DM_DOUBLE /* DM_DOUBLE = DOUBLE PRECISION */, LAST_2WEEKS_SUM DM_DOUBLE /* DM_DOUBLE = DOUBLE PRECISION */, LAST_PERIOD_SUM DM_DOUBLE /* DM_DOUBLE = DOUBLE PRECISION */, LAST_MONTH_SUM DM_DOUBLE /* DM_DOUBLE = DOUBLE PRECISION */, SEASON_SUM DM_DOUBLE /* DM_DOUBLE = DOUBLE PRECISION */, RASHOD_DOC_QUANT DM_STATUS /* DM_STATUS = INTEGER */, PRIHOD_DOC_QUANT DM_STATUS /* DM_STATUS = INTEGER */, LAST_OZ_DATE DM_DATETIME /* DM_DATETIME = TIMESTAMP */, ELNAKL_QUANT DM_DOUBLE /* DM_DOUBLE = DOUBLE PRECISION */, QUANT DM_DOUBLE /* DM_DOUBLE = DOUBLE PRECISION */, LAST_OZ_QUANT DM_DOUBLE /* DM_DOUBLE = DOUBLE PRECISION */, ACTIVE_PRIHOD_DOC_QUANT DM_DOUBLE /* DM_DOUBLE = DOUBLE PRECISION */, LAST_OZ_PRICE DM_DOUBLE /* DM_DOUBLE = DOUBLE PRECISION */, LAST_RASHOD_DATE DM_DATETIME, ACTIVE_ORDER_QUANT DM_DOUBLE, MGN_ID DM_ID_NULL /* DM_ID_NULL = BIGINT */, BAD_FLAG DM_STATUS /* DM_STATUS = INTEGER */, INSERTDT DM_DATETIME /* DM_DATETIME = TIMESTAMP */ ); CREATE GENERATOR GEN_ORDER_DATA_ID; ALTER TABLE ORDER_DATA ADD CONSTRAINT PK_ORDER_DATA PRIMARY KEY (ID); CREATE INDEX ORDER_DATA_IDX1 ON ORDER_DATA (MGN_NAME); CREATE DESCENDING INDEX ORDER_DATA_IDX2 ON ORDER_DATA (MGN_NAME); CREATE DESCENDING INDEX ORDER_DATA_IDX3 ON ORDER_DATA (ID); CREATE OR ALTER TRIGGER ORDER_DATA_BI FOR ORDER_DATA ACTIVE BEFORE INSERT POSITION 0 as begin if (new.id is null) then new.id = gen_id(gen_order_data_id,1); end; ==Проверка себя==