123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386 |
- $PBExportHeader$uo_outware_move.sru
- forward
- global type uo_outware_move from nonvisualobject
- end type
- type s_outwaremx from structure within uo_outware_move
- end type
- end forward
- type s_outwaremx from structure
- long mtrlwareid
- long mtrlid
- long storageid
- decimal { 4 } qty
- string plancode
- decimal { 10 } cost
- string mtrlcode
- string mxdscrp
- long printid
- string status
- long scid
- integer dxflag
- long sptid
- string woodcode
- string pcode
- decimal { 10 } price
- decimal { 4 } addqty
- string unit
- string waredscrp
- datetime inworkdate
- string newplancode
- integer packqty
- decimal { 10 } cost_notax
- end type
- global type uo_outware_move from nonvisualobject
- end type
- global uo_outware_move uo_outware_move
- type variables
- public protectedwrite long outwareid //出仓单表自动增量id
- public protectedwrite string outwarecode //所有单据的唯一编号
- public protectedwrite datetime opdate //建立时间,自动
- public protectedwrite int flag=0 //仓库审核标志,默认0,审核时(变1)才减少库存
- public protectedwrite datetime auditingdate //审核时间
- public protectedwrite string auditingrep //审核操作员
- public protectedwrite string operator //建立操作员
- public protectedwrite datetime moddate //修改时间
- public protectedwrite string modrep //修改操作员
- long sstorageid //原仓库
- long dstorageid //目标仓库
- datetime outdate //进仓发生时间
- string outrep='' //经手人
- string dscrp='' //备注
- string relcode = ''
- string reason //调拨原因
- long d_auditflag = 0
- private:
- s_outwaremx outwaremx[] //明细结构数组
- long it_mxbt=0 //明细结构数组末指针
- boolean it_newbegin=true //新建标志
- boolean it_updatebegin=false//修改标志
- end variables
- forward prototypes
- public function integer add_dscrp (string arg_newdescppart, ref string arg_msg)
- public function integer p_clearmx ()
- public function integer p_reset ()
- public function integer p_getinfo (long arg_outwareid, ref string arg_msg)
- public function integer newbegin (ref string arg_msg)
- public function integer cancel (long arg_outwareid, ref string arg_msg)
- public function integer getinfo (long arg_outwareid, ref string arg_msg)
- public function integer updatebegin (long arg_outwareid, ref string arg_msg)
- public function integer ss_auditing (string arg_auditingrep, ref string arg_msg)
- public function integer c_ss_auditing (ref string arg_msg)
- public function integer ds_auditing (string arg_auditingrep, ref string arg_msg)
- public function integer c_ds_auditing (ref string arg_msg)
- public function integer mod_price (long arg_scid, long arg_outwareid, long arg_printid, decimal arg_price, ref string arg_msg)
- public function integer save (boolean arg_ifcommit, ref string arg_msg)
- public function integer acceptmx (long arg_mtrlwareid, decimal arg_qty, decimal arg_addqty, decimal arg_price, ref string arg_msg, long arg_printid, string arg_mxdscrp, string arg_newplancode, integer arg_packqty)
- end prototypes
- public function integer add_dscrp (string arg_newdescppart, ref string arg_msg);//add_dscrp(string arg_newdescppart)
- //0 fail 1 success
- int rslt=1
- arg_newdescppart=trim(arg_newdescppart)
- if it_updatebegin or it_newbegin then
- rslt=0
- arg_msg="编辑状态下不可用"
- goto ext
- end if
- update u_outware_move
- set dscrp = dscrp+' '+:arg_newdescppart
- where u_outware_move.outwareid = :outwareid;
- if sqlca.sqlcode<>0 then
- rollback ;
- rslt=0
- arg_msg="添加单据备注操作失败"+"~n"+sqlca.sqlerrtext
- goto ext
- end if
- commit;
- dscrp = dscrp+' '+arg_newdescppart
- ext: return (rslt)
- end function
- public function integer p_clearmx ();//INT p_clearmx()
- //清除明细
- it_mxbt=0
- RETURN 1
- end function
- public function integer p_reset ();//int p_reset()
- //清除对象及其明细
- outwareid=0
- outwarecode = ''
- flag=0
- relcode = ''
- sstorageid = 0
- dstorageid = 0
- outrep=''
- dscrp=''
- it_newbegin=false
- it_updatebegin=false
- //清除明细
- p_clearmx()
- return 1
- end function
- public function integer p_getinfo (long arg_outwareid, ref string arg_msg);//getinfo(arg_outwareid,string arg_msg)
- //0 失败 1成功
- Int rslt = 1
- IF arg_outwareid <= 0 THEN
- rslt = 0
- arg_msg = "非法调拨单唯一码"
- GOTO ext
- END IF
- SELECT u_outware_move.outwarecode,
- u_outware_move.opdate,
- u_outware_move.operator,
- u_outware_move.flag,
- u_outware_move.auditingdate,
- u_outware_move.auditingrep,
- u_outware_move.moddate,
- u_outware_move.modrep,
- u_outware_move.outdate,
- u_outware_move.outrep,
- u_outware_move.dscrp,
- u_outware_move.sstorageid,
- u_outware_move.dstorageid,
- u_outware_move.relcode,
- u_outware_move.reason,
- u_outware_move.d_auditflag
- INTO :outwarecode,
- :opdate,
- :operator,
- :flag,
- :auditingdate,
- :auditingrep,
- :moddate,
- :modrep,
- :outdate,
- :outrep,
- :dscrp,
- :sstorageid,
- :dstorageid,
- :relcode,
- :reason,
- :d_auditflag
- FROM u_outware_move
- Where u_outware_move.outwareid = :arg_outwareid;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败(错误出仓单唯一码),调拨单"
- GOTO ext
- END IF
- ext:
- IF rslt = 0 THEN p_reset()
- RETURN rslt
- end function
- public function integer newbegin (ref string arg_msg);//newbegin(INT arg_billtype,long arg_relid)
- //从置对象,设定业务类型与关联ID,准备建立新出仓单
- //0 fail 1 success
- LONG RSLT=1,CNT=0
- p_reset()
- it_newbegin=TRUE
- it_updatebegin=FALSE
- //EXT:
- IF RSLT=0 THEN p_reset()
- return RSLT
- end function
- public function integer cancel (long arg_outwareid, ref string arg_msg);//cancel()
- //如果单据还没有审核删除单据极其明细
- //0 FAIL, 1 SUCCESS
- INT rslt=1
- IF arg_outwareid<=0 THEN
- rslt=0
- arG_MSG="没有删除对象,操作取消"
- goto ext
- END IF
- rslt=p_getinfo(arg_outwareid,arg_msg)
- if rslt=0 then goto ext
- IF flag=1 THEN
- rslt=0
- arG_MSG="单据已经审核,不可以删除"
- goto ext
- END IF
- DELETE FROM u_outwaremovemx
- WHERE u_outwaremovemx.outwareid = :arg_outwareid;
- if sqlca.sqlcode<>0 then
- rslt=0
- arG_MSG="删除进仓单明细操作失败"+"~n"+SQLCA.SQLErrText
- ROLLBACK;
- goto ext
- end if
- DELETE FROM u_outware_move
- WHERE u_outware_move.outwareid = :arg_outwareid;
- if sqlca.sqlcode<>0 then
- rslt=0
- arG_MSG="删除进仓单操作失败"+"~n"+SQLCA.SQLErrText
- ROLLBACK;
- goto ext
- end if
- COMMIT;
- it_newbegin=FALSE
- it_updatebegin=FALSE
- EXT:
- p_reset()
- return (rslt)
- end function
- public function integer getinfo (long arg_outwareid, ref string arg_msg);//getinfo(long arg_outwareid,string arg_msg)
- //0 失败 1成功
- int rslt=1,i=1,no_mxcheck=0
- if arg_outwareid<=0 then
- rslt=0
- arg_msg="非法调拨仓单唯一码"
- goto ext
- end if
-
- if p_getinfo(arg_outwareid,arg_msg) = 0 then
- rslt = 0
- goto ext
- end if
- //用游标读取明细
- declare cur_outwaermx cursor for
- select u_outwaremovemx.mtrlwareid,
- u_outwaremovemx.mtrlid,
- u_outwaremovemx.storageid,
- u_outwaremovemx.qty,
- u_outwaremovemx.addqty,
- u_outwaremovemx.cost,
- u_outwaremovemx.price,
- u_mtrldef.mtrlcode,
- u_mtrldef.unit,
- u_outwaremovemx.printid,
- u_outwaremovemx.mxdscrp,
- u_outwaremovemx.status,
- u_outwaremovemx.plancode,
- u_outwaremovemx.scid,
- u_outwaremovemx.dxflag,
- u_outwaremovemx.sptid,
- u_outwaremovemx.woodcode,
- u_outwaremovemx.pcode,
- u_outwaremovemx.waredscrp,
- u_outwaremovemx.inworkdate,
- u_outwaremovemx.newplancode,
- u_outwaremovemx.cost_notax
- from u_outwaremovemx,u_mtrldef
- where u_outwaremovemx.outwareid = :arg_outwareid and
- u_outwaremovemx.mtrlid=u_mtrldef.mtrlid;
- open cur_outwaermx;
- fetch cur_outwaermx into :outwaremx[i].mtrlwareid,:outwaremx[i].mtrlid,
- :outwaremx[i].storageid,:outwaremx[i].qty,:outwaremx[i].addqty,
- :outwaremx[i].cost,:outwaremx[i].price,
- :outwaremx[i].mtrlcode,:outwaremx[i].unit,:outwaremx[i].printid,
- :outwaremx[i].mxdscrp,:outwaremx[i].status,
- :outwaremx[i].plancode,:outwaremx[i].scid,
- :outwaremx[i].dxflag,:outwaremx[i].sptid,
- :outwaremx[i].woodcode,:outwaremx[i].pcode,
- :outwaremx[i].waredscrp,
- :outwaremx[i].inworkdate,
- :outwaremx[i].newplancode,
- :outwaremx[i].cost_notax;
- do while sqlca.sqlcode=0
- i++
- fetch cur_outwaermx into :outwaremx[i].mtrlwareid,:outwaremx[i].mtrlid,
- :outwaremx[i].storageid,:outwaremx[i].qty,:outwaremx[i].addqty,
- :outwaremx[i].cost,:outwaremx[i].price,
- :outwaremx[i].mtrlcode,:outwaremx[i].unit,:outwaremx[i].printid,
- :outwaremx[i].mxdscrp,:outwaremx[i].status,
- :outwaremx[i].plancode,:outwaremx[i].scid,
- :outwaremx[i].dxflag,:outwaremx[i].sptid,
- :outwaremx[i].woodcode,:outwaremx[i].pcode,
- :outwaremx[i].waredscrp,
- :outwaremx[i].inworkdate,
- :outwaremx[i].newplancode,
- :outwaremx[i].cost_notax;
- loop
- close cur_outwaermx;
- //检验明细是否读入完整
- select count(*) into :no_mxcheck
- from u_outwaremovemx
- where u_outwaremovemx.outwareid = :arg_outwareid;
- if sqlca.sqlcode<>0 then
- rslt=0
- arg_msg="查询操作失败,调拨单明细数量"
- goto ext
- end if
- if i<>no_mxcheck+1 then
- rslt=0
- arg_msg="查询操作失败,调拨单明细"
- goto ext
- end if
- outwareid = arg_outwareid
- it_mxbt=i - 1
- it_newbegin=false
- it_updatebegin=false
- ext:
- if rslt=0 then p_reset()
- return rslt
- end function
- public function integer updatebegin (long arg_outwareid, ref string arg_msg);//updatebegin(long arg_outwareid,int arg_billtype,long arg_relid)
- //从置对象,设定业务类型与关联id,准备更新出仓单
- //0 fail 1 success
- Int rslt = 1,cnt = 0
- IF arg_outwareid <= 0 THEN
- rslt = 0
- outwareid = 0
- GOTO ext
- END IF
- rslt = p_getinfo(arg_outwareid,arg_msg)
- IF rslt = 0 THEN GOTO ext
- IF flag = 1 THEN
- rslt = 0
- arg_msg = '单据已经审核,不可以修改'
- GOTO ext
- END IF
- outwareid = arg_outwareid
- p_clearmx()
- it_newbegin = False
- it_updatebegin = True
- ext:
- IF rslt = 0 THEN p_reset()
- RETURN rslt
- end function
- public function integer ss_auditing (string arg_auditingrep, ref string arg_msg);//调仓单调出审核
- //auditing(arg_auditingrep,arg_msg)
- //单据审核后生成一张原仓库调拨出仓单,目标仓库调拨入仓单
- //0 fail 1 success
- Long rslt = 1,cnt = 0,i
- Long rst_outwareid //调拨出仓id
- Long s_scid
- Long o_scid
- uo_outware uo_out
- uo_out = Create uo_outware
- uo_out.commit_transaction = sqlca
- uo_out.if_getid_ture = False
- IF outwareid = 0 THEN
- rslt = 0
- arg_msg = "没有审核对象"
- GOTO ext
- END IF
- IF it_newbegin Or it_updatebegin THEN
- rslt = 0
- arg_msg = "编辑状态下不可以执行审核"
- GOTO ext
- END IF
- IF flag = 1 THEN
- rslt = 0
- arg_msg = "单据已经调出审核"
- GOTO ext
- END IF
- UPDATE u_outware_move
- SET auditingrep = :arg_auditingrep,
- auditingdate = getdate(),
- flag = 1
- Where u_outware_move.outwareid = :outwareid And flag = 0;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "调出审核单据操作失败"+"~n"+sqlca.SQLErrText
- GOTO ext
- ELSEIF sqlca.SQLNRows = 0 THEN
- rslt = 0
- arg_msg = "调仓单据正在调出审核,请稍后查询。"+"~n"+sqlca.SQLErrText
- GOTO ext
- END IF
- SELECT scid INTO :s_scid
- FROM u_storage
- Where storageid = :sstorageid;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '查询调出仓库所属分部资料失败'
- rslt = 0
- GOTO ext
- END IF
- //2.原事务生成出仓单
- IF uo_out.newbegin(s_scid,12,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- uo_out.relid = outwareid
- uo_out.outdate = outdate
- uo_out.outrep = outrep
- uo_out.part = outwarecode
- uo_out.dscrp = dscrp
- uo_out.cusname = '调拨出仓'
- uo_out.storageid = sstorageid
- FOR i = 1 To it_mxbt
- IF uo_out.acceptmx(outwaremx[i].mtrlwareid,&
- outwaremx[i].qty,outwaremx[i].addqty,outwaremx[i].cost,1,&
- outwaremx[i].mxdscrp,outwaremx[i].printid,arg_msg,0,0,0,0,0,0,0,outwaremx[i].unit,1,'','') = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- NEXT
- IF uo_out.Save(False,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- rst_outwareid = uo_out.outwareid
- //4.原事务审核出仓单
- IF uo_out.getinfo(s_scid,rst_outwareid,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF uo_out.auditing(False,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- //更新出仓成本价
- IF sys_option_outwaremove = 0 THEN //按出仓成本价
- UPDATE u_outwaremovemx
- SET cost = u_outwaremx.cost,
- price = u_outwaremx.cost
- FROM u_OutWaremoveMx INNER JOIN
- u_outwaremx ON u_OutWaremoveMx.MtrlWareID = u_outwaremx.mtrlwareid
- WHERE (u_outwaremx.scid = :s_scid)
- And (u_outwaremx.outwareid = :rst_outwareid);
- ELSE
- UPDATE u_outwaremovemx
- SET cost = u_outwaremx.cost
- FROM u_OutWaremoveMx INNER JOIN
- u_outwaremx ON u_OutWaremoveMx.MtrlWareID = u_outwaremx.mtrlwareid
- WHERE (u_outwaremx.scid = :s_scid)
- And (u_outwaremx.outwareid = :rst_outwareid);
- END IF
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "更新调拨明细出仓成本价失败"+"~n"+sqlca.SQLErrText
- GOTO ext
- END IF
- flag = 1
- ext:
- IF rslt = 0 THEN
- ROLLBACK;
- ELSE
- COMMIT;
- END IF
- Destroy uo_out
- RETURN rslt
- end function
- public function integer c_ss_auditing (ref string arg_msg);//调仓单审核
- //auditing(arg_auditingrep,arg_msg)
- //单据审核后生成一张原仓库调拨出仓单,目标仓库调拨入仓单
- //0 fail 1 success
- Long rslt = 1,cnt = 0,i
- Long rst_outwareid //调拨出仓id
- Long rst_inwareid //调拨进仓id
- Long s_scid
- Long o_scid
- DateTime null_dt
- SetNull(null_dt)
- uo_outware uo_out
- uo_out = Create uo_outware
- uo_out.commit_transaction = sqlca
- uo_out.if_getid_ture = False
- IF outwareid = 0 THEN
- rslt = 0
- arg_msg = "没有撤审对象"
- GOTO ext
- END IF
- IF it_newbegin Or it_updatebegin THEN
- rslt = 0
- arg_msg = "编辑状态下不可以执行审核"
- GOTO ext
- END IF
- IF flag = 0 THEN
- rslt = 0
- arg_msg = "单据未调出审核"
- GOTO ext
- END IF
- UPDATE u_outware_move
- SET auditingrep = '',
- auditingdate = :null_dt,
- flag = 0
- Where u_outware_move.outwareid = :outwareid And flag = 1;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "调出撤审单据操作失败"+"~n"+sqlca.SQLErrText
- GOTO ext
- ELSEIF sqlca.SQLNRows = 0 THEN
- rslt = 0
- arg_msg = "调仓单据正在调出撤审,请稍后查询。"+"~n"+sqlca.SQLErrText
- GOTO ext
- END IF
- SELECT scid INTO :s_scid
- FROM u_storage
- Where storageid = :sstorageid;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '查询调出仓库所属分部资料失败'
- rslt = 0
- GOTO ext
- END IF
- //查询调仓单相关的出仓单
- SELECT outwareid INTO :rst_outwareid
- FROM u_outware
- WHERE scid = :s_scid
- AND relid = :outwareid
- And billtype = 12;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '查询该调仓单相关出仓单失败,'+sqlca.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- //撤审出仓单,再删除
- IF uo_out.getinfo(s_scid,rst_outwareid,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF uo_out.c_auditing(False,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF uo_out.del(s_scid,rst_outwareid,arg_msg,False) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- flag = 1
- ext:
- IF rslt = 0 THEN
- ROLLBACK;
- ELSE
- COMMIT;
- END IF
- Destroy uo_out
- RETURN rslt
- end function
- public function integer ds_auditing (string arg_auditingrep, ref string arg_msg);//调仓单调入审核
- //auditing(arg_auditingrep,arg_msg)
- //单据审核后生成一张原仓库调拨出仓单,目标仓库调拨入仓单
- //0 fail 1 success
- Long rslt = 1,cnt = 0,i
- Long rst_inwareid //调拨进仓id
- Long s_scid
- Long o_scid
- uo_inware uo_in
- uo_in = CREATE uo_inware
- uo_in.commit_transaction = sqlca
- uo_in.if_getid_ture = FALSE
- IF outwareid = 0 THEN
- rslt = 0
- arg_msg = "没有审核对象"
- GOTO ext
- END IF
- IF it_newbegin OR it_updatebegin THEN
- rslt = 0
- arg_msg = "编辑状态下不可以执行审核"
- GOTO ext
- END IF
- IF d_auditflag = 1 THEN
- rslt = 0
- arg_msg = "单据已经调入审核"
- GOTO ext
- END IF
- UPDATE u_outware_move
- SET d_auditingrep = :arg_auditingrep,
- d_auditingdate = getdate(),
- d_auditflag = 1
- Where u_outware_move.outwareid = :outwareid AND d_auditflag = 0;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "调入审核单据操作失败"+"~n"+sqlca.SQLErrText
- GOTO ext
- ELSEIF sqlca.SQLNRows = 0 THEN
- rslt = 0
- arg_msg = "调仓单据正在调入审核,请稍后查询。"+"~n"+sqlca.SQLErrText
- GOTO ext
- END IF
- SELECT scid INTO :o_scid
- FROM u_storage
- Where storageid = :dstorageid;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '查询调入仓库所属分部资料失败'
- rslt = 0
- GOTO ext
- END IF
- //3.目标事务建立进仓单
- DateTime server_datetime
- SELECT Top 1 getdate() INTO :server_datetime FROM u_user;
- //取得系统时间,借用操作员表
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询目标仓库日期失败"
- GOTO ext
- END IF
- IF uo_in.newbegin(o_scid,12,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- uo_in.relid = outwareid
- uo_in.indate = outdate
- uo_in.inrep = outrep
- uo_in.part = outwarecode
- uo_in.dscrp = dscrp
- uo_in.storageid = dstorageid
- uo_in.sptname = '调拨进仓'
- FOR i = 1 TO it_mxbt
- Decimal ld_price
- IF sys_option_outwaremove = 0 THEN
- ld_price = outwaremx[i].cost
- ELSE
- ld_price = outwaremx[i].price
- END IF
- IF uo_in.acceptmx(outwaremx[i].printid,&
- outwaremx[i].mtrlid,&
- outwaremx[i].mtrlcode,&
- outwaremx[i].newplancode,&
- outwaremx[i].status,&
- outwaremx[i].qty,&
- outwaremx[i].addqty,&
- ld_price,&
- 1,&
- outwaremx[i].mxdscrp,&
- arg_msg,&
- 0,0,0,0,outwaremx[i].woodcode,&
- outwaremx[i].pcode,&
- '',&
- outwaremx[i].sptid,outwaremx[i].unit,1,'',outwaremx[i].waredscrp,outwaremx[i].inworkdate,outwaremx[i].cost_notax) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- NEXT
- IF uo_in.Save(FALSE,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- rst_inwareid = uo_in.inwareid
- //4.原事务审核进仓单
- IF uo_in.getinfo(o_scid,rst_inwareid,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF uo_in.auditing(FALSE,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- d_auditflag = 1
- ext:
- IF rslt = 0 THEN
- ROLLBACK;
- ELSE
- COMMIT;
- END IF
- DESTROY uo_in
- RETURN rslt
- end function
- public function integer c_ds_auditing (ref string arg_msg);//调仓单调入撤审
- //auditing(arg_auditingrep,arg_msg)
- //单据审核后生成一张原仓库调拨出仓单,目标仓库调拨入仓单
- //0 fail 1 success
- Long rslt = 1,cnt = 0,i
- Long rst_inwareid //调拨进仓id
- Long s_scid
- Long o_scid
- DateTime null_dt
- SetNull(null_dt)
- uo_inware uo_in
- uo_in = Create uo_inware
- uo_in.commit_transaction = sqlca
- uo_in.if_getid_ture = False
- IF outwareid = 0 THEN
- rslt = 0
- arg_msg = "没有撤审对象"
- GOTO ext
- END IF
- IF it_newbegin Or it_updatebegin THEN
- rslt = 0
- arg_msg = "编辑状态下不可以执行审核"
- GOTO ext
- END IF
- IF d_auditflag = 0 THEN
- rslt = 0
- arg_msg = "单据未调入审核"
- GOTO ext
- END IF
- UPDATE u_outware_move
- SET d_auditingrep = '',
- d_auditingdate = :null_dt,
- d_auditflag = 0
- Where u_outware_move.outwareid = :outwareid And d_auditflag = 1;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "调入撤审单据操作失败"+"~n"+sqlca.SQLErrText
- GOTO ext
- ELSEIF sqlca.SQLNRows = 0 THEN
- rslt = 0
- arg_msg = "调仓单据正在调入撤审,请稍后查询。"+"~n"+sqlca.SQLErrText
- GOTO ext
- END IF
- SELECT scid INTO :o_scid
- FROM u_storage
- Where storageid = :dstorageid;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '查询调入仓库所属分部资料失败'
- rslt = 0
- GOTO ext
- END IF
- //查询调仓单相关的入仓单
- SELECT top 1 inwareid INTO :rst_inwareid
- FROM u_inware
- WHERE scid = :o_scid
- AND relid = :outwareid
- And billtype = 12;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '查询该调仓单相关入仓单失败,'+sqlca.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- //撤审入仓单,再删除
- IF uo_in.getinfo(o_scid,rst_inwareid,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF uo_in.c_auditing(False,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF uo_in.del(o_scid,rst_inwareid,arg_msg,False) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- d_auditflag = 1
- ext:
- IF rslt = 0 THEN
- ROLLBACK;
- ELSE
- COMMIT;
- END IF
- Destroy uo_in
- RETURN rslt
- end function
- public function integer mod_price (long arg_scid, long arg_outwareid, long arg_printid, decimal arg_price, ref string arg_msg);Long rslt = 1
- UPDATE u_OutWaremoveMx
- SET price = :arg_price
- WHERE outWareID = :arg_outwareid AND
- scid = :arg_scid AND
- Printid = :arg_printid ;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "更新单价操作失败"+"~n"+sqlca.SQLErrText
- GOTO ext
- END IF
- ext:
- IF rslt = 0 THEN
- ROLLBACK;
- ELSE
- COMMIT;
- END IF
- RETURN rslt
- end function
- public function integer save (boolean arg_ifcommit, ref string arg_msg);//submit(string arg_msg)
- // 新建(outwareid=0)\更新(outwareid>0)
- //0 fail 1 success
- //
- // 函数执行出仓操作
- // 函数在表 u_outware_move、u_outwaremovemx 记帐
- // 1 检查单据信息合法性
- // 2 新建-取得单据编号\新建出仓单\读取出仓单唯一码\插入明细
- // 2 修改-更新出仓单\删除旧明细\插入明细
- // 3 提交,修改状态标志
- Integer rslt = 1,cnt = 0,i
- DateTime server_datetime
- Long ls_newid
- IF IsNull(dscrp) THEN dscrp = ''
- IF IsNull(outrep) THEN outrep = ''
- IF IsNull(relcode) THEN relcode = ''
- IF IsNull(reason) THEN reason = ''
- IF it_newbegin = False And it_updatebegin = False THEN
- rslt = 0
- arg_msg = "非编辑状态不可以提交"
- GOTO ext
- END IF
- SELECT Top 1 getdate() Into :server_datetime From u_user ;
- //取得系统时间,借用操作员表
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,日期 "
- GOTO ext
- END IF
- IF it_mxbt = 0 THEN //如果输入库存物料资料错则已经清空
- rslt = 0
- arg_msg = "没有正确出仓内容"
- GOTO ext
- END IF
- IF outrep = '' THEN
- rslt = 0
- arg_msg = '请输入经手人'
- GOTO ext
- END IF
- IF Year(Date(outdate)) < 2000 Or IsNull(outdate) THEN
- rslt = 0
- arg_msg = "缺少出仓发生时间或不合理"
- GOTO ext
- END IF
- //检查仓库
- cnt = 0
- SELECT count(*) Into :cnt From u_storage Where storageid = :sstorageid;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,调出仓库"
- GOTO ext
- END IF
- IF cnt = 0 THEN
- rslt = 0
- arg_msg = "调出仓库未登记或已取消"
- GOTO ext
- END IF
- cnt = 0
- SELECT count(*) Into :cnt From u_storage Where storageid = :dstorageid;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,调入仓库"
- GOTO ext
- END IF
- IF cnt = 0 THEN
- rslt = 0
- arg_msg = "调入仓库未登记或已取消"
- GOTO ext
- END IF
- opdate = server_datetime //填写单据建立时间(最近修改时间)
- ////////////////////////////////////////////// //开始区分:新建/更新 处理
- IF outwareid = 0 THEN //新建
- ls_newid = f_sys_scidentity(sys_scid,"u_outware_move","outwareid",arg_msg,True,sqlca)
- IF ls_newid <= 0 THEN
- rslt = 0
- ROLLBACK;
- GOTO ext
- END IF
-
- outwarecode = getid(sys_scid,"MV",Date(server_datetime),True,sqlca) //取得新单据编号
- IF outwarecode = "err" THEN
- outwarecode = ''
- rslt = 0
- arg_msg = "无法获取出仓单编号"
- GOTO ext
- END IF
-
- INSERT INTO u_outware_move (
- outwareid,
- outwarecode,
- sstorageid,
- dstorageid,
- opdate,
- operator,
- flag,
- outdate,
- outrep,
- dscrp,
- relcode,
- reason)
- VALUES ( :ls_newid,
- :outwarecode,
- :sstorageid,
- :dstorageid,
- :server_datetime,
- :publ_operator,
- :flag,
- :outdate,
- :outrep,
- :dscrp,
- :relcode,
- :reason) ;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '插入单据失败,'+sqlca.SQLErrText
- GOTO ext
- END IF
-
- outwareid = ls_newid
-
- ELSE //////////////////////////////////////////////// //更新
- UPDATE u_outware_move
- SET
- outdate = :outdate,
- outrep = :outrep,
- dscrp = :dscrp,
- sstorageid = :sstorageid,
- dstorageid = :dstorageid,
- relcode = :relcode,
- modrep = :publ_operator,
- moddate = getdate(),
- reason = :reason
- Where u_outware_move.outwareid = :outwareid And flag = 0;
- IF sqlca.SQLCode <> 0 Or sqlca.SQLNRows <= 0 THEN
- rslt = 0
- arg_msg = "更新单据操作失败"+"~n"+sqlca.SQLErrText
- GOTO ext
- END IF
-
- //删除原有明细
- DELETE FROM u_outwaremovemx
- Where u_outwaremovemx.outwareid = :outwareid;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "删除旧有明细操作失败"+"~n"+sqlca.SQLErrText
- GOTO ext
- END IF
-
- // FOR i = 1 To it_mxbt
- // INSERT INTO u_outwaremovemx
- // ( outwareid,
- // mtrlwareid,
- // mtrlid,
- // storageid,
- // qty,
- // addqty,
- // cost,
- // price,
- // printid,
- // mxdscrp,
- // scid,
- // status,
- // plancode,
- // dxflag,
- // sptid,
- // woodcode,
- // pcode,
- // waredscrp,
- // inworkdate,
- // newplancode)
- // VALUES (:outwareid,
- // :outwaremx[i].mtrlwareid,
- // :outwaremx[i].mtrlid,
- // :outwaremx[i].storageid,
- // :outwaremx[i].qty,
- // :outwaremx[i].addqty,
- // :outwaremx[i].cost,
- // :outwaremx[i].price,
- // :outwaremx[i].printid,
- // :outwaremx[i].mxdscrp,
- // :outwaremx[i].scid,
- // :outwaremx[i].status,
- // :outwaremx[i].plancode,
- // :outwaremx[i].dxflag,
- // :outwaremx[i].sptid,
- // :outwaremx[i].woodcode,
- // :outwaremx[i].pcode,
- // :outwaremx[i].waredscrp,
- // :outwaremx[i].inworkdate,
- // :outwaremx[i].newplancode);
- //
- // IF sqlca.SQLCode <> 0 THEN
- // rslt = 0
- // IF Pos(Lower(sqlca.SQLErrText),'PK_u_outwaremovemx') > 0 THEN
- // arg_msg = '插入单据明细资料失败,关键字ID,序号重复'
- // ELSE
- // arg_msg = '因网络或其他原因导致插入单据明细资料失败,'+sqlca.SQLErrText
- // END IF
- // GOTO ext
- // END IF
- // NEXT
-
- END IF
- FOR i = 1 To it_mxbt
- INSERT INTO u_outwaremovemx
- (outwareid,
- mtrlwareid,
- mtrlid,
- storageid,
- qty,
- addqty,
- cost,
- price,
- printid,
- mxdscrp,
- scid,
- status,
- plancode,
- dxflag,
- sptid,
- woodcode,
- pcode,
- waredscrp,
- inworkdate,
- newplancode,
- packqty,
- cost_notax)
- VALUES (:outwareid,
- :outwaremx[i].mtrlwareid,
- :outwaremx[i].mtrlid,
- :outwaremx[i].storageid,
- :outwaremx[i].qty,
- :outwaremx[i].addqty,
- :outwaremx[i].cost,
- :outwaremx[i].price,
- :outwaremx[i].printid,
- :outwaremx[i].mxdscrp,
- :outwaremx[i].scid,
- :outwaremx[i].status,
- :outwaremx[i].plancode,
- :outwaremx[i].dxflag,
- :outwaremx[i].sptid,
- :outwaremx[i].woodcode,
- :outwaremx[i].pcode,
- :outwaremx[i].waredscrp,
- :outwaremx[i].inworkdate,
- :outwaremx[i].newplancode,
- :outwaremx[i].packqty,
- :outwaremx[i].cost_notax);
- IF sqlca.SQLCode <> 0 THEN
- IF it_newbegin THEN outwareid = 0 //还原outwareid
- rslt = 0
- arg_msg = '插入单据明细失败,'+sqlca.SQLErrText
- GOTO ext
- END IF
- NEXT
- it_newbegin = False
- it_updatebegin = False
- ext:
- IF rslt = 0 THEN
- ROLLBACK;
- p_clearmx()
- ELSEIF arg_ifcommit THEN
- COMMIT;
- END IF
- Return(rslt)
- end function
- public function integer acceptmx (long arg_mtrlwareid, decimal arg_qty, decimal arg_addqty, decimal arg_price, ref string arg_msg, long arg_printid, string arg_mxdscrp, string arg_newplancode, integer arg_packqty);//acceptmx(arg_mtrlwareid,arg_qty,arg_msg,arg_printid,arg_mxdscrp)
- //return 0 fail 1 success
- // 函数增加出仓单的一个出仓明细项
- Long rslt = 1,cnt = 0,ls_i
- Long i_mtrlid,i_storageid,i_scid
- String i_mtrlcode,i_status,i_plancode,i_woodcode,i_pcode
- Decimal i_cost,i_cost_notax
- Int i_dxflag
- Long i_sptid
- Decimal i_notauditqty,i_allouseqty
- String i_waredscrp
- DateTime i_inworkdate
- IF it_newbegin = False And it_updatebegin = False THEN
- rslt = 0
- arg_msg = "非编辑状态不可以使用,操作取消"
- GOTO ext
- END IF
- //清除空值
- IF IsNull(arg_mtrlwareid) THEN arg_mtrlwareid = 0
- IF IsNull(arg_qty) THEN arg_qty = 0
- IF IsNull(arg_mxdscrp) THEN arg_mxdscrp = ''
- IF IsNull(arg_printid) THEN arg_printid = 0
- IF IsNull(arg_price) THEN arg_price = 0
- IF isnull(arg_packqty) then arg_packqty = 0
- IF arg_mtrlwareid = 0 Or arg_qty = 0 THEN // 如果出仓数量为 0,或物料编号为空,则不作任何处理
- rslt = 1
- GOTO ext
- END IF
- //检查物料库存id
- SELECT u_mtrlware.mtrlid,
- u_mtrlware.storageid,
- u_mtrlware.cost,
- u_mtrldef.mtrlcode,
- u_mtrlware.plancode,
- u_mtrlware.status,
- u_mtrlware.scid,
- u_mtrlware.dxflag,
- u_mtrlware.sptid,
- u_mtrlware.woodcode,
- u_mtrlware.pcode,
- isnull(uv_mtrlware_noauditingqty.noauditingqty,0),
- u_mtrlware.noallocqty,
- u_mtrlware.waredscrp,
- u_mtrlware.inworkdate,
- u_mtrlware.cost_notax
- INTO :i_mtrlid,
- :i_storageid,
- :i_cost,
- :i_mtrlcode,
- :i_plancode,
- :i_status,
- :i_scid,
- :i_dxflag,
- :i_sptid,
- :i_woodcode,
- :i_pcode,
- :i_notauditqty,
- :i_allouseqty,
- :i_waredscrp,
- :i_inworkdate,
- :i_cost_notax
- FROM u_mtrlware left OUTER join uv_mtrlware_noauditingqty
- on ( u_mtrlware.mtrlwareid = uv_mtrlware_noauditingqty.mtrlwareid)
- AND ( u_mtrlware.scid = uv_mtrlware_noauditingqty.scid),u_mtrldef
- WHERE ( u_mtrlware.mtrlwareid = :arg_mtrlwareid )
- AND ( u_mtrlware.mtrlid = u_mtrldef.mtrlid )
- And ( u_mtrlware.storageid = :sstorageid );
-
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,库存编号错误"
- GOTO ext
- END IF
- //检查成本价调整单
- cnt = 0
- SELECT count(*)
- INTO :cnt
- FROM u_updatecost,u_updatecostmx
- WHERE u_updatecost.wareid = u_updatecostmx.wareid AND
- u_updatecost.flag = 0 AND
- u_updatecostmx.mtrlwareid = :arg_mtrlwareid Using sqlca;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "第" + String(arg_printid) + "行,查询成本价调整单操作失败"
- GOTO ext
- END IF
- IF cnt > 0 THEN
- rslt = 0
- arg_msg = "第" + String(arg_printid) + "行," + i_mtrlcode + "已开成本价调整单,请先审核"
- GOTO ext
- END IF
- IF IsNull(i_cost) THEN i_cost = 0
- IF IsNull(i_cost_notax) THEN i_cost_notax = 0
- IF IsNull(i_mtrlid) THEN i_mtrlid = 0
- IF IsNull(i_storageid) THEN i_storageid = 0
- IF IsNull(i_status) THEN i_status = ''
- IF IsNull(i_plancode) THEN i_plancode = ''
- IF IsNull(i_scid) THEN i_scid = 0
- IF IsNull(i_dxflag) THEN i_dxflag = 0
- IF IsNull(i_sptid) THEN i_sptid = 0
- IF IsNull(i_pcode) THEN i_pcode = ''
- //*****检查大于未开数不可以开单
- IF flag = 0 THEN
- Int ls_noallocflag
- Decimal ol_mtrl_qty = 0
-
- SELECT noallocflag INTO :ls_noallocflag
- FROM u_storage
- Where storageid = :sstorageid;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '查询仓库允许使用未开单库存属性失败'+sqlca.SQLErrText
- GOTO ext
- END IF
-
- IF ls_noallocflag = 1 THEN
- IF it_updatebegin THEN
- SELECT u_outwaremovemx.qty
- INTO :ol_mtrl_qty
- FROM u_outwaremovemx
- WHERE u_outwaremovemx.outwareid = :outwareid
- And u_outwaremovemx.mtrlwareid = :arg_mtrlwareid;
- IF sqlca.SQLCode = -1 THEN
- rslt = 0
- arg_msg = '查询原开单数量失败'
- GOTO ext
- END IF
- END IF
-
- IF arg_qty > ( i_allouseqty - i_notauditqty + ol_mtrl_qty ) THEN
- rslt = 0
- arg_msg = String(i_mtrlcode)+"库存未开单数不够,不能开单.未开单数{"+String(i_allouseqty - i_notauditqty + ol_mtrl_qty,'#####,0.00##')+"}"
- GOTO ext
- END IF
- END IF
- END IF
- //***********************************************
- //写入内容
- it_mxbt++
- outwaremx[it_mxbt].scid = i_scid
- outwaremx[it_mxbt].mtrlwareid = arg_mtrlwareid
- outwaremx[it_mxbt].mtrlid = i_mtrlid
- outwaremx[it_mxbt].qty = arg_qty
- outwaremx[it_mxbt].addqty = arg_addqty
- outwaremx[it_mxbt].storageid = i_storageid
- outwaremx[it_mxbt].cost = i_cost
- outwaremx[it_mxbt].cost_notax = i_cost_notax
- outwaremx[it_mxbt].mtrlcode = i_mtrlcode
- outwaremx[it_mxbt].printid = arg_printid
- outwaremx[it_mxbt].mxdscrp = arg_mxdscrp
- outwaremx[it_mxbt].status = i_status
- outwaremx[it_mxbt].plancode = i_plancode
- outwaremx[it_mxbt].dxflag = i_dxflag
- outwaremx[it_mxbt].sptid = i_sptid
- outwaremx[it_mxbt].woodcode = i_woodcode
- outwaremx[it_mxbt].pcode = i_pcode
- outwaremx[it_mxbt].price = arg_price
- outwaremx[it_mxbt].waredscrp = i_waredscrp
- outwaremx[it_mxbt].inworkdate = i_inworkdate
- outwaremx[it_mxbt].newplancode = arg_newplancode
- outwaremx[it_mxbt].packqty = arg_packqty
- ext:
- IF rslt = 0 THEN
- p_clearmx()
- arg_msg = "第" + String(arg_printid) + "行," + arg_msg
- END IF
- Return(rslt)
- end function
- on uo_outware_move.create
- call super::create
- TriggerEvent( this, "constructor" )
- end on
- on uo_outware_move.destroy
- TriggerEvent( this, "destructor" )
- call super::destroy
- end on
|