$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