显示批准和待处理的文件

Posted

技术标签:

【中文标题】显示批准和待处理的文件【英文标题】:show approve and pending documents 【发布时间】:2014-02-03 15:01:35 【问题描述】:

当用户上传文件然后文件保存在这个表中并将值设置为3意味着这是在等待

 DocID      DocName UploadedDate    Uploadfile  DocTypeID   DepID   ApproveID    UploadedBy UserID  
36        erp system 2014-02-03     Presentation1.pptx  1    4        3           noreen    21  

当主管批准/拒绝此文件时,则将批准更改为 1,例如批准

所以我想在第一个用户上传文件时显示,然后他/她查看文件,哪些文件正在审核、批准和拒绝

这是我尝试的sp

ALTER procedure [dbo].[UserIDDoc]

@UserID int
as
Select 
 dbo.DocumentInfo.DocID as DocumentID, 
   dbo.DocumentInfo.DocName as DocumentName, 
 dbo.DocumentInfo.UploadedDate as UploadedDate,
 dbo.DocType.DocType as Document, 

 dbo.Department.DepType as Department, 
dbo.DocumentInfo.Uploadfile as FileUploaded,

 dbo.ApproveType.ApproveType AS Status 

FROM 
dbo.DocumentInfo
inner JOIN dbo.DocType ON dbo.DocumentInfo.DocTypeID=dbo.DocType.DocTypeID
inner JOIN dbo.Department ON dbo.DocumentInfo.DepID=dbo.Department.DepID

left join dbo.ApproveType on dbo.DocumentInfo.ApproveID=dbo.ApproveType.ApproveID
INNER JOIN dbo.Approval ON dbo.DocumentInfo.DocID = dbo.Approval.DocID 

 where UserID=@UserID AND dbo.Approval.DesigID = 3

但是当我执行这个 sp 时,它会像这样显示我

DocumentID  DocumentName    UploadedDate    Document    Department       FileUploaded                               Status
    36          ERP SYSTEM       2014-01-20     MSWord  Computer Science    system admin first assignment.docx  Pending
    36          ERP SYSTEM      2014-01-20  MSWord  Computer Science    system admin first assignment.docx  Pending
    36          ERP SYSTEM      2014-01-20  MSWord  Computer Science    system admin first assignment.docx  Pending
    39           def          2014-01-22    MSWord  Human Resource  BISE RAWALPINDI.docx                  Approve

但我想要这个

DocumentID  DocumentName    UploadedDate    Document    Department       FileUploaded                     Status
 36         ERP SYSTEM      2014-01-20  MSWord  Computer Science    system admin first assignment.docx  Pending
 39          def          2014-01-22    MSWord  Human Resource  BISE RAWALPINDI.docx                  Approve

【问题讨论】:

【参考方案1】:

尝试添加 DISTINCT 关键字

 Select DISTINCT 
         dbo.DocumentInfo.DocID as DocumentID,    
         dbo.DocumentInfo.DocName as DocumentName,  
         dbo.DocumentInfo.UploadedDate as UploadedDate,  
         dbo.DocType.DocType as Document, 
         dbo.Department.DepType as Department,  
         dbo.DocumentInfo.Uploadfile as FileUploaded,
         dbo.ApproveType.ApproveType AS Status 
 FROM  dbo.DocumentInfo 
 inner JOIN dbo.DocType    ON  dbo.DocumentInfo.DocTypeID=dbo.DocType.DocTypeID 
 inner JOIN dbo.Department ON dbo.DocumentInfo.DepID=dbo.Department.DepID
 left join dbo.ApproveType on dbo.DocumentInfo.ApproveID=dbo.ApproveType.ApproveID 
 INNER JOIN  dbo.Approval ON dbo.DocumentInfo.DocID = dbo.Approval.DocID     
 where UserID=@UserID AND dbo.Approval.DesigID = 3

【讨论】:

DISTINCT 关键字告诉 SQL 只显示一行而不是多行,所有列都相同【参考方案2】:

使用SQL Distinct Statement

【讨论】:

您能否提供更多信息来说明为什么这是一个好主意?应该如何使用。等等。仅链接的答案在 SO 上不受欢迎。

以上是关于显示批准和待处理的文件的主要内容,如果未能解决你的问题,请参考以下文章

使用空闲实例和待处理延迟设置调整 AppEngine 性能

如何根据类别实现带有节头的RecyclerView?

异常体系与项目实践

詹金斯管道的企业社会责任批准

个推推送处理

使用 classNames 模块动态设置类不起作用