1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599 |
- $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 { 10 } qty
- decimal { 10 } uqty
- decimal { 5 } rate
- string unit
- 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
- string mtrlcuscode
- string location
- string newlocation
- decimal { 10 } inqty
- decimal { 10 } outqty
- integer outtype_mtrl
- integer ifrel
- long relid
- long relprintid
- string relcode
- 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 Int d_auditflag = 0 //仓库审核标志,默认0,审核时(变1)才减少库存
- Public ProtectedWrite DateTime d_auditingdate //审核时间
- Public ProtectedWrite String d_auditingrep //审核操作员
- Public ProtectedWrite String operator //建立操作员
- Public ProtectedWrite DateTime moddate //修改时间
- Public ProtectedWrite String modrep //修改操作员
- Public ProtectedWrite Int priceflag = 0
- long sscid
- long dscid
- Long sstorageid //原仓位
- Long dstorageid //目标仓位
- DateTime outdate //进仓发生时间
- DateTime indate //进仓发生时间
- String outrep = '' //经手人
- String dscrp = '' //备注
- String relcode = ''
- Int ifauto = 0 //自动建立
- long il_newlocation_cnt
- Boolean if_getid_ture = True
- Private:
- s_outwaremx outwaremx[] //明细结构数组
- s_outwaremx_barcode s_mx_barcode[]
- s_outwaremx_barcode s_mx_barcode_in[]
- Long it_mxbt = 0 //明细结构数组末指针
- Long it_mxbt_barcode = 0
- Long it_mxbt_barcode_in = 0
- Boolean it_newbegin = True //新建标志
- Boolean it_updatebegin = False //修改标志
- Int uo_option_barcode_outwaremove_paudit
- Int uo_option_inout_type
- Int uo_option_noauditingqty_mode
- Int uo_option_barcodelocation_use_inwaremx_location
- 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 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, boolean arg_ifcommit)
- public function integer c_ds_auditing (ref string arg_msg, boolean arg_ifcommit)
- public function integer c_ss_auditing (ref string arg_msg, boolean arg_ifcommit)
- public function integer ds_auditing (string arg_auditingrep, ref string arg_msg, boolean arg_ifcommit)
- public function integer cancel (long arg_outwareid, ref string arg_msg, boolean arg_ifcommit)
- public function integer save (ref string arg_msg, boolean arg_ifcommit)
- public function integer p_update_cost (long arg_mtrlwareid, long arg_printid, string arg_mtrlcode, ref decimal arg_ref_cost, ref string arg_msg, boolean arg_ifcommit)
- public function integer uof_update_waredate (boolean arg_ifcommit, ref string arg_msg)
- public function integer p_auditing (string arg_auditingrep, ref string arg_msg, boolean arg_ifcommit)
- public function integer c_p_auditing (ref string arg_msg, boolean arg_ifcommit)
- public function integer uof_set_qty_equal_bqty (long arg_outwareid, ref string arg_msg, boolean arg_ifcommit)
- public function integer uof_mod_indate (long arg_outwareid, datetime arg_indate, ref string arg_msg)
- public function integer uof_noauditingqty_add (ref string arg_msg)
- public function integer uof_noauditingqty_del (long arg_outwareid, ref string arg_msg)
- public function integer acceptmx (long arg_mtrlwareid, decimal arg_qty, decimal arg_price, ref string arg_msg, long arg_printid, string arg_mxdscrp, string arg_unit, decimal arg_uqty, decimal arg_rate, string arg_newlocation, integer arg_ifrel, long arg_relid, long arg_relprintid, string arg_relcode)
- 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()
- //清除明细
- il_newlocation_cnt = 0
- it_mxbt = 0
- it_mxbt_barcode = 0
- it_mxbt_barcode_in = 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 = ''
- d_auditflag = 0
- ifauto = 0
- 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.indate,
- u_outware_move.outrep,
- u_outware_move.dscrp,
- u_outware_move.sstorageid,
- u_outware_move.dstorageid,
- u_outware_move.relcode,
- u_outware_move.d_auditflag,
- u_outware_move.d_auditingdate,
- u_outware_move.d_auditingrep,
- u_outware_move.ifauto,
- u_outware_move.priceflag
- Into :outwarecode,
- :opdate,
- :operator,
- :flag,
- :auditingdate,
- :auditingrep,
- :moddate,
- :modrep,
- :outdate,
- :indate,
- :outrep,
- :dscrp,
- :sstorageid,
- :dstorageid,
- :relcode,
- :d_auditflag,
- :d_auditingdate,
- :d_auditingrep,
- :ifauto,
- :priceflag
- From u_outware_move
- Where u_outware_move.outwareid = :arg_outwareid;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败(错误出仓单唯一码),调拨单"
- GOTO ext
- END IF
- SELECT scid
- INTO :sscid
- FROM u_storage
- Where storageid = :sstorageid;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败(原仓库分部),调拨单"
- GOTO ext
- END IF
- SELECT scid
- INTO :dscid
- FROM u_storage
- Where storageid = :dstorageid;
- 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 getinfo (long arg_outwareid, ref string arg_msg);//getinfo(long arg_outwareid,string arg_msg)
- //0 失败 1成功
- Int rslt = 1
- Long i = 1,no_mxcheck = 0
- Long k = 1,no_mxcheck_barcode = 0
- Long j = 1,no_mxcheck_barcode_in = 0
- Int li_outtype,li_outtype_in
- 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
- SELECT outtype
- INTO :li_outtype
- FROM u_storage
- Where storageid = :sstorageid;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,调出仓库出仓类型,"+sqlca.SQLErrText
- GOTO ext
- END IF
- SELECT outtype
- INTO :li_outtype_in
- FROM u_storage
- Where storageid = :dstorageid;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,调入仓库出仓类型,"+sqlca.SQLErrText
- GOTO ext
- END IF
- //用游标读取明细
- DECLARE cur_outwaermx CURSOR FOR
- SELECT u_outwaremovemx.mtrlwareid,
- u_outwaremovemx.mtrlid,
- u_outwaremovemx.storageid,
- u_outwaremovemx.qty,
- u_outwaremovemx.cost,
- u_outwaremovemx.price,
- u_mtrldef.mtrlcode,
- 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.unit,
- u_outwaremovemx.uqty,
- u_outwaremovemx.rate,
- u_outwaremovemx.mtrlcuscode,
- u_outwaremovemx.location,
- u_outwaremovemx.newlocation,
- u_outwaremovemx.inqty,
- u_outwaremovemx.outqty,
- u_mtrldef.outtype,
- u_outwaremovemx.ifrel,
- u_outwaremovemx.relid,
- u_outwaremovemx.relprintid,
- u_outwaremovemx.relcode
- FROM u_outwaremovemx,u_mtrldef
- WHERE u_outwaremovemx.outwareid = :arg_outwareid AND
- u_outwaremovemx.mtrlid = u_mtrldef.mtrlid
- Order By u_outwaremovemx.printid;
-
- OPEN cur_outwaermx;
- FETCH cur_outwaermx INTO :outwaremx[i].mtrlwareid,:outwaremx[i].mtrlid,
- :outwaremx[i].storageid,:outwaremx[i].qty,
- :outwaremx[i].cost,:outwaremx[i].price,
- :outwaremx[i].mtrlcode,: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].unit,:outwaremx[i].uqty,
- :outwaremx[i].rate,:outwaremx[i].mtrlcuscode,
- :outwaremx[i].Location,:outwaremx[i].newlocation,
- :outwaremx[i].inqty,:outwaremx[i].outqty,:outwaremx[i].outtype_mtrl,
- :outwaremx[i].ifrel,:outwaremx[i].relid,:outwaremx[i].relprintid,:outwaremx[i].relcode;
- DO WHILE sqlca.SQLCode = 0
- i++
- FETCH cur_outwaermx INTO :outwaremx[i].mtrlwareid,:outwaremx[i].mtrlid,
- :outwaremx[i].storageid,:outwaremx[i].qty,
- :outwaremx[i].cost,:outwaremx[i].price,
- :outwaremx[i].mtrlcode,: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].unit,:outwaremx[i].uqty,
- :outwaremx[i].rate,:outwaremx[i].mtrlcuscode,
- :outwaremx[i].Location,:outwaremx[i].newlocation,
- :outwaremx[i].inqty,:outwaremx[i].outqty,:outwaremx[i].outtype_mtrl,
- :outwaremx[i].ifrel,:outwaremx[i].relid,:outwaremx[i].relprintid,:outwaremx[i].relcode;
- 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
- //用游标读取调出条码明细
- If (li_outtype = 2 Or li_outtype_in = 2 Or li_outtype_in = 3 ) And uo_option_barcode_outwaremove_paudit = 0 Or &
- li_outtype = 2 And uo_option_barcode_outwaremove_paudit = 1 THEN
- DECLARE cur_outwaremx_barcode CURSOR FOR
- SELECT u_outwaremx_mx_barcode.barcode,
- u_outwaremx_mx_barcode.qty
- FROM u_outwaremx_mx_barcode
- WHERE u_outwaremx_mx_barcode.outwareid = :arg_outwareid AND
- //u_outwaremx_mx_barcode.scid = 0 AND
- u_outwaremx_mx_barcode.billtype = 50
- Order By u_outwaremx_mx_barcode.barcode;
-
- OPEN cur_outwaremx_barcode;
- FETCH cur_outwaremx_barcode Into :s_mx_barcode[k].barcode,:s_mx_barcode[k].qty;
-
- DO WHILE sqlca.SQLCode = 0
- k++
- FETCH cur_outwaremx_barcode Into :s_mx_barcode[k].barcode,:s_mx_barcode[k].qty;
- LOOP
- CLOSE cur_outwaremx_barcode;
-
- //检验明细是否读入完整
- SELECT count(*) INTO :no_mxcheck_barcode
- FROM u_outwaremx_mx_barcode
- WHERE u_outwaremx_mx_barcode.outwareid = :arg_outwareid
- //AND u_outwaremx_mx_barcode.scid = 0
- And u_outwaremx_mx_barcode.billtype = 50;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,调仓单调出条码明细数量"
- GOTO ext
- END IF
-
- IF k <> (no_mxcheck_barcode+1) THEN
- rslt = 0
- arg_msg = "查询操作失败,调仓单调出条码明细"
- GOTO ext
- END IF
-
- it_mxbt_barcode = k - 1
- END IF
- //调入条码明细
- IF (li_outtype_in = 2 Or li_outtype_in = 3) And uo_option_barcode_outwaremove_paudit = 1 THEN
- DECLARE cur_outwaremx_barcode_in CURSOR FOR
- SELECT u_outwaremx_mx_barcode.barcode,
- u_outwaremx_mx_barcode.qty
- FROM u_outwaremx_mx_barcode
- WHERE u_outwaremx_mx_barcode.outwareid = :arg_outwareid AND
- //u_outwaremx_mx_barcode.scid = 0 AND
- u_outwaremx_mx_barcode.billtype = 53
- Order By u_outwaremx_mx_barcode.barcode;
-
- OPEN cur_outwaremx_barcode_in;
- FETCH cur_outwaremx_barcode_in Into :s_mx_barcode_in[j].barcode,:s_mx_barcode_in[j].qty;
-
- DO WHILE sqlca.SQLCode = 0
- j++
- FETCH cur_outwaremx_barcode_in Into :s_mx_barcode_in[j].barcode,:s_mx_barcode_in[j].qty;
- LOOP
- CLOSE cur_outwaremx_barcode_in;
-
- //检验明细是否读入完整
- SELECT count(*) INTO :no_mxcheck_barcode_in
- FROM u_outwaremx_mx_barcode
- WHERE u_outwaremx_mx_barcode.outwareid = :arg_outwareid
- //AND u_outwaremx_mx_barcode.scid = 0
- And u_outwaremx_mx_barcode.billtype = 53;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,调仓单调入条码明细数量"
- GOTO ext
- END IF
-
- IF j <> (no_mxcheck_barcode_in+1) THEN
- rslt = 0
- arg_msg = "查询操作失败,调仓单调入条码明细"
- GOTO ext
- END IF
-
- it_mxbt_barcode_in = j - 1
- 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 uo_option_barcode_outwaremove_paudit = -1000 THEN
- rslt = 0
- arg_msg = '选项:[204]仓库使用条码流程,仓库调拨单使用先确认扫描后审核流程,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- 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 uo_option_barcode_outwaremove_paudit = 1 THEN
- IF priceflag = 1 THEN
- rslt = 0
- arg_msg = '单据已经确认,不可以修改'
- GOTO ext
- END IF
-
- IF it_mxbt_barcode > 0 THEN
- arg_msg = '单据已扫描条码,不能修改,如果修改请先清除已扫描条码'
- rslt = 0
- GOTO ext
- END IF
- END IF
- 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, boolean arg_ifcommit);//调仓单调出审核
- Int rslt = 1
- Long cnt = 0,i,j,mx_barcode_cnt
- Long rst_outwareid //调拨出仓id
- Long s_scid
- Int li_outtype
- IF uo_option_inout_type = -1000 THEN
- rslt = 0
- arg_msg = '选项:[142]进出仓高级选项,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- IF uo_option_barcode_outwaremove_paudit = -1000 THEN
- rslt = 0
- arg_msg = '选项:[204]仓库使用条码流程,仓库调拨单使用先确认扫描后审核流程,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- uo_outware uo_out
- uo_out = Create uo_outware
- uo_out.commit_transaction = sqlca
- uo_out.if_getid_ture = False
- uo_saletask uo_task
- uo_task = Create uo_saletask
- uo_task.commit_transaction = sqlca
- IF outwareid = 0 THEN
- rslt = 0
- arg_msg = "没有审核对象"
- GOTO ext
- END IF
- SELECT scid,outtype INTO :s_scid,:li_outtype
- FROM u_storage
- Where storageid = :sstorageid;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '查询调出仓库所属分部资料,出仓类型失败,'+sqlca.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- IF uo_option_inout_type = 2 And uo_option_barcode_outwaremove_paudit = 1 THEN
- IF priceflag = 0 THEN
- arg_msg = '单据未确认,不能调出审核'
- rslt = 0
- GOTO ext
- END IF
- END IF
- IF flag = 1 THEN
- rslt = 0
- arg_msg = "单据已经调出审核"
- GOTO ext
- END IF
- FOR i = 1 To it_mxbt
- IF li_outtype = 2 And outwaremx[i].outtype_mtrl = 2 THEN mx_barcode_cnt++
-
- IF outwaremx[i].qty <> outwaremx[i].outqty THEN
- arg_msg = '明细行:'+String(i)+',调出数与调拨数不相符,请检查'
- rslt = 0
- GOTO ext
- END IF
- NEXT
- IF li_outtype = 2 And mx_barcode_cnt > 0 And it_mxbt_barcode = 0 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
- 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
- Decimal ld_ref_cost
- FOR i = 1 To it_mxbt
- ld_ref_cost = 0
- IF p_update_cost(outwaremx[i].mtrlwareid,outwaremx[i].printid,&
- outwaremx[i].mtrlcode,ld_ref_cost,arg_msg,False) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- outwaremx[i].cost = ld_ref_cost
- NEXT
- //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].cost,1,&
- outwaremx[i].mxdscrp,outwaremx[i].printid,arg_msg,0,0,0,0,'',0,0,&
- outwaremx[i].unit,outwaremx[i].uqty,outwaremx[i].rate,'','',0,0,'',0,0,0,0,'','') = 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
- //条码
- IF li_outtype = 2 THEN
- FOR j = 1 To it_mxbt_barcode
- IF uo_out.uof_outbarcode_add(12,s_scid,rst_outwareid,&
- s_mx_barcode[j].barcode,s_mx_barcode[j].qty,arg_msg,False) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- NEXT
- END IF
- //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 uof_noauditingqty_del(outwareid,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- //完成分部需求单
- FOR i = 1 To it_mxbt
- IF outwaremx[i].relid > 0 THEN
- IF uo_task.addmxcmpl(sscid,outwaremx[i].relid,outwaremx[i].relprintid,outwaremx[i].uqty,arg_msg,False) <> 1 THEN
- arg_msg = '行:'+String(i)+','+arg_msg
- rslt = 0
- GOTO ext
- END IF
-
-
- IF uo_task.trycmplsaletask(sscid,outwaremx[i].relid,arg_msg,False) = 0 THEN
- arg_msg = '行:'+String(i)+','+arg_msg
- rslt = 0
- GOTO ext
- END IF
- END IF
- NEXT
- flag = 1
- ext:
- IF rslt = 0 THEN
- ROLLBACK;
- ELSEIF rslt = 1 And arg_ifcommit THEN
- COMMIT;
- END IF
- Destroy uo_out
- Destroy uo_task
- RETURN rslt
- end function
- public function integer c_ds_auditing (ref string arg_msg, boolean arg_ifcommit);
- Long rslt = 1,cnt = 0,i
- Long rst_inwareid //调拨进仓id
- Long o_scid
- Long mx_barcode_cnt
- Int li_outtype_out,li_outtype_in
- 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 d_auditflag = 0 THEN
- rslt = 0
- arg_msg = "单据未调入审核"
- GOTO ext
- END IF
- SELECT outtype
- INTO :li_outtype_out
- FROM u_storage
- Where storageid = :sstorageid;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询调出仓库出仓策略失败,"+sqlca.SQLErrText
- GOTO ext
- END IF
- SELECT outtype
- INTO :li_outtype_in
- FROM u_storage
- Where storageid = :dstorageid;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询调出仓库出仓策略失败,"+sqlca.SQLErrText
- GOTO ext
- END IF
- //限制条码调入撤审清除条码库存id问题
- FOR i = 1 To it_mxbt
- IF li_outtype_in = 2 And outwaremx[i].outtype_mtrl = 2 THEN mx_barcode_cnt++
- NEXT
- IF li_outtype_in = 2 And li_outtype_out = 2 And mx_barcode_cnt > 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 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
- Long ll_scid,ll_mtrlwareid
- //更新条码调出仓的库存id,注释原因:如果开了条码库存配置调整单,找不到调出条码的库存id
- //IF li_outtype_in = 2 And li_outtype_out = 2 And mx_barcode_cnt > 0 THEN
- // FOR i = 1 To it_mxbt_barcode
- // ll_scid = 0
- // ll_mtrlwareid = 0
- // SELECT u_mtrlware.scid,u_mtrlware.mtrlwareid
- // INTO :ll_scid,:ll_mtrlwareid
- // FROM u_mtrlware,u_getbar,u_mtrlware_mx
- // WHERE u_mtrlware.storageid = :sstorageid
- // AND u_mtrlware_mx.barcode = :s_mx_barcode[i].barcode
- // AND u_getbar.getbarid = u_mtrlware_mx.getbarid
- // AND u_mtrlware.mtrlid = u_getbar.mtrlid
- // AND ( u_mtrlware.sptid = u_getbar.cusid AND :li_storagetype_storage = 0 OR
- // u_mtrlware.sptid = 0 AND :li_storagetype_storage = 1 )
- // AND u_mtrlware.status = u_getbar.status
- // AND u_mtrlware.woodcode = u_getbar.woodcode
- // AND u_mtrlware.pcode = u_getbar.pcode
- // AND u_mtrlware.plancode = u_getbar.plancode
- // AND ( u_mtrlware.mtrlcuscode = u_getbar.mtrlcuscode AND :li_storagetype_storage = 0 OR
- // u_mtrlware.mtrlcuscode = '' AND :li_storagetype_storage = 1 )
- // And u_mtrlware.Location = u_getbar.Location Using commit_transaction;
- // IF commit_transaction.SQLCode <> 0 THEN
- // arg_msg = '条码:'+s_mx_barcode[i].barcode+',查询库存资料失败,请检查对应条码单与库存资料,'+commit_transaction.SQLErrText
- // rslt = 0
- // GOTO ext
- // END IF
- // NEXT
- //END IF
- d_auditflag = 0
- ext:
- IF rslt = 0 THEN
- ROLLBACK;
- ELSEIF rslt = 1 And arg_ifcommit THEN
- COMMIT;
- END IF
- Destroy uo_in
- RETURN rslt
- end function
- public function integer c_ss_auditing (ref string arg_msg, boolean arg_ifcommit);Long rslt = 1,cnt = 0,i
- Long rst_outwareid //调拨出仓id
- Long s_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
- uo_saletask uo_task
- uo_task = Create uo_saletask
- uo_task.commit_transaction = sqlca
- If outwareid = 0 Then
- rslt = 0
- arg_msg = "没有撤审对象"
- Goto ext
- End If
- If flag = 0 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 auditingrep = '',
- auditingdate = :null_dt,
- flag = 0
- Where u_outware_move.outwareid = :outwareid
- And flag = 1
- 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 :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,0,arg_msg,False) = 0 Then
- rslt = 0
- Goto ext
- End If
- //增加已开单数
- If uof_noauditingqty_add(arg_msg) = 0 Then
- rslt = 0
- Goto ext
- End If
- //完成分部需求单
- FOR i = 1 To it_mxbt
- IF outwaremx[i].relid > 0 THEN
- IF uo_task.addmxcmpl(sscid,outwaremx[i].relid,outwaremx[i].relprintid,0 - outwaremx[i].uqty,arg_msg,False) <> 1 THEN
- arg_msg = '行:'+String(i)+','+arg_msg
- rslt = 0
- GOTO ext
- END IF
-
-
- IF uo_task.trycmplsaletask(sscid,outwaremx[i].relid,arg_msg,False) = 0 THEN
- arg_msg = '行:'+String(i)+','+arg_msg
- rslt = 0
- GOTO ext
- END IF
- END IF
- NEXT
- flag = 0
- ext:
- If rslt = 0 Then
- Rollback;
- ElseIf rslt = 1 And arg_ifcommit Then
- Commit;
- End If
- Destroy uo_out
- Destroy uo_task
- Return rslt
- end function
- public function integer ds_auditing (string arg_auditingrep, ref string arg_msg, boolean arg_ifcommit);//调仓单调入审核
- Int rslt = 1
- Long cnt = 0,i,j
- Long rst_inwareid //调拨进仓id
- Long o_scid
- Int li_outtype
- Long mx_barcode_cnt
- 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 flag = 0 THEN
- rslt = 0
- arg_msg = "单据还未调出审核"
- GOTO ext
- END IF
- IF d_auditflag = 1 THEN
- rslt = 0
- arg_msg = "单据已经调入审核"
- GOTO ext
- END IF
- SELECT scid,outtype INTO :o_scid,:li_outtype
- FROM u_storage
- Where storageid = :dstorageid;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '查询调入仓库所属分部资料,出仓类型失败,'+sqlca.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- FOR i = 1 To it_mxbt
- IF outwaremx[i].inqty <> outwaremx[i].outqty THEN
- arg_msg = '明细行:'+String(i)+',调出数与调入数不相符,请检查'
- rslt = 0
- GOTO ext
- END IF
- NEXT
- 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
- 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
- //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 = indate
- uo_in.inrep = outrep
- uo_in.part = outwarecode
- uo_in.dscrp = dscrp
- uo_in.storageid = dstorageid
- uo_in.sptname = '调拨进仓'
- Decimal ld_uprice
- FOR i = 1 To it_mxbt
-
- ld_uprice = 0
- ld_uprice = outwaremx[i].price * outwaremx[i].rate
-
-
- IF uo_in.acceptmx(outwaremx[i].printid,&
- outwaremx[i].mtrlid,&
- outwaremx[i].mtrlcode,&
- outwaremx[i].plancode,&
- outwaremx[i].status,&
- outwaremx[i].uqty,&
- ld_uprice,&
- 1,&
- outwaremx[i].mxdscrp,&
- arg_msg,&
- 0,0,0,outwaremx[i].woodcode,&
- outwaremx[i].pcode,&
- outwaremx[i].sptid,&
- outwaremx[i].unit,&
- outwaremx[i].rate,&
- outwaremx[i].qty,0,0,'','',0,0,&
- outwaremx[i].mtrlcuscode,&
- outwaremx[i].newlocation,&
- outwaremx[i].uqty,&
- 0) = 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
- //条码
- //条码
- IF li_outtype = 2 Or li_outtype = 3 THEN
- IF uo_option_barcode_outwaremove_paudit = 0 THEN
- FOR j = 1 To it_mxbt_barcode
- IF uo_in.uof_inbarcode_add(12,o_scid,rst_inwareid,0,&
- s_mx_barcode[j].barcode,s_mx_barcode[j].qty,arg_msg,False) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- NEXT
- ELSE
- FOR j = 1 To it_mxbt_barcode_in
- IF uo_in.uof_inbarcode_add(12,o_scid,rst_inwareid,0,&
- s_mx_barcode_in[j].barcode,s_mx_barcode_in[j].qty,arg_msg,False) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- NEXT
- END IF
- END IF
- //
- //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
- IF uof_update_waredate(False,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- d_auditflag = 1
- ext:
- IF rslt = 0 THEN
- ROLLBACK;
- ELSEIF rslt = 1 And arg_ifcommit THEN
- COMMIT;
- END IF
- Destroy uo_in
- RETURN rslt
- end function
- public function integer cancel (long arg_outwareid, ref string arg_msg, boolean arg_ifcommit);//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 priceflag = 1 Then
- rslt = 0
- arG_MSG = "单据已经确认,不可以删除"
- Goto ext
- End If
- If flag = 1 Then
- rslt = 0
- arG_MSG = "单据已经调出审核,不可以删除"
- Goto ext
- End If
- If d_auditflag = 1 Then
- rslt = 0
- arG_MSG = "单据已经调入审核,不可以删除"
- Goto ext
- End If
- //更新库存已开单数(减)
- If uof_noauditingqty_del(arg_outwareid,arG_MSG) = 0 Then
- rslt = 0
- Goto ext
- End If
- Delete From u_outwaremx_mx_barcode
- Where u_outwaremx_mx_barcode.outwareid = :arg_outwareid
- And u_outwaremx_mx_barcode.scid = 0
- And u_outwaremx_mx_barcode.billtype = 50;
- If sqlca.SQLCode <> 0 Then
- rslt = 0
- arG_MSG = "删除单据条码明细操作失败"+"~n"+sqlca.SQLErrText
- Goto ext
- End If
- Delete From u_outwaremx_mx_barcode
- Where u_outwaremx_mx_barcode.outwareid = :arg_outwareid
- And u_outwaremx_mx_barcode.scid = 0
- And u_outwaremx_mx_barcode.billtype = 53;
- If sqlca.SQLCode <> 0 Then
- rslt = 0
- arG_MSG = "删除单据条码明细操作失败"+"~n"+sqlca.SQLErrText
- 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:
- If rslt = 0 Then
- Rollback;
- ElseIf rslt = 1 And arg_ifcommit Then
- Commit;
- End If
- p_reset()
- Return (rslt)
- end function
- public function integer save (ref string arg_msg, boolean arg_ifcommit);Integer rslt = 1
- Long cnt = 0,i
- DateTime server_datetime
- Long ls_newid
- Decimal ld_inqty,ld_outqty
- Int li_outtype_storage_s
- If uo_option_barcode_outwaremove_paudit = -1000 Then
- rslt = 0
- arg_msg = '选项:[204]仓库使用条码流程,仓库调拨单使用先确认扫描后审核流程,读取初始默认值失败,操作取消!'
- Goto ext
- End If
- If IsNull(dscrp) Then dscrp = ''
- If IsNull(outrep) Then outrep = ''
- If IsNull(relcode) Then relcode = ''
- If IsNull(ifauto) Then ifauto = 0
- 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 f_rst_storage_outtype(sstorageid,li_outtype_storage_s) = 0 Then
- arg_msg = '查询调出仓库出仓策略失败,请检查'
- rslt = 0
- Goto ext
- End If
- If f_check_inoutdate(sstorageid,outdate,True,arg_msg) = 0 Then
- rslt = 0
- Goto ext
- End If
- If f_check_inoutdate(dstorageid,outdate,True,arg_msg) = 0 Then
- rslt = 0
- 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(0,"u_outware_move","outwareid",arg_msg,True,id_sqlca)
- If ls_newid <= 0 Then
- rslt = 0
- Goto ext
- End If
-
-
- outwarecode = getid(0,"MV",Date(server_datetime),if_getid_ture,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,
- indate,
- outrep,
- dscrp,
- relcode,
- ifauto)
- Values ( :ls_newid,
- :outwarecode,
- :sstorageid,
- :dstorageid,
- getdate(),
- :publ_operator,
- :flag,
- :outdate,
- :indate,
- :outrep,
- :dscrp,
- :relcode,
- :ifauto) ;
- If sqlca.SQLCode <> 0 Then
- rslt = 0
- arg_msg = "因网络或其它原因导致插入操作失败"+"~n"+sqlca.SQLErrText
- Goto ext
- End If
-
- outwareid = ls_newid
-
- For i = 1 To it_mxbt
- If uo_option_barcode_outwaremove_paudit = 0 Then
- ld_inqty = outwaremx[i].qty
- ld_outqty = outwaremx[i].qty
- Else
- If li_outtype_storage_s = 2 And outwaremx[i].outtype_mtrl = 2 Then
- ld_inqty = 0
- ld_outqty = 0
- Else
- ld_inqty = outwaremx[i].qty
- ld_outqty = outwaremx[i].qty
- End If
- End If
-
- Insert Into u_outwaremovemx
- (outwareid,
- mtrlwareid,
- mtrlid,
- storageid,
- qty,
- cost,
- price,
- printid,
- mxdscrp,
- scid,
- status,
- plancode,
- dxflag,
- sptid,
- woodcode,
- pcode,
- unit,
- uqty,
- rate,
- mtrlcuscode,
- location,
- newlocation,
- inqty,
- outqty,
- ifrel,
- relid,
- relprintid,
- relcode)
- Values (:ls_newid,
- :outwaremx[i].mtrlwareid,
- :outwaremx[i].mtrlid,
- :outwaremx[i].storageid,
- :outwaremx[i].qty,
- :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].unit,
- :outwaremx[i].uqty,
- :outwaremx[i].rate,
- :outwaremx[i].mtrlcuscode,
- :outwaremx[i].location,
- :outwaremx[i].newlocation,
- :ld_inqty,
- :ld_outqty,
- :outwaremx[i].ifrel,
- :outwaremx[i].relid,
- :outwaremx[i].relprintid,
- :outwaremx[i].relcode);
- If sqlca.SQLCode <> 0 Then
- outwareid = 0 //还原outwareid
- rslt = 0
- arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+sqlca.SQLErrText
- Goto ext
- End If
- Next
-
- //更新库存已开单数
- If uof_noauditingqty_add(arg_msg) = 0 Then
- rslt = 0
- Goto ext
- End If
-
- Else //////////////////////////////////////////////// //更新
- Update u_outware_move
- Set outdate = :outdate,
- indate = :indate,
- outrep = :outrep,
- dscrp = :dscrp,
- sstorageid = :sstorageid,
- dstorageid = :dstorageid,
- relcode = :relcode,
- moddate = getdate(),
- modrep = :publ_operator
- 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
-
- //更新库存已开单数(减)
- If uof_noauditingqty_del(outwareid,arg_msg) = 0 Then
- rslt = 0
- 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
- If uo_option_barcode_outwaremove_paudit = 0 Then
- ld_inqty = outwaremx[i].qty
- ld_outqty = outwaremx[i].qty
- Else
- If li_outtype_storage_s = 2 And outwaremx[i].outtype_mtrl = 2 Then
- ld_inqty = 0
- ld_outqty = 0
- Else
- ld_inqty = outwaremx[i].qty
- ld_outqty = outwaremx[i].qty
- End If
- End If
-
- Insert Into u_outwaremovemx
- ( outwareid,
- mtrlwareid,
- mtrlid,
- storageid,
- qty,
- cost,
- price,
- printid,
- mxdscrp,
- scid,
- status,
- plancode,
- dxflag,
- sptid,
- woodcode,
- pcode,
- unit,
- uqty,
- rate,
- mtrlcuscode,
- location,
- newlocation,
- inqty,
- outqty,
- ifrel,
- relid,
- relprintid,
- relcode)
- Values (:outwareid,
- :outwaremx[i].mtrlwareid,
- :outwaremx[i].mtrlid,
- :outwaremx[i].storageid,
- :outwaremx[i].qty,
- :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].unit,
- :outwaremx[i].uqty,
- :outwaremx[i].rate,
- :outwaremx[i].mtrlcuscode,
- :outwaremx[i].location,
- :outwaremx[i].newlocation,
- :ld_inqty,
- :ld_outqty,
- :outwaremx[i].ifrel,
- :outwaremx[i].relid,
- :outwaremx[i].relprintid,
- :outwaremx[i].relcode);
-
- If sqlca.SQLCode <> 0 Then
- rslt = 0
- arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+sqlca.SQLErrText
- Goto ext
- End If
- Next
-
- If uof_noauditingqty_add(arg_msg) = 0 Then
- rslt = 0
- Goto ext
- End If
-
- End If
- it_newbegin = False
- it_updatebegin = False
- ext:
- If rslt = 0 Then
- Rollback;
- p_clearmx()
- ElseIf arg_ifcommit And rslt = 1 Then
- Commit;
- End If
- Return(rslt)
- end function
- public function integer p_update_cost (long arg_mtrlwareid, long arg_printid, string arg_mtrlcode, ref decimal arg_ref_cost, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
- Decimal ld_cost
- Long ll_storagescid
- SELECT scid INTO :ll_storagescid
- FROM u_storage
- Where storageid = :sstorageid;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '查询仓库分部失败'+ sqlca.SQLErrText
- GOTO ext
- END IF
- SELECT cost INTO :ld_cost
- FROM u_mtrlware
- WHERE storageid = :sstorageid
- AND mtrlwareid = :arg_mtrlwareid
- AND scid = :ll_storagescid;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '查询行:'+string(arg_printid)+',物料:'+arg_mtrlcode+'库存成本价失败,'+sqlca.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- arg_ref_cost = ld_cost
- UPDATE u_outwaremovemx
- SET cost = :ld_cost,
- price = :ld_cost
- WHERE outwareid = :outwareid
- and scid = :ll_storagescid
- AND mtrlwareid = :arg_mtrlwareid;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '查询行:'+string(arg_printid)+',物料:'+arg_mtrlcode+'出仓成本价失败,'+sqlca.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- ext:
- IF rslt = 0 THEN
- ROLLBACK;
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT;
- END IF
- RETURN rslt
- end function
- public function integer uof_update_waredate (boolean arg_ifcommit, ref string arg_msg);Int rslt = 1
- DateTime ld_waredate,ld_auditingdate,ld_waradate_mx
- String ls_auditdate,ls_waredate
- Long i
- Long ll_mtrlid,ll_sptid,ll_mtrlwareid
- String ls_status,ls_woodcode ,ls_pcode,ls_plancode
- String ls_mtrlcuscode,ls_location
- DateTime ld_waredate_max
- Long o_scid,s_scid
- Int li_ifout_notfind_ware,li_o_storagetype
- Int li_ifpack,li_ifpackpro
- Select d_Auditingdate Into :ld_auditingdate
- From u_outware_move
- Where outwareid = :outwareid;
- If sqlca.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '查询单据审核时间失败,'+sqlca.SQLErrText
- Goto ext
- End If
- ls_auditdate = String(ld_auditingdate,'yyyy-mm-dd hh:mm')
- Select scid,storagetype Into :o_scid,:li_o_storagetype
- From u_storage
- Where storageid = :dstorageid;
- If sqlca.SQLCode <> 0 Then
- arg_msg = '查询调入仓库所属分部资料失败'
- rslt = 0
- 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
- For i = 1 To it_mxbt
- If outwaremx[i].uqty = 0 Or outwaremx[i].qty = 0 Then Continue
-
- ll_mtrlid = outwaremx[i].mtrlid
- ll_sptid = outwaremx[i].sptid
- ls_status = outwaremx[i].status
- ls_woodcode = outwaremx[i].woodcode
- ls_pcode = outwaremx[i].pcode
- ls_plancode = outwaremx[i].plancode
- ls_mtrlcuscode = outwaremx[i].mtrlcuscode
- ls_location = outwaremx[i].newlocation
- ll_mtrlwareid = outwaremx[i].mtrlwareid
-
-
-
- Select waredate Into :ld_waredate
- From u_mtrlware
- Where scid = :s_scid
- And mtrlwareid = :ll_mtrlwareid;
- If sqlca.SQLCode = -1 Then
- rslt = 0
- arg_msg = '明细行:'+String(i)+',查询调出库存最近进仓日期失败,'+sqlca.SQLErrText
- Goto ext
- ElseIf sqlca.SQLCode = 100 Then
- li_ifout_notfind_ware = 1
- End If
-
- Select ifpack,ifpackpro
- Into :li_ifpack,:li_ifpackpro
- From u_mtrldef
- Where mtrlid = :ll_mtrlid;
- If sqlca.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '明细行:'+String(i)+',查询物料属性失败,'+sqlca.SQLErrText
- Goto ext
- End If
-
- If li_o_storagetype = 1 and li_ifpack <> 2 and li_ifpackpro <> 2 and li_ifpackpro <> 4 Then
- ll_sptid = 0
- ls_mtrlcuscode = ''
- End If
-
- Select waredate Into :ld_waradate_mx
- From u_mtrlware
- Where scid = :o_scid
- And storageid = :dstorageid
- And mtrlid = :ll_mtrlid
- And sptid = :ll_sptid
- And status = :ls_status
- And woodcode = :ls_woodcode
- And pcode = :ls_pcode
- And plancode = :ls_plancode
- And mtrlcuscode = :ls_mtrlcuscode
- And Location = :ls_location;
- If sqlca.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '明细行:'+String(i)+',查询调入新库存最近进仓日期失败,错误:'+String(sqlca.SQLCode)+','+sqlca.SQLErrText
- Goto ext
- End If
-
- ls_waredate = String(ld_waradate_mx,'yyyy-mm-dd hh:mm')
-
- If ls_auditdate = ls_waredate Or li_ifout_notfind_ware = 1 Then
- Update u_mtrlware
- Set waredate = :ld_waredate
- Where scid = :o_scid
- And storageid = :dstorageid
- And mtrlid = :ll_mtrlid
- And sptid = :ll_sptid
- And status = :ls_status
- And woodcode = :ls_woodcode
- And pcode = :ls_pcode
- And plancode = :ls_plancode
- And mtrlcuscode = :ls_mtrlcuscode
- And Location = :ls_location;
- If sqlca.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '明细行:'+String(i)+',更新调入库存最近进仓日期失败,'+sqlca.SQLErrText
- Goto ext
- End If
-
- End If
- Next
- ext:
- If rslt = 0 Then
- Rollback;
- ElseIf rslt = 1 And arg_ifcommit Then
- Commit;
- End If
- Return rslt
- end function
- public function integer p_auditing (string arg_auditingrep, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
- IF outwareid = 0 THEN
- rslt = 0
- arg_msg = "没有审核对象"
- GOTO ext
- END IF
- IF priceflag = 1 THEN
- arg_msg = '单据已确认,请检查'
- rslt = 0
- GOTO ext
- END IF
- UPDATE u_outware_move
- SET priceemp = :arg_auditingrep,
- pricedate = getdate(),
- priceflag = 1
- WHERE u_outware_move.outwareid = :outwareid
- AND priceflag = 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
- priceflag = 1
- ext:
- IF rslt = 0 THEN
- ROLLBACK;
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT;
- END IF
- RETURN rslt
- end function
- public function integer c_p_auditing (ref string arg_msg, boolean arg_ifcommit);Long rslt = 1
- DateTime null_dt
- SetNull(null_dt)
- IF outwareid = 0 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 priceemp = '',
- pricedate = :null_dt,
- priceflag = 0
- WHERE u_outware_move.outwareid = :outwareid
- AND priceflag = 1
- 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
- DELETE FROM u_outwaremx_mx_barcode
- WHERE u_outwaremx_mx_barcode.outwareid = :outwareid
- AND u_outwaremx_mx_barcode.scid = 0
- AND u_outwaremx_mx_barcode.billtype = 50;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arG_MSG = "删除单据条码明细操作失败"+"~n"+sqlca.SQLErrText
- GOTO ext
- END IF
- DELETE FROM u_outwaremx_mx_barcode
- WHERE u_outwaremx_mx_barcode.outwareid = :outwareid
- AND u_outwaremx_mx_barcode.scid = 0
- AND u_outwaremx_mx_barcode.billtype = 53;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arG_MSG = "删除单据条码明细操作失败"+"~n"+sqlca.SQLErrText
- GOTO ext
- END IF
- priceflag = 0
- ext:
- IF rslt = 0 THEN
- ROLLBACK;
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT;
- END IF
- RETURN rslt
- end function
- public function integer uof_set_qty_equal_bqty (long arg_outwareid, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
- Int li_ref_outtype
- IF arg_outwareid <= 0 THEN
- arg_msg = '错误的单据id'
- rslt = 0
- GOTO ext
- END IF
- IF p_getinfo(arg_outwareid,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF f_rst_storage_outtype(sstorageid,li_ref_outtype) = 0 THEN
- arg_msg = '查询仓库出仓策略失败,请检查仓库资料'
- rslt = 0
- GOTO ext
- END IF
- IF li_ref_outtype <> 2 THEN
- arg_msg = '仓库出仓策略不是使用条码出仓,操作取消,请检查仓库资料'
- rslt = 0
- GOTO ext
- END IF
- IF priceflag = 0 THEN
- arg_msg = '单据未确认,操作取消'
- rslt = 0
- GOTO ext
- END IF
- IF flag = 1 THEN
- arg_msg = '单据已仓审,操作取消'
- rslt = 0
- GOTO ext
- END IF
- UPDATE u_outwaremovemx
- SET u_outwaremovemx.uqty = u_outwaremovemx.outqty,
- u_outwaremovemx.qty = u_outwaremovemx.outqty
- FROM u_outwaremovemx,u_mtrldef
- WHERE u_outwaremovemx.mtrlid = u_mtrldef.mtrlid
- AND u_outwaremovemx.outwareid = :arg_outwareid
- AND u_mtrldef.outtype = 2;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '更新明细条码调拨数到明细调出数失败,'+sqlca.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- ext:
- IF rslt = 0 THEN
- ROLLBACK;
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT;
- END IF
- RETURN rslt
- end function
- public function integer uof_mod_indate (long arg_outwareid, datetime arg_indate, ref string arg_msg);Int rslt = 1
- rslt = p_getinfo(arg_outwareid,arg_msg)
- IF rslt = 0 THEN GOTO ext
- IF flag = 0 THEN
- rslt = 0
- arg_msg = '单据未调出审核,不可以操作'
- GOTO ext
- END IF
- IF d_auditflag = 1 THEN
- rslt = 0
- arg_msg = '单据已经调入审核,不可以操作'
- GOTO ext
- END IF
- IF Date(arg_indate) < Date(outdate) THEN
- arg_msg = '不合理调出日期,调出日期大于调入日期'
- rslt = 0
- GOTO ext
- END IF
- UPDATE u_outware_move
- SET indate = :arg_indate
- Where u_outware_move.outwareid = :arg_outwareid;
- IF sqlca.SQLCode <> 0 THEN
- ROLLBACK ;
- rslt = 0
- arg_msg = "因网络或其它原因导致更新调入日期操作失败"+"~n"+sqlca.SQLErrText
- GOTO ext
- END IF
- COMMIT;
- ext:
- Return (rslt)
- end function
- public function integer uof_noauditingqty_add (ref string arg_msg);If uo_option_noauditingqty_mode = 0 Then Return 1
- Int rslt = 1
- Long i
- For i = 1 To it_mxbt
-
- Update u_mtrlware
- Set noauditingqty = noauditingqty + :outwaremx[i].qty,
- noauditinguqty = noauditingqty + :outwaremx[i].uqty
- Where scid = :outwaremx[i].scid
- And mtrlwareid = :outwaremx[i].mtrlwareid;
- If sqlca.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '物料:'+String(outwaremx[i].mtrlcode)+',更新明细库存已开单数失败 '+sqlca.SQLErrText
- Goto ext
- End If
-
- Next
- ext:
- Return rslt
- end function
- public function integer uof_noauditingqty_del (long arg_outwareid, ref string arg_msg);If uo_option_noauditingqty_mode = 0 Then Return 1
- Int rslt = 1
- Long i,ll_i
- i = 1
- s_outwaremx arg_s_mx[]
- Declare cur_outwaremx Cursor For
- Select u_outwaremovemx.scid,
- u_outwaremovemx.mtrlwareid,
- u_outwaremovemx.qty,
- u_outwaremovemx.uqty,
- u_mtrldef.mtrlcode
- From u_outwaremovemx,u_mtrldef
- Where u_outwaremovemx.outwareid = :arg_outwareid And
- u_outwaremovemx.mtrlid = u_mtrldef.mtrlid
- Order By u_outwaremovemx.printid;
-
- Open cur_outwaremx;
- Fetch cur_outwaremx Into :arg_s_mx[i].scid,:arg_s_mx[i].mtrlwareid,
- :arg_s_mx[i].qty,:arg_s_mx[i].uqty,:arg_s_mx[i].mtrlcode;
- Do While sqlca.SQLCode = 0
- i++
- Fetch cur_outwaremx Into :arg_s_mx[i].scid,:arg_s_mx[i].mtrlwareid,
- :arg_s_mx[i].qty,:arg_s_mx[i].uqty,:arg_s_mx[i].mtrlcode;
- Loop
- Close cur_outwaremx;
- For ll_i = 1 To i - 1
-
- Update u_mtrlware
- Set noauditingqty = noauditingqty - :arg_s_mx[ll_i].qty,
- noauditinguqty = noauditingqty - :arg_s_mx[ll_i].uqty
- Where scid = :arg_s_mx[ll_i].scid
- And mtrlwareid = :arg_s_mx[ll_i].mtrlwareid;
- If sqlca.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '物料:'+String(arg_s_mx[ll_i].mtrlcode)+',更新明细库存已开单数失败 '+sqlca.SQLErrText
- Goto ext
- End If
-
- Next
- ext:
- Return rslt
- end function
- public function integer acceptmx (long arg_mtrlwareid, decimal arg_qty, decimal arg_price, ref string arg_msg, long arg_printid, string arg_mxdscrp, string arg_unit, decimal arg_uqty, decimal arg_rate, string arg_newlocation, integer arg_ifrel, long arg_relid, long arg_relprintid, string arg_relcode);Long rslt = 1,cnt = 0,ls_i,j
- Long i_mtrlid,i_storageid,i_scid
- String i_mtrlcode,i_status,i_plancode,i_woodcode,i_pcode
- String ls_mtrlcuscode,ls_location
- Decimal i_cost
- Int i_dxflag
- Long i_sptid
- Decimal i_notauditqty,i_allouseqty
- String ls_unit
- String ls_relcode
- Decimal lde_noconqty, ld_saletqty_task, ld_consignedqty_task, lde_mx_qty, lde_notauditqty
- Long ll_mtrlid_task
- String ls_status_task, ls_woodcode_task, ls_pcode_task
- Int li_status_ck, li_woodcode_ck, li_pcode_ck
- IF uo_option_barcodelocation_use_inwaremx_location = -1000 THEN
- rslt = 0
- arg_msg = '选项:[287]条码进仓仓位使用进仓单扫描仓位,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- 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_unit) THEN arg_unit = ''
- IF IsNull(arg_printid) THEN arg_printid = 0
- IF IsNull(arg_price) THEN arg_price = 0
- IF IsNull(arg_uqty) THEN arg_uqty = 0
- IF IsNull(arg_rate) THEN arg_rate = 0
- IF IsNull(arg_newlocation) THEN arg_newlocation = ''
- IF IsNull(arg_ifrel) THEN arg_ifrel = 0
- IF IsNull(arg_relid) THEN arg_relid = 0
- IF IsNull(arg_relprintid) THEN arg_relprintid = 0
- IF IsNull(arg_relcode) THEN arg_relcode = ''
- IF arg_mtrlwareid = 0 Or arg_qty = 0 THEN // 如果出仓数量为 0,或物料编号为空,则不作任何处理
- rslt = 1
- GOTO ext
- END IF
- IF arg_uqty = 0 And arg_rate = 0 THEN
- rslt = 1
- GOTO ext
- END IF
- IF arg_uqty = 0 THEN
- arg_rate = 1
- ELSE
- arg_rate = arg_qty / arg_uqty
- 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,
- u_mtrlware.noauditingqty,
- u_mtrlware.noallocqty,
- u_mtrldef.unit,
- u_mtrlware.mtrlcuscode,
- u_mtrlware.location
- 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,
- :ls_unit,
- :ls_mtrlcuscode,
- :ls_location
- FROM u_mtrlware ,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 = "查询操作失败,库存编号(仓库调拨单)错误,仓库:"+String(sstorageid)+'库存:'+String(arg_mtrlwareid)+',~n'+sqlca.SQLErrText
- GOTO ext
- END IF
- IF IsNull(i_cost) THEN i_cost = 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_woodcode) THEN i_woodcode = ''
- IF IsNull(i_pcode) THEN i_pcode = ''
- 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(ls_mtrlcuscode) THEN ls_mtrlcuscode = ''
- IF IsNull(ls_location) THEN ls_location = ''
- //IF ls_unit <> arg_unit AND arg_rate = 1 THEN
- // arg_msg = '行:'+String(arg_printid)+',物料库存单位与采购单位不同,但转换率为1,请检查'
- // rslt = 0
- // GOTO ext
- //END IF
- IF ls_unit = arg_unit And arg_rate <> 1 THEN
- arg_msg = '行:'+String(arg_printid)+',物料库存单位与采购单位相同,但转换率不为1,请检查'
- rslt = 0
- GOTO ext
- END IF
- IF arg_price * arg_rate < 0 THEN
- rslt = 0
- arg_msg = '行:'+String(arg_printid)+",单价错误"
- GOTO ext
- END IF
- //*****检查大于未开数不可以开单
- IF flag = 0 THEN
- Int ls_noallocflag
-
- 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
-
- Decimal ol_mtrl_qty = 0
- IF ls_noallocflag = 1 THEN
-
- IF it_updatebegin THEN
- SELECT sum(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 IsNull(ol_mtrl_qty) THEN ol_mtrl_qty = 0
-
- 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
- FOR ls_i = 1 To it_mxbt
- IF outwaremx[ls_i].mtrlwareid = arg_mtrlwareid And &
- outwaremx[ls_i].newlocation <> arg_newlocation THEN
- rslt = 0
- arg_msg = '第'+String(arg_printid)+'行存在相同的库存,但调入仓位下相同,不能在同1张单建立,请检查'
- GOTO ext
- END IF
-
- IF outwaremx[ls_i].mtrlwareid = arg_mtrlwareid THEN
- outwaremx[ls_i].qty = outwaremx[ls_i].qty + arg_qty
- outwaremx[ls_i].uqty = outwaremx[ls_i].uqty + arg_uqty
- rslt = 1
- GOTO ext
- END IF
- NEXT
- IF arg_ifrel = 0 THEN
- arg_relid = 0
- arg_relprintid = 0
- arg_relcode = ''
- ELSE
- IF arg_relid = 0 THEN
- rslt = 0
- arg_msg = '第'+String(arg_printid)+'行,请选择相应分部需求单'
- GOTO ext
- END IF
-
- SELECT u_saletask.taskcode,
- u_saletaskmx.saleqty - u_saletaskmx.consignedqty ,
- u_saletaskmx.mtrlid,
- u_saletaskmx.status,
- u_saletaskmx.woodcode,
- u_saletaskmx.pcode,
- u_saletaskmx.saleqty,
- u_saletaskmx.consignedqty
- INTO :ls_relcode,
- :lde_noconqty,
- :ll_mtrlid_task,
- :ls_status_task,
- :ls_woodcode_task,
- :ls_pcode_task,
- :ld_saletqty_task,
- :ld_consignedqty_task
- FROM u_saletaskmx,u_saletask
- WHERE u_saletaskmx.taskid = :arg_relid
- AND u_saletaskmx.scid = :i_scid
- AND u_saletaskmx.scid = u_saletask.scid
- AND u_saletaskmx.printid = :arg_relprintid
- And u_saletaskmx.taskid = u_saletask.taskid ;
-
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '查询分部需求单是否有物料:'+i_mtrlcode+'失败'
- rslt = 0
- GOTO ext
- END IF
-
- IF ll_mtrlid_task <> i_mtrlid THEN
- arg_msg = '第'+String(arg_printid)+'行,分部需求单:'+ls_relcode+',产品:'+i_mtrlcode+' 与库存信息(物料id)不匹配,不允许保存,请检查相关分部需求单与库存信息'
- rslt = 0
- GOTO ext
- END IF
-
- SELECT Top 1 CASE when ltrim(rtrim(:i_status)) = ltrim(rtrim(:ls_status_task)) THEN 0 ELSE 1 END,
- CASE when ltrim(rtrim(:i_woodcode)) = ltrim(rtrim(:ls_woodcode_task)) THEN 0 ELSE 1 END,
- CASE when ltrim(rtrim(:i_pcode)) = ltrim(rtrim(:ls_pcode_task)) THEN 0 ELSE 1 END
- Into :li_status_ck,:li_woodcode_ck,:li_pcode_ck
- From u_user Using sqlca;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '第'+String(arg_printid)+'行,分部需求单:'+ls_relcode+',产品:'+i_mtrlcode+',3个配置信息与库存3个配置信息是否相同失败,'+sqlca.SQLErrText
- rslt = 0
- GOTO ext
- END IF
-
- IF li_status_ck + li_woodcode_ck + li_pcode_ck > 0 THEN
- arg_msg = '第'+String(arg_printid)+'行,分部需求单:'+ls_relcode+',产品:'+i_mtrlcode+' 与库存信息不匹配,不允许保存,请检查相关分部需求单与库存信息'
- rslt = 0
- GOTO ext
- END IF
-
- lde_mx_qty = 0
- FOR ls_i = 1 To it_mxbt
- IF i_mtrlid = outwaremx[ls_i].mtrlid And &
- arg_relid = outwaremx[ls_i].relid And &
- arg_relprintid = outwaremx[ls_i].relprintid And &
- i_status = outwaremx[ls_i].status And &
- i_woodcode = outwaremx[ls_i].woodcode And &
- i_pcode = outwaremx[ls_i].pcode THEN
- lde_mx_qty = lde_mx_qty + outwaremx[ls_i].qty
- END IF
- NEXT
-
- lde_mx_qty = lde_mx_qty + arg_qty
-
-
- //查询相关订单已开发货单未审核数量
- SELECT isnull(sum(qty),0)
- INTO :lde_notauditqty
- FROM u_outwaremovemx,u_outware_move
- WHERE u_outwaremovemx.relid = :arg_relid
- AND u_outwaremovemx.relprintid = :arg_relprintid
- AND u_outware_move.flag = 0
- AND u_outwaremovemx.outwareid = u_outware_move.outwareid
- AND u_outware_move.outwareid <> :outwareid
- Using sqlca;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '查询分部需求单:'+ls_relcode+'产品:'+i_mtrlcode+'已开单未审核数量失败'
- rslt = 0
- GOTO ext
- END IF
-
- IF lde_notauditqty + lde_mx_qty > lde_noconqty THEN
- arg_msg = '分部需求单:'+ls_relcode+' 产品:'+i_mtrlcode+'未完成数:'+String(lde_noconqty,'#,##0.##########')+',已开单未审核数:'+String(lde_notauditqty,'#,##0.##########')+'不能再开单:'+String(lde_mx_qty,'#,##0.##########')
- rslt = 0
- GOTO ext
- END IF
-
-
- END IF
- //***********************************************
- //yyx20150428
- IF uo_option_barcodelocation_use_inwaremx_location = 1 THEN
- IF it_mxbt = 0 THEN
- il_newlocation_cnt = 1
- ELSE
- FOR j = 1 To it_mxbt
- IF trim(arg_newlocation) <> trim(outwaremx[j].newlocation) THEN
- il_newlocation_cnt++
- END IF
- NEXT
- END IF
- if il_newlocation_cnt <> 1 then
- arg_msg = '系统开启了[287]条码进仓仓位使用进仓单扫描仓位 系统选项,调拨明细的新仓位多于1个,不能保存单据。~n'
- arg_msg += '如果调拨明细的新仓位多于1个,请分开建立调拨单。~n'
- rslt = 0
- goto ext
- 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].unit = arg_unit
- outwaremx[it_mxbt].uqty = arg_uqty
- outwaremx[it_mxbt].rate = arg_rate
- outwaremx[it_mxbt].storageid = i_storageid
- outwaremx[it_mxbt].cost = i_cost
- 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].mtrlcuscode = ls_mtrlcuscode
- outwaremx[it_mxbt].Location = ls_location
- outwaremx[it_mxbt].newlocation = arg_newlocation
- outwaremx[it_mxbt].ifrel = arg_ifrel
- outwaremx[it_mxbt].relid = arg_relid
- outwaremx[it_mxbt].relprintid = arg_relprintid
- outwaremx[it_mxbt].relcode = arg_relcode
- ext:
- IF rslt = 0 THEN p_clearmx()
- 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
- event constructor;String str_optionvalue,arg_msg
- f_get_sys_option_value('204',str_optionvalue,arg_msg)
- uo_option_barcode_outwaremove_paudit = Long(str_optionvalue)
- f_get_sys_option_value('142',str_optionvalue,arg_msg)
- uo_option_inout_type = Long(str_optionvalue)
- f_get_sys_option_value('390',str_optionvalue,arg_msg)
- uo_option_noauditingqty_mode = Long(str_optionvalue)
- f_get_sys_option_value('287',str_optionvalue,arg_msg)
- uo_option_barcodelocation_use_inwaremx_location = Long(str_optionvalue)
- end event
|