ALTERprocedure[dbo].[procMaterialOrderItems_log_AllList]@sessionvarchar(30),@ipvarchar(30),@order_novarchar(225),--生产任务单编号@material_receipt_novarchar(225),--收料通知请检单@product_novarchar(225),--零部件编号@operatorvarchar(200),--操作人@begin_datevarchar(50),@end_datevarchar(50),@page_sizeint,@page_indexint,@totalint output,@rescodeint=-1 output ,@resdescvarchar(200)='' output
asbegin try
exec __Check @session,nullif@begin_date=''set@begin_date=nullif@end_date=''set@end_date=nulldeclare@SkipSizeintset@SkipSize=@page_size*(@page_index-1);declare@sql nvarchar(max),@sqlwhere nvarchar(max),@fields nvarchar(max),@strwherevarchar(max)set@sqlwhere=dbo.__SQL_CONDITION(@sqlwhere,'orderNo',quotename('%'+@order_no+'%',''''),'like','and');set@sqlwhere=dbo.__SQL_CONDITION(@sqlwhere,'quality_checking_no',quotename('%'+@material_receipt_no+'%',''''),'like','and');set@sqlwhere=dbo.__SQL_CONDITION(@sqlwhere,'tFNumberCP',quotename('%'+@product_no+'%',''''),'like','and');set@sqlwhere=dbo.__SQL_CONDITION(@sqlwhere,'operatorName',quotename('%'+@operator+'%',''''),'like','and');set@sqlwhere=dbo.__SQL_CONDITION(@sqlwhere,'create_date',quotename(''+@begin_date+'',''''),'>=','and');set@sqlwhere=dbo.__SQL_CONDITION(@sqlwhere,'create_date',quotename(''+@end_date+'',''''),'<=','and');set@sqlwhere=dbo.__SQL_WHERE(@sqlwhere)if@sqlwhere=''set@strwhere=' where 'elseset@strwhere=@sqlwhere+' and 'exec@total=__SQL_GetCount 'v_material_order_items_log',@sqlwhereset@fields='top '+ cast(@page_sizeasvarchar)+'id,orderNo as order_no,tFNumberCP as product_no,tFNumberWL as item_no,spec,quality_checking_no,datet as manufacture_date,batchNo,qty,create_date,repertoryName,positionName,productName,ItemName,operatorName,item_key,order_key'set@sql='select distinct '+@fields+' from dbo.v_material_order_items_log '+@strwhere+' id not in (select top '+cast(@SkipSizeasvarchar)+'id from dbo.v_material_order_items_log '+@sqlwhere+' order by create_date desc )order by create_date desc 'exec sp_executesql @sql;set@rescode=0;set@resdesc='success';end try
begin catch
exec __Exception '获取领料单日志列表失败',@rescode output,@resdesc output
end catch;