Выгрузка старого Автозаказа в Общий заказ
Материал из wiki.standart-n.ru
Выгрузка
Для работы дожно быть заполнено значение пути до папки Общего заказа
- Изменить вьюху VW_ZAKAZ добавить
SORIG_NAME как (select list(distinct coalesce(v.svalue,w.mgn_name,''),';') from wares w inner join wares w2 on (w2.name_id = z.NAME_ID or w2.orig_name_id = z.name_id--dd.NAME_ID ) and (w2.name_id = w.name_id or w2.orig_name_id = w.name_id) left join vals v on w.orig_name_id = v.id where w2.name_id is not null )
-полный текс
CREATE OR ALTER VIEW VW_ZAKAZ( ID, SNAME, SIZG, SCOUNTRY, AGENT_TOVAR, QUANT, PRICE, SUMMA, PRICE_O, SUMMA_O, QUANTOST, AVG_QUANT, NAME_ID, PART_ID, INSERTDT, MIN_QUANT, KRITK, OPTIM_QUANT, MMBSH, LAST_DATE, LAST_QUANT, SORIG_NAME) AS SELECT z.id, sname, sizg, scountry, (select a.caption from pr_getmotherpart(part_id) pr left join agents a on pr.agent_id=a.id), z.quant, z.price, summa, z.price_o, summa_o, quantost, avg_quant, name_id, part_id, z.insertdt, min_quant, kritk, optim_quant, (select membership from PR_MEMBERSHIPS('PARTS=' || part_id || ';PARTS.NAME_ID=' || name_id ||';',ascii_char(13)||ascii_char(10),1)), last_date, LAST_QUANT, (select list(distinct coalesce(v.svalue,w.mgn_name,''),';') from wares w inner join wares w2 on (w2.name_id = z.NAME_ID or w2.orig_name_id = z.name_id--dd.NAME_ID ) and (w2.name_id = w.name_id or w2.orig_name_id = w.name_id) left join vals v on w.orig_name_id = v.id where w2.name_id is not null ) FROM ZAKAZ_TMS z left join parts p on p.id = z.part_id ;
- Добавить новую ТМС или изменить старый вариант на тот что ниже
uses Classes, Graphics, Controls, Forms, Dialogs, ComCtrls, ToolWin, ImgList, dxExEdtr, dxCntner, dxTL, dxDBCtrl, dxDBGrid, DB, IBQuery, IBDatabase, unDM, DBTables, cfdxUtils, Menus, Buttons, ExtCtrls, StdCtrls, cfSelectEdit,DateUtils, gb_table, Mask, unFrameCustomDict, unMain,SysUtils, cfUtils; var t,profile,param_oz ,str_post,IMPORT_ID,sql: string; imp_count: Integer; procedure miLoadToOZ; var str: string; doc_type,i: integer; F : TextFile; FileName : String; qP: TIBQuery; PATH_ZAKAZ: String; begin try qP:=TIBQuery.Create(nil); qP.Database:=dm.FindComponent('db'); qP.Transaction:=TIBTransaction.Create(qP); qP.Transaction.DefaultDatabase:=qP.Database; //Путь выгрузки Автозаказа qP.sql.text:='select * from PARAMS where param_id = ''OZ_PATH'''; qP.Active:=true; qP.first; if (not qP.eof) then begin PATH_ZAKAZ:= qP.FieldByName('PARAM_VALUE').AsString; end; FileName:= PATH_ZAKAZ+'_import\'+DateToStr(Now)+'.ZAO'; //frmmanagerxp2.LogIt(FileName); AssignFile(F, FileName); Rewrite(F); qP.sql.text:=sql; qP.Active:=true; while not qP.eof do begin WriteLn(F, qP.FieldByName('SNAME').AsString+#9+#9+#9+qP.FieldByName('QUANT').AsString+#9+#9+qP.FieldByName('QUANT').AsString+#9+qP.FieldByName('PRICE_O').AsString+#9+qP.FieldByName('SNAME').AsString+';'+qP.FieldByName('SORIG_NAME').AsString+';'); qP.Next; end; finally qP.Free; CloseFile(F); Showmessage('Данные выгружены в Общий заказ'); end; end; begin sql:=gsender.GetCurSqlText; miLoadToOZ; end;