1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782 |
- $PBExportHeader$uo_outware_scll.sru
- forward
- global type uo_outware_scll from uo_outware
- end type
- end forward
- global type uo_outware_scll from uo_outware
- end type
- global uo_outware_scll uo_outware_scll
- type variables
- Int uo_option_wkpmtrlware
- Int uo_option_inware_sc_location
- int uo_option_outware_scll_new_cj_mtrlware
- int uo_option_scll_plan_wsaudit
- s_aps_orderrqmtrl ins_s_rqmtrl,ins_s_empty
- long ins_itmx_aps
- end variables
- forward prototypes
- public function integer auditing (boolean arg_ifcommit, ref string arg_msg)
- public function integer c_auditing (boolean arg_ifcommit, ref string arg_msg)
- public function integer secauditing (boolean arg_ifcommit, ref string arg_msg)
- public function integer c_secauditing (boolean arg_ifcommit, ref string arg_msg)
- public function integer priceaudit (boolean arg_ifcommit, ref string arg_msg)
- public function integer c_priceaudit (boolean arg_ifcommit, ref string arg_msg)
- public function integer uof_auto_secaudit (ref string arg_msg)
- public function integer wsauditing (long arg_scid, long arg_outwareid, long arg_printid, ref string arg_msg, boolean arg_ifcommit)
- public function integer wscauditing (long arg_scid, long arg_outwareid, long arg_printid, ref string arg_msg, boolean arg_ifcommit)
- public function integer cauditing_cw (long arg_scid, long arg_outwareid, long arg_printid, ref string arg_msg, boolean arg_ifcommit)
- public function integer auditing_cw (long arg_scid, long arg_outwareid, long arg_printid, ref string arg_msg, boolean arg_ifcommit)
- end prototypes
- public function integer auditing (boolean arg_ifcommit, ref string arg_msg);Int rslt = 1
- Long cnt = 0,i,li_type,ll_i,j
- Decimal ld_overqty,lde_addqty,lde_adduqty
- s_cmplpackpro_ref_mtrlwareid_array s_mtrlwareid_array_rst
- ins_ref_outwaremx = ins_empty_outwaremx
- ins_ref_mxbt = 0
- uo_mtrlware_assign uo_ma
- uo_ma = Create uo_mtrlware_assign
- uo_ma.commit_transaction = commit_transaction
- uo_cmpl_packpro uo_cmpl_p
- uo_cmpl_p = Create uo_cmpl_packpro
- uo_cmpl_p.commit_transaction = commit_transaction
- //库存分配ds
- datastore ds_out_assign
- ds_out_assign = Create datastore
- ds_out_assign.DataObject = 'ds_outwaremx_assign_scll'
- ds_out_assign.SetTransObject(commit_transaction)
- ins_itmx_aps = 0
- ins_s_rqmtrl = ins_s_empty
- If f_aps_mrp_cklock(scid,arg_msg) = 0 Then
- rslt = 0
- Goto ext
- End If
- If uo_option_confirmaudit_scll = -1000 Then
- arg_msg = '选项:[006]生产领料单先确认再审核,读取初始默认值失败,操作取消!'
- rslt = 0
- Goto ext
- End If
- If uo_option_wkpmtrlware = -1000 Then
- arg_msg = '选项:[057]生产使用车间核算,读取初始默认值失败,操作取消!'
- rslt = 0
- Goto ext
- End If
- If uo_option_inware_sc_location = -1000 Then
- arg_msg = '选项:[151]车间仓仓位按工组名称,读取初始默认值失败,操作取消!'
- rslt = 0
- Goto ext
- End If
- If uo_option_scll_plan_wsaudit = -1000 Then
- arg_msg = '选项:[377]发料单使用明细车间审核流程,读取初始默认值失败,操作取消!'
- rslt = 0
- Goto ext
- End If
- uo_order_ml uo_order
- uo_order = Create uo_order_ml
- //更新备料领料单实领数
- uo_outware_scllplan uo_scllplan
- uo_scllplan = Create uo_outware_scllplan
- If storageid = 0 Then
- rslt = 0
- arg_msg = '没有正确的仓库'
- Goto ext
- End If
- //yyx20120808加盘点表生成的领料单不检查
- If billtype <> 9 And Not (billtype = 3 And Pos(dscrp,'的领料单') > 0) Then
- If uof_check_warepdb_audit(storageid,arg_msg) = 0 Then
- rslt = 0
- Goto ext
- End If
- End If
- String ls_storagename
- Int li_storagetype
- Select storagename,storagetype
- Into :ls_storagename,:li_storagetype
- From u_storage
- Where storageid = :storageid Using commit_transaction ;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = "查询操作失败,仓库"
- Goto ext
- End If
- //检查是否有该仓库的建立权限
- If sys_user_storagestr_audit <> '0' Then
- If Pos(sys_user_storagestr_audit,','+String(storageid)+',') <= 0 Then
- rslt = 0
- arg_msg = '没有仓库: '+ls_storagename+' 的审核权限,不允许审核该仓库的单据'
- Goto ext
- End If
- End If
- //
- If outwareid = 0 Then
- rslt = 0
- arg_msg = "没有审核对象"
- Goto ext
- End If
- If uo_option_confirmaudit_scll = 1 And relint_1 = 0 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
- //IF relint_1 = 0 THEN
- If uo_option_confirmaudit_scll = 1 Then
- Update u_outware
- Set Auditingrep = :publ_operator,
- Auditingdate = getdate(),
- flag = 1
- Where u_outware.outwareid = :outwareid
- And flag = 0
- And priceflag = 1 Using commit_transaction;
- Else
- Update u_outware
- Set Auditingrep = :publ_operator,
- Auditingdate = getdate(),
- flag = 1,
- priceemp = :publ_operator,
- pricedate = getdate(),
- priceflag = 1
- Where u_outware.outwareid = :outwareid
- And flag = 0 Using commit_transaction;
- End If
- //ELSE
- //
- //END IF
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = "因网络或其它原因导致审核单据操作失败"+"~n"+commit_transaction.SQLErrText
- Goto ext
- ElseIf commit_transaction.SQLNRows = 0 Then
- rslt = 0
- arg_msg = "单据正在审核,请稍后查询。"+"~n"+commit_transaction.SQLErrText
- Goto ext
- End If
- Decimal ld_assign_outqty,ld_sumnotoutqty,ld_sumnotoutqty_bill
- Long ll_row
- Long ll_porderid,ll_orderid_retrieve
- Int li_ordertype_zl
- For i = 1 To it_mxbt
- Decimal ld_ref_costamt
- If p_update_cost(outwaremx[i].mtrlwareid,outwaremx[i].mtrlcode,&
- outwaremx[i].qty,outwaremx[i].printid,ld_ref_costamt,arg_msg,False) = 0 Then
- rslt = 0
- Goto ext
- End If
-
- If outwaremx[i].relid > 0 And relint_1 <> 4 Then
- //先扣库存分配,再扣库存
- If billtype = 3 And li_storagetype = 1 And outwaremx[i].relid > 0 And outwaremx[i].iffp = 1 Then
- Select ordertype,porderid
- Into :li_ordertype_zl,:ll_porderid
- From u_order_ml
- Where u_order_ml.scid = :scid
- And u_order_ml.orderid = :outwaremx[i].relid
- Using commit_transaction ;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '行:'+String(i)+',查询指令单属性失败,'+commit_transaction.SQLErrText
- Goto ext
- End If
-
- If li_ordertype_zl = 4 Then
- ll_orderid_retrieve = ll_porderid
- Else
- ll_orderid_retrieve = outwaremx[i].relid
- End If
-
- ll_row = ds_out_assign.Retrieve(scid,outwaremx[i].mtrlwareid,ll_orderid_retrieve)
- ds_out_assign.AcceptText()
-
- If ll_row <= 0 Then
- ld_sumnotoutqty = 0
- Else
- ld_sumnotoutqty = ds_out_assign.Object.sumnotoutqty[1]
- End If
-
- ld_sumnotoutqty_bill = 0
- ld_sumnotoutqty_bill = outwaremx[i].qty
-
- If ld_sumnotoutqty_bill > ld_sumnotoutqty Then
- arg_msg = '行:'+String(i)+'计划库存分配数不足,请检查库存分配明细'
- rslt = 0
- Goto ext
- Else
- ld_assign_outqty = 0
- For j = 1 To ds_out_assign.RowCount()
- If ds_out_assign.Object.notoutqty[j] >= ld_sumnotoutqty_bill Then
- ld_assign_outqty = ld_sumnotoutqty_bill
- If uo_ma.uof_assign_addoutqty(ds_out_assign.Object.assignid[j],ld_assign_outqty,arg_msg,False) = 0 Then
- arg_msg = '行:'+String(i)+','+arg_msg
- rslt = 0
- Goto ext
- End If
- Exit
- Else
- ld_assign_outqty = ds_out_assign.Object.notoutqty[j]
- If uo_ma.uof_assign_addoutqty(ds_out_assign.Object.assignid[j],ld_assign_outqty,arg_msg,False) = 0 Then
- arg_msg = '行:'+String(i)+','+arg_msg
- rslt = 0
- Goto ext
- End If
- ld_sumnotoutqty_bill = ld_sumnotoutqty_bill - ds_out_assign.Object.notoutqty[j]
- End If
- Next
- End If
- End If
- ////////////////////////////////////////////////////////////////////////// //
-
- If uo_order.f_add_dstrqty(scid,outwaremx[i].relid,relid,&
- outwaremx[i].mtrlid,outwaremx[i].mtrlcode,&
- outwaremx[i].status,outwaremx[i].woodcode,outwaremx[i].pcode,&
- outwaremx[i].qty,ld_ref_costamt,arg_msg,False,relint_1,ld_overqty) = 0 Then
- rslt = 0
- arg_msg = '行:'+String(i)+','+arg_msg
- Goto ext
- End If
-
- For ll_i = 1 To uo_order.it_mx_rq
- ins_itmx_aps++
- ins_s_rqmtrl.mtrlid[ins_itmx_aps] = uo_order.ins_s_rqmtrl.mtrlid[ll_i]
- ins_s_rqmtrl.status[ins_itmx_aps] = uo_order.ins_s_rqmtrl.status[ll_i]
- ins_s_rqmtrl.woodcode[ins_itmx_aps] = uo_order.ins_s_rqmtrl.woodcode[ll_i]
- ins_s_rqmtrl.pcode[ins_itmx_aps] = uo_order.ins_s_rqmtrl.pcode[ll_i]
- ins_s_rqmtrl.wrkgrpid[ins_itmx_aps] = uo_order.ins_s_rqmtrl.wrkgrpid[ll_i]
- ins_s_rqmtrl.orderid[ins_itmx_aps] = uo_order.ins_s_rqmtrl.orderid[ll_i]
- ins_s_rqmtrl.qty[ins_itmx_aps] = uo_order.ins_s_rqmtrl.qty[ll_i]
- ins_s_rqmtrl.scid[ins_itmx_aps] = uo_order.ins_s_rqmtrl.scid[ll_i]
- Next
-
- If ld_overqty > 0 Then
- Update u_outwaremx
- Set overqty = overqty + :ld_overqty
- Where outwareid = :outwareid
- And scid = :scid
- And printid = :outwaremx[i].printid;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '行:'+String(i)+','+'更新超计划领料数量失败'+"~n"+commit_transaction.SQLErrText
- Goto ext
- End If
- End If
- End If
-
- //发料单
- If billtype = 3 And relint_1 = 4 Then
- lde_addqty = outwaremx[i].qty
- lde_adduqty = outwaremx[i].uqty
-
- // If lde_addqty <> 0 And outwaremx[i].relid > 0 Then
- If outwaremx[i].relid > 0 Then
- //先扣库存分配,再扣库存(在p_addfactscllqty处理)
- If uo_scllplan.p_addfactscllqty(outwaremx[i].relid,outwaremx[i].mtrlwareid,storageid,outwaremx[i].mtrlid, outwaremx[i].status, outwaremx[i].woodcode, outwaremx[i].pcode, lde_addqty, lde_adduqty,ld_overqty,ld_ref_costamt,outwaremx[i].planqty - outwaremx[i].qty,1,False, arg_msg ) = 0 Then
- arg_msg = '行:'+String(i)+','+arg_msg
- rslt = 0
- Goto ext
- End If
-
- For ll_i = 1 To uo_order.it_mx_rq
- ins_itmx_aps++
- ins_s_rqmtrl.mtrlid[ins_itmx_aps] = uo_scllplan.ins_s_rqmtrl.mtrlid[ll_i]
- ins_s_rqmtrl.status[ins_itmx_aps] = uo_scllplan.ins_s_rqmtrl.status[ll_i]
- ins_s_rqmtrl.woodcode[ins_itmx_aps] = uo_scllplan.ins_s_rqmtrl.woodcode[ll_i]
- ins_s_rqmtrl.pcode[ins_itmx_aps] = uo_scllplan.ins_s_rqmtrl.pcode[ll_i]
- ins_s_rqmtrl.wrkgrpid[ins_itmx_aps] = uo_scllplan.ins_s_rqmtrl.wrkgrpid[ll_i]
- ins_s_rqmtrl.orderid[ins_itmx_aps] = uo_scllplan.ins_s_rqmtrl.orderid[ll_i]
- ins_s_rqmtrl.qty[ins_itmx_aps] = uo_scllplan.ins_s_rqmtrl.qty[ll_i]
- ins_s_rqmtrl.scid[ins_itmx_aps] = uo_scllplan.ins_s_rqmtrl.scid[ll_i]
- Next
-
- If ld_overqty > 0 Then
- Update u_outwaremx
- Set overqty = overqty + :ld_overqty
- Where outwareid = :outwareid
- And scid = :scid
- And printid = :outwaremx[i].printid;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '行:'+String(i)+','+'更新超计划领料数量失败'+"~n"+commit_transaction.SQLErrText
- Goto ext
- End If
- End If
- End If
- End If
-
- If p_update_mtrlware ( outwaremx[i].mtrlwareid, outwaremx[i].mtrlid, &
- outwaremx[i].mtrlcode, storageid, outwaremx[i].plancode,&
- outwaremx[i].status, outwaremx[i].qty, outwaremx[i].uqty,ld_ref_costamt,&
- outwaremx[i].planprice, outwaremx[i].sptid,outwaremx[i].dxflag,&
- outwaremx[i].woodcode,outwaremx[i].pcode,&
- outwaremx[i].mtrlcuscode,outwaremx[i].Location,outwaremx[i].ifvqty,arg_msg) = 0 Then
- rslt = 0
- arg_msg = '行:'+String(i)+','+arg_msg
- Goto ext
- End If
-
- //yyx2012-9-29返回计算可装数库存id数组
- If ( outwaremx[i].ifpack = 1 Or outwaremx[i].ifpack = 2 Or outwaremx[i].ifpackpro = 3 Or outwaremx[i].ifpackpro = 4 ) And uo_option_mtrlware_autocmp = 1 Then
- If uo_option_noauditingqty_mode = 0 Then
- If uo_cmpl_p.uof_ref_mtrlwarid_array(outwaremx[i].mtrlid,outwaremx[i].plancode,outwaremx[i].mtrlcuscode,storageid,s_mtrlwareid_array_rst,arg_msg) = 0 Then
- rslt = 0
- Goto ext
- End If
- Else
- ins_ref_mxbt++
- ins_ref_outwaremx[ins_ref_mxbt].mtrlid = outwaremx[i].mtrlid
- ins_ref_outwaremx[ins_ref_mxbt].plancode = outwaremx[i].plancode
- ins_ref_outwaremx[ins_ref_mxbt].mtrlcuscode = outwaremx[i].mtrlcuscode
- ins_ref_outwaremx[ins_ref_mxbt].storageid = storageid
- End If
- End If
-
- //
- Next
- //更新库存已开单数(减)
- If uof_noauditingqty_del(scid,outwareid,arG_MSG) = 0 Then
- rslt = 0
- Goto ext
- End If
- //yyx2012-9-29返回计算可装数库存id数组计算可装数
- If UpperBound(s_mtrlwareid_array_rst.mtrlwareid) > 0 And uo_option_mtrlware_autocmp = 1 Then
- If uo_option_noauditingqty_mode = 0 Then
- If uo_cmpl_p.uof_cmpl_diqty(s_mtrlwareid_array_rst,arg_msg) = 0 Then
- rslt = 0
- Goto ext
- End If
- End If
- End If
- //
- //领料单审核自动生成车间进仓单
- If uo_option_wkpmtrlware = 0 And uo_option_scll_plan_wsaudit = 0 And billtype = 3 And relint_1 = 4 Then
-
- If getinfo(scid,outwareid,arg_msg) = 0 Then
- rslt = 0
- Goto ext
- End If
-
- Long ll_wrkGrpid
- Long ll_storageid,ll_storageid_scid
- Long ll_inwareid,ll_inwareid_ws
- Long ll_pid
- Int li_ifwkpmtrlware
- Int li_iforder,li_ifover
- Decimal ld_qty_tmp,ld_uqty_tmp
- String ls_wrkgrpname,ls_location
-
- Select wrkGrpid Into :ll_wrkGrpid
- From u_workgroup
- Where workgroupid = :relid Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '查询工作组所属工组失败'+"~n"+commit_transaction.SQLErrText
- Goto ext
- End If
-
- If ll_wrkGrpid = 0 Then
- arg_msg = '领料组未设定所属工组'
- rslt = 0
- Goto ext
- End If
-
- Select u_sc_wkp.storageid,
- isnull(u_storage.scid,0),
- u_sc_wkp.ifwkpmtrlware,
- u_sc_workgroup.wrkgrpname
- Into :ll_storageid,
- :ll_storageid_scid,
- :li_ifwkpmtrlware,
- :ls_wrkgrpname
- From u_sc_workgroup,u_storage,u_sc_wkp
- Where u_sc_workgroup.wrkGrpid = :ll_wrkGrpid
- And u_sc_wkp.storageid = u_storage.storageid
- And u_sc_wkp.wrkGrpid = u_sc_workgroup.storageid
- Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '查询工组所属车间所属仓库失败'+"~n"+commit_transaction.SQLErrText
- Goto ext
- End If
-
- If uo_option_inware_sc_location = 1 Then
- ls_location = ls_wrkgrpname
- Else
- ls_location = ''
- End If
-
- If IsNull(ll_storageid) Then ll_storageid = 0
- If IsNull(ll_storageid_scid) Then ll_storageid_scid = 0
- If IsNull(li_ifwkpmtrlware) Then li_ifwkpmtrlware = 0
-
-
-
- If ll_storageid = 0 Then
- arg_msg = '领料组所属车间未指定仓库'
- rslt = 0
- Goto ext
- End If
-
- If ll_storageid_scid <> scid Then
- arg_msg = '领料车间对就仓库分部与单据分部不相符,请检查'
- rslt = 0
- Goto ext
- End If
- li_iforder = 0
- li_ifover = 0
-
- For i = 1 To it_mxbt
- If outwaremx[i].relid > 0 Then
- If outwaremx[i].overqty > 0 Then
- li_ifover = 1
- End If
- Else
- li_ifover = 1
- End If
- If li_ifover = 1 Then Exit
- Next
-
- If li_ifover = 1 Then
- uo_inware uo_in
- uo_in = Create uo_inware
- uo_in.commit_transaction = commit_transaction
- uo_in.if_getid_ture = False
-
- If uo_in.newbegin(scid,16,arg_msg) = 0 Then
- rslt = 0
- Goto ext
- End If
-
- uo_in.indate = outdate
- uo_in.inrep = outrep
- uo_in.part = outwarecode
- uo_in.dscrp = ''
- uo_in.storageid = ll_storageid
- uo_in.sptname = '车间领料自动进仓(不按计划/超数量)'
- uo_in.relint_3 = outwareid
-
- ll_pid = 0
-
- For i = 1 To it_mxbt
- ld_qty_tmp = 0
- ld_uqty_tmp = 0
- If outwaremx[i].relid = 0 Or &
- ( outwaremx[i].relid > 0 And outwaremx[i].overqty > 0 ) Then
- If outwaremx[i].relid = 0 Then
- ld_qty_tmp = outwaremx[i].qty
- ld_uqty_tmp = outwaremx[i].uqty
- Else
- ld_qty_tmp = outwaremx[i].overqty
- ld_uqty_tmp = outwaremx[i].overqty / outwaremx[i].rate
- End If
- Else
- Continue
- End If
-
- ll_pid++
- If uo_in.acceptmx(ll_pid,&
- outwaremx[i].mtrlid,&
- outwaremx[i].mtrlcode,&
- outwaremx[i].plancode,&
- outwaremx[i].status,&
- ld_uqty_tmp,&
- outwaremx[i].cost,&
- outwaremx[i].rebate,&
- outwaremx[i].mxdscrp,&
- arg_msg,&
- 0,0,0,&
- outwaremx[i].woodcode,&
- outwaremx[i].pcode,0,&
- outwaremx[i].unit,&
- outwaremx[i].rate,&
- ld_qty_tmp,&
- 0,0,'','',0,0,'',ls_location,&
- ld_uqty_tmp,&
- 0) = 0 Then
- arg_msg = '建立相关自动车间进仓单失败,' + arg_msg
- rslt = 0
- Goto ext
- End If
- Next
-
- If uo_in.Save(False,arg_msg) = 0 Then
- arg_msg = '建立相关自动车间进仓单失败,' + arg_msg
- rslt = 0
- Goto ext
- End If
-
- ll_inwareid = uo_in.inwareid
-
- If uo_in.getinfo(scid,ll_inwareid,arg_msg) = 0 Then
- arg_msg = '审核相关自动车间进仓单失败,' + arg_msg
- rslt = 0
- Goto ext
- End If
-
- If uo_in.auditing(False,arg_msg) = 0 Then
- arg_msg = '审核相关自动车间进仓单失败,' + arg_msg
- rslt = 0
- Goto ext
- End If
-
- //
- // Update u_outware
- // Set relint_2 = :ll_inwareid
- // Where outwareid = :outwareid
- // And scid = :scid
- // Using commit_transaction;
- // If commit_transaction.SQLCode <> 0 Then
- // rslt = 0
- // arg_msg = '更新出仓单失败'+'~n'+commit_transaction.SQLErrText
- // Goto ext
- // End If
-
- Destroy uo_in
- End If
- End If
- //如果是退料单,按明细类型执行相关处理
- datastore ds_mtrlware
- ds_mtrlware = Create datastore
- ds_mtrlware.DataObject = 'ds_mtrl_storage_mtrlware'
- ds_mtrlware.SetTransObject(commit_transaction)
- Long ll_row_ds,ll_j,ll_k
- Long ll_mtrlwareid_arr[],ll_scid_arr[],ll_storageid_arr[],ll_storageid_bu_arr[],ll_scid_bu_arr[]
- Int li_ifrel_arr[]
- Long ll_relid_arr[],ll_olmtrlid_arr[]
- Decimal ld_cost_arr[],ld_qty_arr[]
- String ls_unit_arr[]
- Decimal ld_qty_temp,ld_qty_bu
- Long ll_cnt_bu = 0,ll_cnt_storageid = 0
- Boolean lb_find_storage = False
- DateTime server_dt
- Long ll_printid_bu
- Long ll_wrkgrpid_back
- Decimal ld_truerqqty,ld_sqty,ld_dqty
- Boolean lb_backtype = False
- s_order_ml_mtrl_change_mx arg_s_mx[],arg_s_empty_mx[]
- Select Top 1 getdate() Into :server_dt From u_user Using commit_transaction ;
- //取得系统时间,借用操作员表
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = "查询操作失败,日期 "
- Goto ext
- End If
- uo_outware uo_out_bu
- uo_out_bu = Create uo_outware
- uo_out_bu.commit_transaction = commit_transaction
- uo_out_bu.if_getid_ture = False
- If billtype = 3 And relint_1 = 2 Then
-
- Select wrkGrpid
- Into :ll_wrkgrpid_back
- From u_workgroup
- Where workgroupid = :relid Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- arg_msg = '查询工作中心所属工组失败 ' +commit_transaction.SQLErrText
- rslt = 0
- Goto ext
- End If
-
- For ll_i = 1 To it_mxbt
- If outwaremx[ll_i].backtype = 1 Then
- ld_qty_temp = 0 - outwaremx[ll_i].qty
- ll_row_ds = ds_mtrlware.Retrieve(outwaremx[ll_i].mtrlid,outwaremx[ll_i].status,outwaremx[ll_i].woodcode,outwaremx[ll_i].pcode)
-
- lb_backtype = False
-
- For ll_j = 1 To ll_row_ds
- If ds_mtrlware.Object.qty[ll_j] <= 0 Then Continue
-
- If ld_qty_temp > ds_mtrlware.Object.qty[ll_j] Then
- ld_qty_bu = ds_mtrlware.Object.qty[ll_j]
- ld_qty_temp = ld_qty_temp - ds_mtrlware.Object.qty[ll_j]
- Else
- ld_qty_bu = ld_qty_temp
- ld_qty_temp = 0
- End If
-
- ll_cnt_bu++
- ll_scid_arr[ll_cnt_bu] = ds_mtrlware.Object.u_mtrlware_scid[ll_j]
- ll_mtrlwareid_arr[ll_cnt_bu] = ds_mtrlware.Object.u_mtrlware_mtrlwareid[ll_j]
- ll_storageid_arr[ll_cnt_bu] = ds_mtrlware.Object.u_mtrlware_storageid[ll_j]
- ld_cost_arr[ll_cnt_bu] = ds_mtrlware.Object.u_mtrlware_cost[ll_j]
- ld_qty_arr[ll_cnt_bu] = ld_qty_bu
- ls_unit_arr[ll_cnt_bu] = ds_mtrlware.Object.u_mtrldef_unit[ll_j]
- li_ifrel_arr[ll_cnt_bu] = outwaremx[ll_i].ifrel
- ll_relid_arr[ll_cnt_bu] = outwaremx[ll_i].relid
- ll_olmtrlid_arr[ll_cnt_bu] = outwaremx[ll_i].olmtrlid
- lb_backtype = True
-
- lb_find_storage = False
- For ll_k = 1 To ll_cnt_storageid
- If ll_storageid_bu_arr[ll_k] = ll_storageid_arr[ll_cnt_bu] Then
- lb_find_storage = True
- Exit
- End If
- Next
-
- If lb_find_storage = False Then
- ll_cnt_storageid++
- ll_storageid_bu_arr[ll_cnt_storageid] = ll_storageid_arr[ll_cnt_bu]
- ll_scid_bu_arr[ll_cnt_storageid] = ll_scid_arr[ll_cnt_bu]
- End If
-
- If ld_qty_temp <= 0 Then Goto _next_bu
- Next
-
- If lb_backtype = False Then
- Update u_outwaremx
- Set backtype = 0
- Where scid = :scid
- And outwareid = :outwareid
- And printid = :outwaremx[ll_i].printid Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- arg_msg = '第'+String(ll_i)+'行,更新明细退料类型为不自动建立补料单失败,'+commit_transaction.SQLErrText
- rslt = 0
- Goto ext
- Else
- arg_msg = arg_msg + '第'+String(ll_i)+'行,明细物料没有库存自动建立补料单,退料类型自动变为不自动建立补料单'+'~r~n'
- End If
- End If
-
- ElseIf outwaremx[ll_i].backtype = 2 Then
- If outwaremx[ll_i].relid > 0 Then
- Select truerqqty
- Into :ld_truerqqty
- From u_orderrqmtrl_scll
- Where orderid = :outwaremx[ll_i].relid
- And mtrlid = :outwaremx[ll_i].mtrlid
- And wrkGrpid = :ll_wrkgrpid_back
- And scid = :scid
- And status = :outwaremx[ll_i].status
- And woodcode = :outwaremx[ll_i].woodcode
- And pcode = :outwaremx[ll_i].pcode Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- arg_msg = '第'+String(ll_i)+'行,查询指令单领料明细信息失败,'+commit_transaction.SQLErrText
- rslt = 0
- Goto ext
- End If
-
- ld_sqty = ld_truerqqty
- ld_dqty = ld_truerqqty + outwaremx[ll_i].qty
-
- uo_order_ml_mtrl_change uo_mtrl_ch
- uo_mtrl_ch = Create uo_order_ml_mtrl_change
- s_order_ml_mtrl_change arg_s_mtrl_ch
-
-
-
- arg_s_mtrl_ch.scid = scid
- arg_s_mtrl_ch.billid = 0
- arg_s_mtrl_ch.billdate = server_dt
- arg_s_mtrl_ch.billemp = publ_operator
- arg_s_mtrl_ch.relcode = ''
- arg_s_mtrl_ch.dscrp = '退料单终止用料自动生成' //注意修改时这里时要修改uo_order_ml_mtrl_change.audit
- arg_s_mtrl_ch.orderid = outwaremx[ll_i].relid
- arg_s_mtrl_ch.smtrlid = outwaremx[ll_i].mtrlid
- arg_s_mtrl_ch.wrkgrpid = ll_wrkgrpid_back
- arg_s_mtrl_ch.status = outwaremx[ll_i].status
- arg_s_mtrl_ch.woodcode = outwaremx[ll_i].woodcode
- arg_s_mtrl_ch.pcode = outwaremx[ll_i].pcode
- arg_s_mtrl_ch.dmtrlid = outwaremx[ll_i].mtrlid
-
- arg_s_mtrl_ch.sqty = ld_sqty
- arg_s_mtrl_ch.dqty = ld_dqty
-
-
- arg_s_mtrl_ch.billtype = 1
-
- arg_s_mtrl_ch.ifchange = 1
-
- //加明细
- arg_s_mx = arg_s_empty_mx
-
- If f_addmx_mtrl_change(scid,outwaremx[ll_i].relid,outwaremx[ll_i].mtrlid,ll_wrkgrpid_back,outwaremx[ll_i].status, outwaremx[ll_i].woodcode,outwaremx[ll_i].pcode,ld_sqty,ld_dqty,arg_s_mx,arg_msg) = 0 Then
- rslt = 0
- arg_msg = '明细第'+String(ll_i)+'行,生成生产指令单换料单失败,原因:计算单据明细失败.'+arg_msg
- Goto ext
- End If
-
- arg_s_mtrl_ch.arg_s_mx = arg_s_mx
-
- If uo_mtrl_ch.Save(arg_s_mtrl_ch,publ_operator,arg_msg,False) = 0 Then
- rslt = 0
- arg_msg = '明细第'+String(ll_i)+'行,生成生产指令单换料单失败,'+arg_msg
- Goto ext
- End If
-
- If uo_mtrl_ch.audit(uo_mtrl_ch.uo_billid,publ_operator,arg_msg,False) = 0 Then
- rslt = 0
- arg_msg = '明细第'+String(ll_i)+'行,审核相关生产指令单换料单失败,'+arg_msg
- Goto ext
- End If
-
- Destroy uo_mtrl_ch
- End If
- End If
-
- _next_bu:
- Next
-
- For ll_i = 1 To ll_cnt_storageid
-
- If uo_out_bu.newbegin(ll_scid_bu_arr[ll_i],3,arg_msg) = 0 Then
- rslt = 0
- Goto ext
- End If
-
- uo_out_bu.outdate = server_dt
- uo_out_bu.outrep = publ_operator
- uo_out_bu.part = outwarecode
- uo_out_bu.dscrp = '生产退料单仓审自动生成'
- uo_out_bu.cusname = '补料'
- uo_out_bu.storageid = ll_storageid_bu_arr[ll_i]
- uo_out_bu.relid = relid
- uo_out_bu.relint_1 = 5
- uo_out_bu.relint_4 = outwareid
-
- ll_printid_bu = 0
-
- For ll_j = 1 To ll_cnt_bu
- If ll_storageid_arr[ll_j] <> ll_storageid_bu_arr[ll_i] Then Continue
-
- ll_printid_bu++
- If uo_out_bu.acceptmx(ll_mtrlwareid_arr[ll_j],&
- ld_qty_arr[ll_j],&
- ld_cost_arr[ll_j],&
- 1,&
- '',&
- ll_printid_bu,&
- arg_msg,&
- li_ifrel_arr[ll_j],&
- ll_relid_arr[ll_j],&
- ll_olmtrlid_arr[ll_j],0,'',0,0,&
- ls_unit_arr[ll_j],&
- ld_qty_arr[ll_j],&
- 1,'','',0,0,'',0,0,0,0,'','') = 0 Then
- arg_msg = '自动建立生产补料单失败,' + arg_msg
- rslt = 0
- Goto ext
- End If
- Next
-
- If ll_printid_bu > 0 Then
- If uo_out_bu.Save(False,arg_msg) = 0 Then
- arg_msg = '自动建立生产补料单失败,' + arg_msg
- rslt = 0
- Goto ext
- End If
- End If
-
- Next
- End If
- flag = 1
- ext:
- If rslt = 0 Then
- Rollback Using commit_transaction;
- ElseIf rslt = 1 And arg_ifcommit Then
- Commit Using commit_transaction;
- End If
- Destroy uo_order
- Destroy uo_scllplan
- Destroy uo_ma
- Destroy uo_cmpl_p
- Destroy ds_out_assign
- Destroy ds_mtrlware
- Destroy uo_out_bu
- Return rslt
- end function
- public function integer c_auditing (boolean arg_ifcommit, ref string arg_msg);Int rslt = 1
- Long cnt = 0,i,li_type,ll_i,j
- Decimal ld_overqty,lde_addqty,lde_adduqty
- s_cmplpackpro_ref_mtrlwareid_array s_mtrlwareid_array_rst
- ins_ref_outwaremx = ins_empty_outwaremx
- ins_ref_mxbt = 0
- uo_mtrlware_assign uo_ma
- uo_ma = Create uo_mtrlware_assign
- uo_ma.commit_transaction = commit_transaction
- uo_cmpl_packpro uo_cmpl_p
- uo_cmpl_p = Create uo_cmpl_packpro
- uo_cmpl_p.commit_transaction = commit_transaction
- //库存分配ds
- datastore ds_out_assign
- ds_out_assign = Create datastore
- ds_out_assign.DataObject = 'ds_outwaremx_assign_cancel_scll'
- ds_out_assign.SetTransObject(commit_transaction)
- ins_itmx_aps = 0
- ins_s_rqmtrl = ins_s_empty
- If f_aps_mrp_cklock(scid,arg_msg) = 0 Then
- rslt = 0
- Goto ext
- End If
- If uo_option_confirmaudit_scll = -1000 Then
- arg_msg = '选项:[006]生产领料单先确认再审核,读取初始默认值失败,操作取消!'
- rslt = 0
- Goto ext
- End If
- If uo_option_scll_plan_wsaudit = -1000 Then
- arg_msg = '选项:[377]发料单使用明细车间审核流程,读取初始默认值失败,操作取消!'
- rslt = 0
- Goto ext
- End If
- DateTime null_dt
- SetNull(null_dt)
- uo_order_ml uo_order
- uo_order = Create uo_order_ml
- uo_outware_scllplan uo_scllplan
- uo_scllplan = Create uo_outware_scllplan
- If storageid = 0 Then
- rslt = 0
- arg_msg = '没有正确的仓库'
- Goto ext
- End If
- If billtype <> 9 and not (billtype = 3 And Pos(dscrp,'电脑生成的') > 0 And Pos(dscrp,'的领料单') > 0) Then
- If uof_check_warepdb_audit(storageid,arg_msg) = 0 Then
- rslt = 0
- Goto ext
- End If
- End If
- String ls_storagename
- Int li_storagetype
- Select storagename,storagetype
- Into :ls_storagename,:li_storagetype
- From u_storage
- Where storageid = :storageid Using commit_transaction ;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = "查询操作失败,仓库"
- Goto ext
- End If
- //检查是否有该仓库的建立权限
- If sys_user_storagestr_audit <> '0' Then
- If Pos(sys_user_storagestr_audit,','+String(storageid)+',') <= 0 Then
- rslt = 0
- arg_msg = '没有仓库: '+ls_storagename+' 的审核权限,不允许撤审该仓库的单据'
- Goto ext
- End If
- End If
- //
- If outwareid = 0 Then
- rslt = 0
- arg_msg = "没有审核对象"
- Goto ext
- End If
- If ctmint > 0 Then
- arg_msg = '单据已截数,不能操作'
- rslt = 0
- Goto ext
- End If
- If flag = 0 Then
- rslt = 0
- arg_msg = "单据还未审核"
- Goto ext
- End If
- If balcflag = 1 Then
- rslt = 0
- arg_msg = "单据已经日结,不能撤审"
- Goto ext
- End If
- If uo_option_confirmaudit_scll = 1 Then
- Update u_outware
- Set Auditingrep = '',
- Auditingdate = :null_dt,
- flag = 0
- Where u_outware.outwareid = :outwareid
- And scid = :scid
- And flag = 1
- And priceflag = 1
- And secflag = 0 Using commit_transaction;
- Else
- Update u_outware
- Set Auditingrep = '',
- Auditingdate = :null_dt,
- flag = 0,
- priceemp = '',
- pricedate = :null_dt,
- priceflag = 0
- Where u_outware.outwareid = :outwareid
- And scid = :scid
- And flag = 1
- And secflag = 0 Using commit_transaction;
- End If
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = "因网络或其它原因导致撤审单据操作失败"+"~n"+commit_transaction.SQLErrText
- Goto ext
- ElseIf commit_transaction.SQLNRows = 0 Then
- rslt = 0
- arg_msg = "单据正在撤审,请稍后查询。"+"~n"+commit_transaction.SQLErrText
- Goto ext
- End If
- //如果是退料单,根据明细类型进行处理
- Decimal ld_truerqqty,ld_sqty,ld_dqty
- Long ll_wrkgrpid_back
- DateTime server_dt
- Long ll_cnt_bu
- s_order_ml_mtrl_change_mx arg_s_mx[],arg_s_empty_mx[]
- Select Top 1 getdate() Into :server_dt From u_user Using commit_transaction ;
- //取得系统时间,借用操作员表
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = "查询操作失败,日期 "
- Goto ext
- End If
- uo_outware uo_out_bu
- uo_out_bu = Create uo_outware
- uo_out_bu.commit_transaction = commit_transaction
- uo_out_bu.if_getid_ture = False
- Long ll_scid_bu[],ll_outwareid_bu[]
- Long ll_mxbt_bu
- String ls_outwarecode_bu[]
- If billtype = 3 And relint_1 = 2 Then
-
- Select count(*)
- Into :ll_cnt_bu
- From u_outware
- Where billtype = 3
- And relint_1 = 5
- And relint_4 = :outwareid
- And flag = 1 Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '查询退料单是否有相关自动建立的补料单失败 '+commit_transaction.SQLErrText
- Goto ext
- End If
-
- If ll_cnt_bu > 0 Then
- rslt = 0
- arg_msg = '相关自动建立的补料单已仓审,不能撤审退料单'
- Goto ext
- End If
-
- ll_mxbt_bu = 1
-
- Declare cur_outware_bu Cursor For
- Select scid,outwareid,outwarecode
- From u_outware
- Where billtype = 3
- And relint_1 = 5
- And relint_4 = :outwareid Using commit_transaction;
-
- Open cur_outware_bu;
-
- Fetch cur_outware_bu Into :ll_scid_bu[ll_mxbt_bu],:ll_outwareid_bu[ll_mxbt_bu],:ls_outwarecode_bu[ll_mxbt_bu];
-
- Do While commit_transaction.SQLCode = 0
- ll_mxbt_bu++
- Fetch cur_outware_bu Into :ll_scid_bu[ll_mxbt_bu],:ll_outwareid_bu[ll_mxbt_bu],:ls_outwarecode_bu[ll_mxbt_bu];
-
- Loop
-
- Close cur_outware_bu;
-
- For ll_i = 1 To ll_mxbt_bu - 1
- If uo_out_bu.del(ll_scid_bu[ll_i],ll_outwareid_bu[ll_i],0,arg_msg,False) = 0 Then
- arg_msg = '删除相关自动建立的补料单失败,:'+ls_outwarecode_bu[ll_i]+','+arg_msg
- rslt = 0
- Goto ext
- End If
- Next
-
- For ll_i = 1 To it_mxbt
- Select wrkGrpid
- Into :ll_wrkgrpid_back
- From u_workgroup
- Where workgroupid = :relid Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- arg_msg = '查询工作中心所属工组失败 ' +commit_transaction.SQLErrText
- rslt = 0
- Goto ext
- End If
-
- If outwaremx[ll_i].backtype = 2 And outwaremx[ll_i].relid > 0 Then
- Select truerqqty
- Into :ld_truerqqty
- From u_orderrqmtrl_scll
- Where orderid = :outwaremx[ll_i].relid
- And mtrlid = :outwaremx[ll_i].mtrlid
- And wrkGrpid = :ll_wrkgrpid_back
- And scid = :scid
- And status = :outwaremx[ll_i].status
- And woodcode = :outwaremx[ll_i].woodcode
- And pcode = :outwaremx[ll_i].pcode Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- arg_msg = '第'+String(ll_i)+'行,查询指令单领料明细信息失败,'+commit_transaction.SQLErrText
- rslt = 0
- Goto ext
- End If
-
- ld_sqty = ld_truerqqty
- ld_dqty = ld_truerqqty - outwaremx[ll_i].qty
-
- uo_order_ml_mtrl_change uo_mtrl_ch
- uo_mtrl_ch = Create uo_order_ml_mtrl_change
- s_order_ml_mtrl_change arg_s_mtrl_ch
-
- arg_s_mtrl_ch.scid = scid
- arg_s_mtrl_ch.billid = 0
- arg_s_mtrl_ch.billdate = server_dt
- arg_s_mtrl_ch.billemp = publ_operator
- arg_s_mtrl_ch.relcode = ''
- arg_s_mtrl_ch.dscrp = '退料单撤审取消终止自动生成' //注意修改时这里时要修改uo_order_ml_mtrl_change.audit
- arg_s_mtrl_ch.orderid = outwaremx[ll_i].relid
- arg_s_mtrl_ch.smtrlid = outwaremx[ll_i].mtrlid
- arg_s_mtrl_ch.wrkGrpid = ll_wrkgrpid_back
- arg_s_mtrl_ch.status = outwaremx[ll_i].status
- arg_s_mtrl_ch.woodcode = outwaremx[ll_i].woodcode
- arg_s_mtrl_ch.pcode = outwaremx[ll_i].pcode
- arg_s_mtrl_ch.dmtrlid = outwaremx[ll_i].mtrlid
-
- arg_s_mtrl_ch.sqty = ld_sqty
- arg_s_mtrl_ch.dqty = ld_dqty
-
- arg_s_mtrl_ch.billtype = 1
-
- arg_s_mtrl_ch.ifchange = 1
-
- //加明细
- arg_s_mx = arg_s_empty_mx
-
- If f_addmx_mtrl_change(scid,outwaremx[ll_i].relid,outwaremx[ll_i].mtrlid,ll_wrkgrpid_back,outwaremx[ll_i].status, outwaremx[ll_i].woodcode,outwaremx[ll_i].pcode,ld_sqty,ld_dqty,arg_s_mx,arg_msg) = 0 Then
- rslt = 0
- arg_msg = '明细第'+String(ll_i)+'行,生成生产指令单换料单失败,原因:计算单据明细失败.'+arg_msg
- Goto ext
- End If
-
- arg_s_mtrl_ch.arg_s_mx = arg_s_mx
-
- If uo_mtrl_ch.Save(arg_s_mtrl_ch,publ_operator,arg_msg,False) = 0 Then
- rslt = 0
- arg_msg = '明细第'+String(ll_i)+'行,生成生产指令单换料单失败,'+arg_msg
- Goto ext
- End If
-
- If uo_mtrl_ch.audit(uo_mtrl_ch.uo_billid,publ_operator,arg_msg,False) = 0 Then
- rslt = 0
- arg_msg = '明细第'+String(ll_i)+'行,审核相关生产指令单换料单失败,'+arg_msg
- Goto ext
- End If
-
- Destroy uo_mtrl_ch
- End If
- Next
-
-
- //检查明细是否还有开过补料单
- For ll_i = 1 To it_mxbt
- cnt = 0
-
- Select count(*)
- Into :cnt
- From u_outware Inner JOIN
- u_outwaremx ON u_outware.scid = u_outwaremx.scid And
- u_outware.outwareid = u_outwaremx.outwareid
- Where (u_outware.billtype = 3)
- And (u_outware.relint_1 = 5)
- And (u_outwaremx.relid = :outwaremx[ll_i].relid)
- And (u_outwaremx.mtrlid = :outwaremx[ll_i].mtrlid) Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- arg_msg = '第'+String(ll_i)+'行,查询单据明细是否已开补料单失败,'+commit_transaction.SQLErrText
- rslt = 0
- Goto ext
- End If
-
- If cnt > 0 Then
- arg_msg = '第'+String(ll_i)+'行,单据明细已开补料单,不能撤审'
- rslt = 0
- Goto ext
- End If
-
- Next
- End If
- For i = 1 To it_mxbt
- If p_update_mtrlware ( outwaremx[i].mtrlwareid, outwaremx[i].mtrlid, &
- outwaremx[i].mtrlcode, storageid, outwaremx[i].plancode,&
- outwaremx[i].status, 0 - outwaremx[i].qty,0 - outwaremx[i].uqty,0 - outwaremx[i].costamt,&
- outwaremx[i].planprice, outwaremx[i].sptid,outwaremx[i].dxflag,&
- outwaremx[i].woodcode, outwaremx[i].pcode,&
- outwaremx[i].mtrlcuscode,outwaremx[i].Location,outwaremx[i].ifvqty,arg_msg) = 0 Then
- rslt = 0
- Goto ext
- End If
-
- If outwaremx[i].relid > 0 And relint_1 <> 4 Then
- If uo_order.f_add_dstrqty(scid,outwaremx[i].relid,relid,&
- outwaremx[i].mtrlid,outwaremx[i].mtrlcode,&
- outwaremx[i].status,outwaremx[i].woodcode,outwaremx[i].pcode,&
- 0 - outwaremx[i].qty,0 - outwaremx[i].costamt,arg_msg,False,relint_1,ld_overqty) = 0 Then
- rslt = 0
- Goto ext
- End If
-
- For ll_i = 1 To uo_order.it_mx_rq
- ins_itmx_aps++
- ins_s_rqmtrl.mtrlid[ins_itmx_aps] = uo_order.ins_s_rqmtrl.mtrlid[ll_i]
- ins_s_rqmtrl.status[ins_itmx_aps] = uo_order.ins_s_rqmtrl.status[ll_i]
- ins_s_rqmtrl.woodcode[ins_itmx_aps] = uo_order.ins_s_rqmtrl.woodcode[ll_i]
- ins_s_rqmtrl.pcode[ins_itmx_aps] = uo_order.ins_s_rqmtrl.pcode[ll_i]
- ins_s_rqmtrl.wrkGrpid[ins_itmx_aps] = uo_order.ins_s_rqmtrl.wrkGrpid[ll_i]
- ins_s_rqmtrl.orderid[ins_itmx_aps] = uo_order.ins_s_rqmtrl.orderid[ll_i]
- ins_s_rqmtrl.qty[ins_itmx_aps] = uo_order.ins_s_rqmtrl.qty[ll_i]
- ins_s_rqmtrl.scid[ins_itmx_aps] = uo_order.ins_s_rqmtrl.scid[ll_i]
- Next
-
- If outwaremx[i].overqty > 0 Then
- Update u_outwaremx
- Set overqty = overqty - :outwaremx[i].overqty
- Where outwareid = :outwareid
- And scid = :scid
- And printid = :outwaremx[i].printid;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '更新超计划领料数量失败'+"~n"+commit_transaction.SQLErrText
- Goto ext
- End If
- End If
-
- //更新库存分配
- Decimal ld_assign_outqty,ld_sumnotoutqty,ld_outmxqty
- Long ll_row
- Long ll_porderid,ll_orderid_retrieve
- Int li_ordertype_zl
-
- If billtype = 3 And li_storagetype = 1 And outwaremx[i].iffp = 1 And outwaremx[i].relid > 0 Then
- Select ordertype,porderid
- Into :li_ordertype_zl,:ll_porderid
- From u_order_ml
- Where u_order_ml.scid = :scid
- And u_order_ml.orderid = :outwaremx[i].relid
- Using commit_transaction ;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '行:'+String(i)+',查询指令单属性失败,'+commit_transaction.SQLErrText
- Goto ext
- End If
-
- If li_ordertype_zl = 4 Then
- ll_orderid_retrieve = ll_porderid
- Else
- ll_orderid_retrieve = outwaremx[i].relid
- End If
-
- ll_row = ds_out_assign.Retrieve(scid,outwaremx[i].mtrlwareid,ll_orderid_retrieve)
- ds_out_assign.AcceptText()
-
- If ll_row <= 0 Then
- ld_sumnotoutqty = 0
- Else
- ld_sumnotoutqty = ds_out_assign.Object.sumnotoutqty[1]
- End If
-
- ld_outmxqty = outwaremx[i].qty
-
- If ld_outmxqty > ld_sumnotoutqty Then
- arg_msg = '行:'+String(i)+'订单库存分配已出仓数不足,不能撤审,请检查库存分配明细'
- rslt = 0
- Goto ext
- Else
- ld_assign_outqty = 0
- For j = 1 To ds_out_assign.RowCount()
- If ds_out_assign.Object.notoutqty[j] >= ld_outmxqty Then
- ld_assign_outqty = ld_outmxqty
- If uo_ma.uof_assign_addoutqty(ds_out_assign.Object.assignid[j],0 - ld_assign_outqty,arg_msg,False) = 0 Then
- arg_msg = '行:'+String(i)+','+arg_msg
- rslt = 0
- Goto ext
- End If
- Exit
- Else
- ld_assign_outqty = ds_out_assign.Object.notoutqty[j]
- If uo_ma.uof_assign_addoutqty(ds_out_assign.Object.assignid[j],0 - ld_assign_outqty,arg_msg,False) = 0 Then
- arg_msg = '行:'+String(i)+','+arg_msg
- rslt = 0
- Goto ext
- End If
- ld_outmxqty = ld_outmxqty - ds_out_assign.Object.notoutqty[j]
- End If
- Next
- End If
- End If
- End If
-
- //发料单
- If billtype = 3 And relint_1 = 4 Then
- lde_addqty = 0 - outwaremx[i].qty
- lde_adduqty = 0 - outwaremx[i].uqty
-
- // IF lde_addqty <> 0 And outwaremx[i].relid > 0 THEN
- If outwaremx[i].relid > 0 Then
- If uo_scllplan.p_addfactscllqty(outwaremx[i].relid,outwaremx[i].mtrlwareid,storageid,outwaremx[i].mtrlid, outwaremx[i].status, outwaremx[i].woodcode, outwaremx[i].pcode,lde_addqty,lde_adduqty, ld_overqty,0 - outwaremx[i].costamt,outwaremx[i].qty - outwaremx[i].planqty,0,False, arg_msg ) = 0 Then
- rslt = 0
- Goto ext
- End If
-
- For ll_i = 1 To uo_order.it_mx_rq
- ins_itmx_aps++
- ins_s_rqmtrl.mtrlid[ins_itmx_aps] = uo_scllplan.ins_s_rqmtrl.mtrlid[ll_i]
- ins_s_rqmtrl.status[ins_itmx_aps] = uo_scllplan.ins_s_rqmtrl.status[ll_i]
- ins_s_rqmtrl.woodcode[ins_itmx_aps] = uo_scllplan.ins_s_rqmtrl.woodcode[ll_i]
- ins_s_rqmtrl.pcode[ins_itmx_aps] = uo_scllplan.ins_s_rqmtrl.pcode[ll_i]
- ins_s_rqmtrl.wrkGrpid[ins_itmx_aps] = uo_scllplan.ins_s_rqmtrl.wrkGrpid[ll_i]
- ins_s_rqmtrl.orderid[ins_itmx_aps] = uo_scllplan.ins_s_rqmtrl.orderid[ll_i]
- ins_s_rqmtrl.qty[ins_itmx_aps] = uo_scllplan.ins_s_rqmtrl.qty[ll_i]
- ins_s_rqmtrl.scid[ins_itmx_aps] = uo_scllplan.ins_s_rqmtrl.scid[ll_i]
- Next
-
- If outwaremx[i].overqty > 0 Then
- Update u_outwaremx
- Set overqty = overqty - :outwaremx[i].overqty
- Where outwareid = :outwareid
- And scid = :scid
- And printid = :outwaremx[i].printid;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '更新超计划领料数量失败'+"~n"+commit_transaction.SQLErrText
- Goto ext
- End If
- End If
- End If
- End If
-
- //yyx2012-9-29返回计算可装数库存id数组
- If ( outwaremx[i].ifpack = 1 Or outwaremx[i].ifpack = 2 Or outwaremx[i].ifpackpro = 3 Or outwaremx[i].ifpackpro = 4 ) And uo_option_mtrlware_autocmp = 1 Then
- If uo_option_noauditingqty_mode = 0 Then
- If uo_cmpl_p.uof_ref_mtrlwarid_array(outwaremx[i].mtrlid,outwaremx[i].plancode,outwaremx[i].mtrlcuscode,storageid,s_mtrlwareid_array_rst,arg_msg) = 0 Then
- rslt = 0
- Goto ext
- End If
- Else
- ins_ref_mxbt++
- ins_ref_outwaremx[ins_ref_mxbt].mtrlid = outwaremx[i].mtrlid
- ins_ref_outwaremx[ins_ref_mxbt].plancode = outwaremx[i].plancode
- ins_ref_outwaremx[ins_ref_mxbt].mtrlcuscode = outwaremx[i].mtrlcuscode
- ins_ref_outwaremx[ins_ref_mxbt].storageid = storageid
- End If
- End If
- //
- Next
- //增加已开单数
- If uof_noauditingqty_add(scid,billtype,relint_1,arg_msg) = 0 Then
- rslt = 0
- Goto ext
- End If
- //yyx2012-9-29返回计算可装数库存id数组计算可装数
- If UpperBound(s_mtrlwareid_array_rst.mtrlwareid) > 0 And uo_option_mtrlware_autocmp = 1 Then
- If uo_option_noauditingqty_mode = 0 Then
- If uo_cmpl_p.uof_cmpl_diqty(s_mtrlwareid_array_rst,arg_msg) = 0 Then
- rslt = 0
- Goto ext
- End If
- End If
- End If
- //
- If uo_option_wkpmtrlware = 0 And uo_option_scll_plan_wsaudit = 0 And billtype = 3 And relint_1 = 4 Then
- Long ll_inwareid
-
- Select count(*)
- Into :cnt
- From u_inware
- Where relint_3 = :outwareid
- And scid = :scid Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '查询发料单是否有相关车间进仓单失败,'+commit_transaction.SQLErrText
- Goto ext
- End If
-
- If cnt > 0 Then
- Select top 1 inwareid Into :ll_inwareid
- From u_inware
- Where relint_3 = :outwareid
- And scid = :scid Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '查询发料单是否有相关车间进仓单失败,'+commit_transaction.SQLErrText
- Goto ext
- End If
- End If
-
- If ll_inwareid > 0 Then
- uo_inware uo_in
- uo_in = Create uo_inware
- uo_in.commit_transaction = commit_transaction
-
- If uo_in.getinfo(scid,ll_inwareid,arg_msg) = 0 Then
- arg_msg = '删除相关自动车间进仓单失败,' + arg_msg
- rslt = 0
- Goto ext
- End If
-
- If uo_in.c_auditing(False,arg_msg) = 0 Then
- arg_msg = '删除相关自动车间进仓单失败,' + arg_msg
- rslt = 0
- Goto ext
- End If
-
- If uo_in.del(scid,ll_inwareid,arg_msg,False) = 0 Then
- arg_msg = '删除相关自动车间进仓单失败,' + arg_msg
- rslt = 0
- Goto ext
- End If
- End If
-
- End If
- flag = 0
- ext:
- If rslt = 0 Then
- Rollback Using commit_transaction;
- ElseIf rslt = 1 And arg_ifcommit Then
- Commit Using commit_transaction;
- End If
- Destroy uo_order
- Destroy uo_scllplan
- Destroy uo_ma
- Destroy uo_cmpl_p
- Destroy ds_out_assign
- Destroy uo_out_bu
- Return rslt
- end function
- public function integer secauditing (boolean arg_ifcommit, ref string arg_msg);Int rslt = 1
- Long i,cnt = 0
- String ls_location
- String ls_wrkgrpname
- IF uo_option_wkpmtrlware = -1000 THEN
- arg_msg = '选项:[057]生产使用车间核算,读取初始默认值失败,操作取消!'
- rslt = 0
- GOTO ext
- END IF
- IF uo_option_inware_sc_location = -1000 THEN
- arg_msg = '选项:[151]车间仓仓位按工组名称,读取初始默认值失败,操作取消!'
- rslt = 0
- GOTO ext
- END IF
- IF uo_option_outware_scll_new_cj_mtrlware = -1000 THEN
- arg_msg = '选项:[355]其它领料单增加车间仓库存,读取初始默认值失败,操作取消!'
- rslt = 0
- GOTO ext
- END IF
- If uo_option_scll_plan_wsaudit = -1000 Then
- arg_msg = '选项:[377]发料单使用明细车间审核流程,读取初始默认值失败,操作取消!'
- rslt = 0
- Goto ext
- End If
- 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 secflag = 1 THEN
- rslt = 0
- arg_msg = "单据已经过二审"
- GOTO ext
- END IF
- //SELECT count(*) INTO :cnt
- // FROM u_user
- // Where username = :publ_operator Using commit_transaction ;
- //IF commit_transaction.SQLCode <> 0 THEN
- // rslt = 0
- // arg_msg = "查询操作失败,操作员"
- // GOTO ext
- //END IF
- //
- //IF cnt = 0 THEN
- // rslt = 0
- // arg_msg = "操作员姓名未登记或已取消"
- // GOTO ext
- //END IF
- UPDATE u_outware
- SET secauditingrep = :publ_operator,
- secauditingdate = getdate(),
- secflag = 1
- WHERE u_outware.outwareid = :outwareid AND
- flag = 1 AND secflag = 0
- And scid = :scid Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致二审单据操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- ELSEIF commit_transaction.SQLNRows = 0 THEN
- rslt = 0
- arg_msg = "单据正在二审,请稍后查询。"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- //领料单审核自动生成车间进仓单
- IF uo_option_wkpmtrlware = 1 THEN
-
- IF relint_1 = 3 And uo_option_outware_scll_new_cj_mtrlware = 0 THEN
- GOTO end_inware
- END IF
- IF relint_1 = 4 And uo_option_scll_plan_wsaudit = 1 THEN
- GOTO end_inware
- END IF
-
-
-
- Long ll_wrkGrpid
- Long ll_storageid,ll_storageid_scid
- Long ll_inwareid,ll_inwareid_ws
- Long ll_pid
- Int li_ifwkpmtrlware
- Int li_iforder,li_ifover
- Decimal ld_qty_tmp,ld_uqty_tmp
-
- SELECT wrkGrpid INTO :ll_wrkGrpid
- FROM u_workgroup
- Where workgroupid = :relid Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '查询工作组所属工组失败'+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- IF ll_wrkGrpid = 0 THEN
- arg_msg = '领料组未设定所属工组'
- rslt = 0
- GOTO ext
- END IF
-
- SELECT u_sc_wkp.storageid,
- isnull(u_storage.scid,0),
- u_sc_wkp.ifwkpmtrlware,
- u_sc_workgroup.wrkgrpname
- INTO :ll_storageid,
- :ll_storageid_scid,
- :li_ifwkpmtrlware,
- :ls_wrkgrpname
- FROM u_sc_workgroup,u_storage,u_sc_wkp
- WHERE u_sc_workgroup.wrkGrpid = :ll_wrkGrpid
- AND u_sc_wkp.storageid = u_storage.storageid
- AND u_sc_wkp.wrkGrpid = u_sc_workgroup.storageid
- Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '查询工组所属车间所属仓库失败'+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- IF uo_option_inware_sc_location = 1 THEN
- ls_location = ls_wrkgrpname
- ELSE
- ls_location = ''
- END IF
-
- IF IsNull(ll_storageid) THEN ll_storageid = 0
- IF IsNull(ll_storageid_scid) THEN ll_storageid_scid = 0
- IF IsNull(li_ifwkpmtrlware) THEN li_ifwkpmtrlware = 0
-
- IF li_ifwkpmtrlware = 1 THEN
-
- IF ll_storageid = 0 THEN
- arg_msg = '领料组所属车间未指定仓库'
- rslt = 0
- GOTO ext
- END IF
-
- IF ll_storageid_scid <> scid THEN
- arg_msg = '领料车间对就仓库分部与单据分部不相符,请检查'
- rslt = 0
- GOTO ext
- END IF
- li_iforder = 0
- li_ifover = 0
-
- FOR i = 1 To it_mxbt
- IF outwaremx[i].relid > 0 THEN
- li_iforder = 1
- IF outwaremx[i].overqty > 0 THEN
- li_ifover = 1
- END IF
- ELSE
- li_ifover = 1
- END IF
- IF li_iforder = 1 And li_ifover = 1 THEN EXIT
- NEXT
-
- IF li_ifover = 1 THEN
- uo_inware uo_in
- uo_in = Create uo_inware
- uo_in.commit_transaction = commit_transaction
- uo_in.if_getid_ture = False
-
- IF uo_in.newbegin(scid,16,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- uo_in.indate = outdate
- uo_in.inrep = outrep
- uo_in.part = outwarecode
- uo_in.dscrp = dscrp
- uo_in.storageid = ll_storageid
- uo_in.sptname = '车间领料自动进仓(不按计划/超数量)'
-
- ll_pid = 0
-
- FOR i = 1 To it_mxbt
- ld_qty_tmp = 0
- ld_uqty_tmp = 0
- IF outwaremx[i].relid = 0 Or &
- ( outwaremx[i].relid > 0 And outwaremx[i].overqty > 0 ) THEN
- IF outwaremx[i].relid = 0 THEN
- ld_qty_tmp = outwaremx[i].qty
- ld_uqty_tmp = outwaremx[i].uqty
- ELSE
- ld_qty_tmp = outwaremx[i].overqty
- ld_uqty_tmp = outwaremx[i].overqty / outwaremx[i].rate
- END IF
- ELSE
- CONTINUE
- END IF
-
- ll_pid++
- IF uo_in.acceptmx(ll_pid,&
- outwaremx[i].mtrlid,&
- outwaremx[i].mtrlcode,&
- outwaremx[i].plancode,&
- outwaremx[i].status,&
- ld_uqty_tmp,&
- outwaremx[i].cost,&
- outwaremx[i].rebate,&
- outwaremx[i].mxdscrp,&
- arg_msg,&
- 0,0,0,&
- outwaremx[i].woodcode,&
- outwaremx[i].pcode,0,&
- outwaremx[i].unit,&
- outwaremx[i].rate,&
- ld_qty_tmp,&
- 0,0,'','',0,0,'',ls_location,&
- ld_uqty_tmp,&
- 0) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- NEXT
-
- IF ll_pid > 0 THEN
- IF uo_in.Save(False,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- ll_inwareid = uo_in.inwareid
-
- IF uo_in.getinfo(scid,ll_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
- END IF
- END IF
-
- IF li_iforder = 1 THEN
- uo_inware uo_in_ws
- uo_in_ws = Create uo_inware
- uo_in_ws.commit_transaction = commit_transaction
- uo_in_ws.if_getid_ture = False
-
- IF uo_in_ws.newbegin(scid,20,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- uo_in_ws.indate = outdate
- uo_in_ws.inrep = outrep
- uo_in_ws.part = outwarecode
- uo_in_ws.dscrp = dscrp
- uo_in_ws.storageid = ll_storageid
- uo_in_ws.sptname = '车间领料自动进仓(按计划)'
-
- ll_pid = 0
-
- FOR i = 1 To it_mxbt
- ld_qty_tmp = 0
- ld_uqty_tmp = 0
- IF outwaremx[i].relid > 0 THEN
- ld_qty_tmp = outwaremx[i].qty - outwaremx[i].overqty
- ld_uqty_tmp = (outwaremx[i].qty - outwaremx[i].overqty) / outwaremx[i].rate
- ELSE
- CONTINUE
- END IF
-
- ll_pid++
- IF uo_in_ws.acceptmx(ll_pid,&
- outwaremx[i].mtrlid,&
- outwaremx[i].mtrlcode,&
- outwaremx[i].plancode,&
- outwaremx[i].status,&
- ld_uqty_tmp,&
- outwaremx[i].cost,&
- outwaremx[i].rebate,&
- outwaremx[i].mxdscrp,&
- arg_msg,&
- 0,0,0,&
- outwaremx[i].woodcode,&
- outwaremx[i].pcode,0,&
- outwaremx[i].unit,&
- outwaremx[i].rate,&
- ld_qty_tmp,&
- 0,0,'','',0,0,'',ls_location,&
- ld_uqty_tmp,&
- 0) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- NEXT
-
- IF ll_pid > 0 THEN
- IF uo_in_ws.Save(False,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- ll_inwareid_ws = uo_in_ws.inwareid
-
- IF uo_in_ws.getinfo(scid,ll_inwareid_ws,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- IF uo_in_ws.auditing(False,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- END IF
- END IF
-
- UPDATE u_outware
- SET relint_2 = :ll_inwareid,
- relint_3 = :ll_inwareid_ws
- WHERE outwareid = :outwareid
- AND scid = :scid
- Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '更新出仓单失败'+'~n'+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- Destroy uo_in
- Destroy uo_in_ws
- END IF
- END IF
- end_inware:
- secflag = 1
- ext:
- IF rslt = 0 THEN
- ROLLBACK Using commit_transaction;
- ELSEIF rslt = 1 And arg_ifcommit THEN
- COMMIT Using commit_transaction;
- END IF
- RETURN rslt
- end function
- public function integer c_secauditing (boolean arg_ifcommit, ref string arg_msg);Int rslt = 1
- Long cnt = 0
- DateTime null_datetime
- IF uo_option_wkpmtrlware = -1000 THEN
- arg_msg = '选项:[057]生产使用车间核算,读取初始默认值失败,操作取消!'
- rslt = 0
- GOTO ext
- END IF
- IF uo_option_outware_scll_new_cj_mtrlware = -1000 THEN
- arg_msg = '选项:[355]其它领料单增加车间仓库存,读取初始默认值失败,操作取消!'
- rslt = 0
- GOTO ext
- END IF
- If uo_option_scll_plan_wsaudit = -1000 Then
- arg_msg = '选项:[377]发料单使用明细车间审核流程,读取初始默认值失败,操作取消!'
- rslt = 0
- Goto ext
- End If
- IF outwareid = 0 THEN
- rslt = 0
- arG_MSG = "没有撤审对象"
- GOTO ext
- END IF
- IF ctmint > 0 THEN
- arG_MSG = '单据已截数,不能操作'
- rslt = 0
- GOTO ext
- END IF
- IF secflag = 0 THEN
- rslt = 0
- arG_MSG = "该单据未二审,不能进行二级撤审"
- GOTO ext
- END IF
- SELECT count(*) INTO :cnt
- FROM u_user
- Where username = :publ_operator USING commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arG_MSG = "查询操作失败,操作员"
- GOTO ext
- END IF
- IF cnt = 0 THEN
- rslt = 0
- arG_MSG = "操作员姓名未登记或已取消"
- GOTO ext
- END IF
- SetNull(null_datetime)
- UPDATE u_outware
- SET secAuditingrep = '',
- secAuditingdate = :null_datetime,
- secflag = 0
- WHERE u_outware.outwareid = :outwareid
- AND scid = :scid USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arG_MSG = "因网络或其它原因导致二审单据操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- ELSEIF commit_transaction.SQLNRows = 0 THEN
- rslt = 0
- arG_MSG = "单据正在二审,请稍后查询。"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- //领料单撤销审核自动删除车间进仓单
- IF uo_option_wkpmtrlware = 1 THEN
- IF relint_1 = 3 And uo_option_outware_scll_new_cj_mtrlware = 0 THEN
- GOTO end_inware
- END IF
- IF relint_1 = 4 And uo_option_scll_plan_wsaudit = 0 THEN
- GOTO end_inware
- END IF
- IF relint_2 > 0 THEN
- uo_inware uo_in
- uo_in = CREATE uo_inware
- uo_in.commit_transaction = commit_transaction
-
- IF uo_in.getinfo(scid,relint_2,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(scid,relint_2,arG_MSG,FALSE) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- UPDATE u_outware
- SET relint_2 = 0
- WHERE outwareid = :outwareid
- AND scid = :scid
- USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arG_MSG = '更新出仓单失败'+'~n'+commit_transaction.SQLErrText
- GOTO ext
- END IF
- END IF
-
- IF relint_3 > 0 THEN
- uo_inware uo_in_ws
- uo_in_ws = CREATE uo_inware
- uo_in_ws.commit_transaction = commit_transaction
-
- IF uo_in_ws.getinfo(scid,relint_3,arG_MSG) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- IF uo_in_ws.c_auditing(FALSE,arG_MSG) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- IF uo_in_ws.del(scid,relint_3,arG_MSG,FALSE) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- UPDATE u_outware
- SET relint_3 = 0
- WHERE outwareid = :outwareid
- AND scid = :scid
- USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arG_MSG = '更新出仓单失败'+'~n'+commit_transaction.SQLErrText
- GOTO ext
- END IF
- END IF
-
- DESTROY uo_in_ws
- END IF
- end_inware:
- secflag = 0
- ext:
- IF rslt = 0 THEN
- ROLLBACK USING commit_transaction;
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT USING commit_transaction;
- END IF
- RETURN rslt
- end function
- public function integer priceaudit (boolean arg_ifcommit, ref string arg_msg);Long rslt = 1,i
- IF priceflag = 1 THEN
- rslt = 0
- arg_msg = "单据已经确认"
- GOTO ext
- END IF
- UPDATE u_outware
- SET priceemp = :publ_operator,
- pricedate = getdate(),
- priceflag = 1
- WHERE u_outware.outwareid = :outwareid
- AND priceflag = 0
- AND scid = :scid USING commit_transaction;
-
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致确认单据操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- ELSEIF commit_transaction.SQLNRows = 0 THEN
- rslt = 0
- arg_msg = "单据正在确认,请稍后查询。"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- priceflag = 1
- ext:
- IF rslt = 0 THEN
- ROLLBACK USING commit_transaction;
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT USING commit_transaction;
- END IF
- RETURN rslt
- end function
- public function integer c_priceaudit (boolean arg_ifcommit, ref string arg_msg);Long rslt = 1,i
- DateTime null_dt
- SetNull(null_dt)
- IF uo_option_confirmaudit_sale = -1000 THEN
- arg_msg = '选项:[025]销售发货单先确认后仓库审核,读取初始默认值失败,操作取消!'
- rslt = 0
- GOTO ext
- END IF
- IF priceflag = 0 THEN
- rslt = 0
- arg_msg = "单据还未确认,不能反确认"
- GOTO ext
- END IF
- IF uo_option_confirmaudit_sale = 1 THEN
- IF flag = 1 THEN
- rslt = 0
- arg_msg = "领料单已仓审,不能反确认"
- GOTO ext
- END IF
- END IF
- UPDATE u_outware
- SET priceemp = '',
- pricedate = :null_dt,
- priceflag = 0
- WHERE u_outware.outwareid = :outwareid
- AND priceflag = 1
- AND scid = :scid USING commit_transaction;
-
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致反确认单据操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- ELSEIF commit_transaction.SQLNRows = 0 THEN
- rslt = 0
- arg_msg = "单据正在反确认,请稍后查询。"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- priceflag = 0
- ext:
- IF rslt = 0 THEN
- ROLLBACK USING commit_transaction;
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT USING commit_transaction;
- END IF
- RETURN rslt
- end function
- public function integer uof_auto_secaudit (ref string arg_msg);Long ll_i
- Int rslt = 1
- Long ll_scid,ll_outwareid
- String ls_outwarecode
- datastore ds_scll
- ds_scll = Create datastore
- ds_scll.DataObject = 'ds_outware_scll_auto_secaudit'
- ds_scll.SetTransObject(commit_transaction)
- ds_scll.Retrieve()
- For ll_i = 1 To ds_scll.RowCount()
- ll_scid = ds_scll.Object.scid[ll_i]
- ll_outwareid = ds_scll.Object.outwareid[ll_i]
- ls_outwarecode = ds_scll.Object.outwarecode[ll_i]
-
- If getinfo(ll_scid,ll_outwareid,arg_msg) = 0 Then
- rslt = 0
- arg_msg = arg_msg + ls_outwarecode+' 审核失败,'+arg_msg + '~r~n'
- Continue
- End If
-
- If secauditing(True,arg_msg) = 0 Then
- rslt = 0
- arg_msg = arg_msg + ls_outwarecode+' 审核失败,'+arg_msg + '~r~n'
- Continue
- End If
- Next
- destroy ds_scll
- Return rslt
- end function
- public function integer wsauditing (long arg_scid, long arg_outwareid, long arg_printid, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
- Int li_flag,li_wsauditflag
- Decimal ld_planqty,ld_qty
- Decimal ld_trueoverqty,ld_wasteqty
- Long ll_relwsinwareid,ll_relwsoutwareid,ll_relid
- Long ll_wrkgrpid,ll_storageid,ll_storageid_scid
- String ls_wrkgrpname,ls_location
- Long ll_mtrlid
- String ls_mtrlcode,ls_plancode,ls_status,ls_woodcode,ls_pcode
- Decimal ld_cost,ld_rebate
- String ls_mxdscrp,ls_unit
- Long cnt
- DateTime server_dt
- String ls_overreason
- Long ll_mtrlwareid
- Decimal ld_price
- //判断选项
- If uo_option_scll_plan_wsaudit = -1000 Then
- arg_msg = '选项:[377]发料单使用明细车间审核流程,读取初始默认值失败,操作取消!'
- rslt = 0
- Goto ext
- End If
- If uo_option_scll_plan_wsaudit = 0 Then
- rslt = 0
- arg_msg = '选项[377]发料单使用明细车间审核流程设为否,不能使用明细车间审核/撤审功能'
- Goto ext
- End If
- Select Top 1 getdate() Into :server_dt From u_user Using commit_transaction ;
- //取得系统时间,借用操作员表
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = "查询操作失败,日期 "
- Goto ext
- End If
- //判断单据是否已仓审,是否已做过车间审
- Select u_outware.flag,
- u_outwaremx.wsauditflag,
- u_outwaremx.planqty,
- u_outwaremx.qty,
- u_outwaremx.trueoverqty,
- u_outware.relid,
- u_outwaremx.mtrlid,
- u_mtrldef.mtrlcode,
- u_outwaremx.plancode,
- u_outwaremx.status,
- u_outwaremx.woodcode,
- u_outwaremx.pcode,
- u_outwaremx.cost,
- u_outwaremx.rebate,
- u_outwaremx.mxdscrp,
- u_mtrldef.unit,
- u_outwaremx.overreason
- Into :li_flag,
- :li_wsauditflag,
- :ld_planqty,
- :ld_qty,
- :ld_trueoverqty,
- :ll_relid,
- :ll_mtrlid,
- :ls_mtrlcode,
- :ls_plancode,
- :ls_status,
- :ls_woodcode,
- :ls_pcode,
- :ld_cost,
- :ld_rebate,
- :ls_mxdscrp,
- :ls_unit,
- :ls_overreason
- From u_outwaremx Inner JOIN
- u_outware ON u_outwaremx.scid = u_outware.scid And
- u_outwaremx.outwareid = u_outware.outwareid Inner JOIN
- u_mtrldef ON u_outwaremx.mtrlid = u_mtrldef.mtrlid
- Where u_outwaremx.scid = :arg_scid
- And u_outwaremx.outwareid = :arg_outwareid
- And u_outwaremx.printid = :arg_printid Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '查询发料单信息失败,'+commit_transaction.SQLErrText
- Goto ext
- End If
- If li_flag <> 1 Then
- rslt = 0
- arg_msg = '单据未执行仓审,不能进行车间审'
- Goto ext
- End If
- If li_wsauditflag = 1 Then
- rslt = 0
- arg_msg = '明细已执行过车间审,不能重复执行'
- Goto ext
- End If
- ld_wasteqty = ld_qty - ld_planqty - ld_trueoverqty
- If ld_qty - ld_planqty > 0 Or ld_wasteqty > 0 Then
-
- If getinfo(arg_scid,arg_outwareid,arg_msg) = 0 Then
- rslt = 0
- Goto ext
- End If
-
- Select wrkGrpid Into :ll_wrkGrpid
- From u_workgroup
- Where workgroupid = :relid Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '查询工作组所属工组失败'+"~n"+commit_transaction.SQLErrText
- Goto ext
- End If
-
- If ll_wrkgrpid = 0 Then
- arg_msg = '领料组未设定所属工组'
- rslt = 0
- Goto ext
- End If
-
- Select u_sc_wkp.storageid,
- isnull(u_storage.scid,0),
- u_sc_workgroup.wrkgrpname
- Into :ll_storageid,
- :ll_storageid_scid,
- :ls_wrkgrpname
- From u_sc_workgroup,u_storage,u_sc_wkp
- Where u_sc_workgroup.wrkGrpid = :ll_wrkGrpid
- And u_sc_wkp.storageid = u_storage.storageid
- And u_sc_wkp.wrkGrpid = u_sc_workgroup.storageid
- Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '查询工组所属车间所属仓库失败'+"~n"+commit_transaction.SQLErrText
- Goto ext
- End If
-
- If uo_option_inware_sc_location = 1 Then
- ls_location = ls_wrkgrpname
- Else
- ls_location = ''
- End If
-
- If IsNull(ll_storageid) Then ll_storageid = 0
- If IsNull(ll_storageid_scid) Then ll_storageid_scid = 0
-
- If ll_storageid = 0 Then
- arg_msg = '领料组所属车间未指定仓库'
- rslt = 0
- Goto ext
- End If
-
- If ll_storageid_scid <> scid Then
- arg_msg = '领料车间对就仓库分部与单据分部不相符,请检查'
- rslt = 0
- Goto ext
- End If
-
-
- If ld_qty - ld_planqty > 0 Then
- uo_inware uo_in
- uo_in = Create uo_inware
- uo_in.commit_transaction = commit_transaction
- uo_in.if_getid_ture = False
-
- If uo_in.newbegin(scid,16,arg_msg) = 0 Then
- rslt = 0
- Goto ext
- End If
-
- uo_in.indate = server_dt
- uo_in.inrep = publ_operator
- uo_in.part = outwarecode
- uo_in.dscrp = ''
- uo_in.storageid = ll_storageid
- uo_in.sptname = '发料单车间审核自动进仓/损耗出仓'
- uo_in.relint_3 = outwareid
-
-
- //生成相关单据
- cnt++
- If uo_in.acceptmx(cnt,&
- ll_mtrlid,&
- ls_mtrlcode,&
- ls_plancode,&
- ls_status,&
- ld_qty - ld_planqty,&
- ld_cost,&
- ld_rebate,&
- ls_mxdscrp,&
- arg_msg,&
- 0,0,0,&
- ls_woodcode,&
- ls_pcode,0,&
- ls_unit,&
- 1,&
- ld_qty - ld_planqty,&
- 0,0,'','',0,0,'',ls_location,&
- ld_qty - ld_planqty,&
- 0) = 0 Then
- arg_msg = '建立相关自动车间进仓单失败,' + arg_msg
- rslt = 0
- Goto ext
- End If
-
-
- If uo_in.Save(False,arg_msg) = 0 Then
- arg_msg = '建立相关自动车间进仓单失败,' + arg_msg
- rslt = 0
- Goto ext
- End If
-
- ll_relwsinwareid = uo_in.inwareid
-
- If uo_in.getinfo(scid,ll_relwsinwareid,arg_msg) = 0 Then
- arg_msg = '审核相关自动车间进仓单失败,' + arg_msg
- rslt = 0
- Goto ext
- End If
-
- If uo_in.auditing(False,arg_msg) = 0 Then
- arg_msg = '审核相关自动车间进仓单失败,' + arg_msg
- rslt = 0
- Goto ext
- End If
- End If
-
- If ld_wasteqty > 0 Then
- uo_outware uo_out_ws
- uo_out_ws = Create uo_outware
- uo_out_ws.commit_transaction = commit_transaction
- uo_out_ws.if_getid_ture = False
-
- If uo_out_ws.newbegin(scid,25,arg_msg) = 0 Then
- rslt = 0
- Goto ext
- End If
-
- uo_out_ws.outdate = server_dt
- uo_out_ws.outrep = publ_operator
- uo_out_ws.part = outwarecode
- uo_out_ws.dscrp = ls_overreason
- uo_out_ws.cusname = '发料单损耗出仓'
- uo_out_ws.storageid = ll_storageid
-
- Select top 1 u_mtrlware.mtrlwareid,
- u_mtrlware.cost
- Into :ll_mtrlwareid,
- :ld_price
- From u_mtrlware
- Where u_mtrlware.storageid = :ll_storageid
- And u_mtrlware.mtrlid = ll_mtrlid
- And u_mtrlware.status = ls_status
- And u_mtrlware.woodcode = ls_woodcode
- And u_mtrlware.pcode = ls_pcode
- Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- ll_mtrlwareid = 0
- ld_price = 0
- If f_insert_0_mtrlware(ll_mtrlwareid,ll_mtrlid,ls_mtrlcode,ll_storageid,0,ls_status,ls_woodcode,ls_pcode,'','','',0,arg_msg) = 0 Then
- arg_msg = '发料损耗单>>增加车间仓0库存失败,'+arg_msg
- rslt = 0
- Goto ext
- End If
- End If
-
- If uo_out_ws.acceptmx(ll_mtrlwareid,ld_wasteqty,&
- ld_price,1,'',1,arg_msg,&
- 0,0,0,0,'',0,0,ls_unit,ld_wasteqty,1,'','',0,0,'',0,0,0,0,'','') = 0 Then
- arg_msg = '发料损耗单>>物料'+ls_mtrlcode+','+arg_msg
- rslt = 0
- Goto ext
- End If
-
- If uo_out_ws.Save(False,arg_msg) = 0 Then
- arg_msg = '自动发料损耗单建立失败,'+arg_msg
- rslt = 0
- Goto ext
- End If
-
- ll_relwsoutwareid = uo_out_ws.outwareid
-
- //2.原事务审核出仓单
- If uo_out_ws.getinfo(scid,ll_relwsoutwareid,arg_msg) = 0 Then
- rslt = 0
- Goto ext
- End If
-
- If uo_out_ws.auditing(False,arg_msg) = 0 Then
- arg_msg = '发料损耗单审核失败,'+arg_msg
- rslt = 0
- Goto ext
- End If
-
- End If
-
- End If
- Update u_outwaremx
- Set u_outwaremx.wsauditflag = 1,
- u_outwaremx.wsauditemp = :publ_operator,
- u_outwaremx.wsauditdate = getdate(),
- u_outwaremx.relwsinwareid = :ll_relwsinwareid,
- u_outwaremx.relwsoutwareid = :ll_relwsoutwareid
- Where u_outwaremx.scid = :arg_scid
- And u_outwaremx.outwareid = :arg_outwareid
- And u_outwaremx.printid = :arg_printid Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '更新单据明细车间审状态失败,'+commit_transaction.SQLErrText
- Goto ext
- End If
- ext:
- Destroy uo_in
- Destroy uo_out_ws
- If rslt = 0 Then
- Rollback Using commit_transaction;
- ElseIf rslt = 1 And arg_ifcommit Then
- Commit Using commit_transaction;
- End If
- Return rslt
- end function
- public function integer wscauditing (long arg_scid, long arg_outwareid, long arg_printid, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
- DateTime null_dt
- SetNull(null_dt)
- Long ll_relwsinwareid,ll_relwsoutwareid
- Int li_wsauditflag,li_cwauditflag
- //判断选项
- If uo_option_scll_plan_wsaudit = -1000 Then
- arg_msg = '选项:[377]发料单使用明细车间审核流程,读取初始默认值失败,操作取消!'
- rslt = 0
- Goto ext
- End If
- If uo_option_scll_plan_wsaudit = 0 Then
- rslt = 0
- arg_msg = '选项[377]发料单使用明细车间审核流程设为否,不能使用明细车间审核/撤审功能'
- Goto ext
- End If
- //判断单据是否已仓审,是否已做过车间审
- Select u_outwaremx.wsauditflag,
- u_outwaremx.cwauditflag,
- u_outwaremx.relwsinwareid,
- u_outwaremx.relwsoutwareid
- Into :li_wsauditflag,
- :li_cwauditflag,
- :ll_relwsinwareid,
- :ll_relwsoutwareid
- From u_outwaremx Inner JOIN
- u_outware ON u_outwaremx.scid = u_outware.scid And
- u_outwaremx.outwareid = u_outware.outwareid Inner JOIN
- u_mtrldef ON u_outwaremx.mtrlid = u_mtrldef.mtrlid
- Where u_outwaremx.scid = :arg_scid
- And u_outwaremx.outwareid = :arg_outwareid
- And u_outwaremx.printid = :arg_printid Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '查询发料单信息失败,'+commit_transaction.SQLErrText
- Goto ext
- End If
- If li_cwauditflag = 1 Then
- rslt = 0
- arg_msg = '明细已执行财务审,不能撤车间审'
- Goto ext
- End If
- If li_wsauditflag = 0 Then
- rslt = 0
- arg_msg = '明细未进行车间审,不能撤审'
- Goto ext
- End If
- If ll_relwsinwareid > 0 Then
- uo_inware uo_in
- uo_in = Create uo_inware
- uo_in.commit_transaction = commit_transaction
-
- If uo_in.getinfo(arg_scid,ll_relwsinwareid,arg_msg) = 0 Then
- arg_msg = '删除相关自动车间进仓单失败,' + arg_msg
- rslt = 0
- Goto ext
- End If
-
- If uo_in.c_auditing(False,arg_msg) = 0 Then
- arg_msg = '删除相关自动车间进仓单失败,' + arg_msg
- rslt = 0
- Goto ext
- End If
-
- If uo_in.del(arg_scid,ll_relwsinwareid,arg_msg,False) = 0 Then
- arg_msg = '删除相关自动车间进仓单失败,' + arg_msg
- rslt = 0
- Goto ext
- End If
- End If
- If ll_relwsoutwareid > 0 Then
- uo_outware uo_out
- uo_out = Create uo_outware
- uo_out.commit_transaction = commit_transaction
-
- If uo_out.getinfo(arg_scid,ll_relwsoutwareid,arg_msg) = 0 Then
- arg_msg = '删除相关自动发料损耗单失败,' + arg_msg
- rslt = 0
- Goto ext
- End If
-
- If uo_out.c_auditing(False,arg_msg) = 0 Then
- arg_msg = '删除相关自动发料损耗单失败,' + arg_msg
- rslt = 0
- Goto ext
- End If
-
- If uo_out.del(arg_scid,ll_relwsoutwareid,0,arg_msg,False) = 0 Then
- arg_msg = '删除相关自动发料损耗单失败,' + arg_msg
- rslt = 0
- Goto ext
- End If
-
- End If
- Update u_outwaremx
- Set u_outwaremx.wsauditflag = 0,
- u_outwaremx.wsauditemp = '',
- u_outwaremx.wsauditdate = :null_dt,
- u_outwaremx.relwsinwareid = 0,
- u_outwaremx.relwsoutwareid = 0
- Where u_outwaremx.scid = :arg_scid
- And u_outwaremx.outwareid = :arg_outwareid
- And u_outwaremx.printid = :arg_printid
- Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '更新单据明细车间审状态失败,'+commit_transaction.SQLErrText
- Goto ext
- End If
- ext:
- Destroy uo_in
- Destroy uo_out
- If rslt = 0 Then
- Rollback Using commit_transaction;
- ElseIf rslt = 1 And arg_ifcommit Then
- Commit Using commit_transaction;
- End If
- Return rslt
- end function
- public function integer cauditing_cw (long arg_scid, long arg_outwareid, long arg_printid, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
- DateTime null_dt
- SetNull(null_dt)
- Int li_wsauditflag,li_cwauditflag
- //判断选项
- If uo_option_scll_plan_wsaudit = -1000 Then
- arg_msg = '选项:[377]发料单使用明细车间审核流程,读取初始默认值失败,操作取消!'
- rslt = 0
- Goto ext
- End If
- If uo_option_scll_plan_wsaudit = 0 Then
- rslt = 0
- arg_msg = '选项[377]发料单使用明细车间审核流程设为否,不能使用明细财务审核/撤审功能'
- Goto ext
- End If
- //判断单据是否已仓审,是否已做过车间审
- Select u_outwaremx.wsauditflag,
- u_outwaremx.cwauditflag
- Into :li_wsauditflag,
- :li_cwauditflag
- From u_outwaremx Inner JOIN
- u_outware ON u_outwaremx.scid = u_outware.scid And
- u_outwaremx.outwareid = u_outware.outwareid Inner JOIN
- u_mtrldef ON u_outwaremx.mtrlid = u_mtrldef.mtrlid
- Where u_outwaremx.scid = :arg_scid
- And u_outwaremx.outwareid = :arg_outwareid
- And u_outwaremx.printid = :arg_printid Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '查询发料单信息失败,'+commit_transaction.SQLErrText
- Goto ext
- End If
- If li_cwauditflag = 0 Then
- rslt = 0
- arg_msg = '明细未进行财务审,不能撤审'
- Goto ext
- End If
- Update u_outwaremx
- Set u_outwaremx.cwauditflag = 0,
- u_outwaremx.cwauditemp = '',
- u_outwaremx.cwauditdate = :null_dt
- Where u_outwaremx.scid = :arg_scid
- And u_outwaremx.outwareid = :arg_outwareid
- And u_outwaremx.printid = :arg_printid
- Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '更新单据明细财务审状态失败,'+commit_transaction.SQLErrText
- Goto ext
- End If
- ext:
- If rslt = 0 Then
- Rollback Using commit_transaction;
- ElseIf rslt = 1 And arg_ifcommit Then
- Commit Using commit_transaction;
- End If
- Return rslt
- end function
- public function integer auditing_cw (long arg_scid, long arg_outwareid, long arg_printid, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
- Int li_flag,li_wsauditflag,li_cwauditflag
- //判断选项
- If uo_option_scll_plan_wsaudit = -1000 Then
- arg_msg = '选项:[377]发料单使用明细车间审核流程,读取初始默认值失败,操作取消!'
- rslt = 0
- Goto ext
- End If
- If uo_option_scll_plan_wsaudit = 0 Then
- rslt = 0
- arg_msg = '选项[377]发料单使用明细车间审核流程设为否,不能使用明细财务审核/撤审功能'
- Goto ext
- End If
- //判断单据是否已仓审,是否已做过车间审
- Select u_outware.flag,
- u_outwaremx.wsauditflag,
- u_outwaremx.cwauditflag
- Into :li_flag,
- :li_wsauditflag,
- :li_cwauditflag
- From u_outwaremx Inner JOIN
- u_outware ON u_outwaremx.scid = u_outware.scid And
- u_outwaremx.outwareid = u_outware.outwareid Inner JOIN
- u_mtrldef ON u_outwaremx.mtrlid = u_mtrldef.mtrlid
- Where u_outwaremx.scid = :arg_scid
- And u_outwaremx.outwareid = :arg_outwareid
- And u_outwaremx.printid = :arg_printid Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '查询发料单信息失败,'+commit_transaction.SQLErrText
- Goto ext
- End If
- If li_flag <> 1 Then
- rslt = 0
- arg_msg = '单据未执行仓审,不能进行车间审'
- Goto ext
- End If
- If li_wsauditflag = 0 Then
- rslt = 0
- arg_msg = '明细未执行车间审,不能财务审'
- Goto ext
- End If
- If li_cwauditflag = 1 Then
- rslt = 0
- arg_msg = '明细已执行过财务审,不能重复执行'
- Goto ext
- End If
- Update u_outwaremx
- Set u_outwaremx.cwauditflag = 1,
- u_outwaremx.cwauditemp = :publ_operator,
- u_outwaremx.cwauditdate = getdate()
- Where u_outwaremx.scid = :arg_scid
- And u_outwaremx.outwareid = :arg_outwareid
- And u_outwaremx.printid = :arg_printid Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '更新单据明细财务审状态失败,'+commit_transaction.SQLErrText
- Goto ext
- End If
- ext:
- If rslt = 0 Then
- Rollback Using commit_transaction;
- ElseIf rslt = 1 And arg_ifcommit Then
- Commit Using commit_transaction;
- End If
- Return rslt
- end function
- on uo_outware_scll.create
- call super::create
- end on
- on uo_outware_scll.destroy
- call super::destroy
- end on
- event constructor;call super::constructor;
- String arg_msg
- String str_optionvalue
- str_optionvalue = ''
- f_get_sys_option_value('057',str_optionvalue,arg_msg)
- uo_option_wkpmtrlware = Long(str_optionvalue)
- str_optionvalue = ''
- f_get_sys_option_value('151',str_optionvalue,arg_msg)
- uo_option_inware_sc_location = Long(str_optionvalue)
- str_optionvalue = ''
- f_get_sys_option_value('355',str_optionvalue,arg_msg)
- uo_option_outware_scll_new_cj_mtrlware = Long(str_optionvalue)
- str_optionvalue = ''
- f_get_sys_option_value('377',str_optionvalue,arg_msg)
- uo_option_scll_plan_wsaudit = Long(str_optionvalue)
- end event
|