
     /**
 **  子任务查询 视图
 **/
  IF EXISTS(SELECT 1 FROM sys.views WHERE name='TaskView') 
   DROP VIEW TaskView
GO 
CREATE VIEW TaskView
AS

SELECT   dbo.PartTask.id, dbo.PartTask.maintaskid, dbo.MainTask.sendtime, dbo.MainTask.status, dbo.MainTask.tasktype, 
                dbo.MainTask.finishstatus, dbo.PartTask.sourceplace, dbo.PartTask.type, dbo.PartTask.toplace, 
                dbo.PartTask.status AS partstatus, dbo.PartTask.updatetime, dbo.PartTask.eqname, dbo.PartTask.eqid, 
                dbo.PartTask.iscurrent,
				case dbo.PartTask.iscurrent
				when 1 then '是'
				else  '否' end as  iscurrentText,-- 是否当前任务
				dbo.PartTask.ishandled,
				case dbo.PartTask.ishandled
				when 1 then '已处理'
				else  '未处理' end as  ishandledText,-- 是否处理
				dbo.PartTask.isreleased,
				case dbo.PartTask.isreleased
				when 1 then '已下发'
				else  '未下发' end as  isreleasedText,-- 是否下发
				dbo.PartTask.isfinished, 
				case dbo.PartTask.isfinished
				when 1 then '已完成'
				else  '未完成' end as  isfinishedText,-- 是否完成
                dbo.PartTask.taskcode, 
				dbo.PartTask.containertype, 
				
				dbo.PartTask.targetplace, dbo.PartTask.nexthandel, 
                dbo.PartTask.heighttype, dbo.PartTask.storageno, dbo.MainTask.taskno, dbo.PartTask.containername, 
                dbo.PartTask.filereason, dbo.PartTask.issueTime, dbo.PartTask.finishTime, dbo.PartTask.plcReceiveTime, 
                dbo.PartTask.isPersonHandler, 
				case dbo.PartTask.isPersonHandler
				when 1 then '是'
				else  '否' end as  isPersonHandlerText,-- 是否人工处理
				
				dbo.PartTask.createtime,
				'' as containertypeText,'' as nexthandelText
FROM      dbo.PartTask LEFT OUTER JOIN
                dbo.MainTask ON dbo.PartTask.maintaskid = dbo.MainTask.id

Go


/**
 **  主任务查询 视图
 **/
  IF EXISTS(SELECT 1 FROM sys.views WHERE name='MainTaskView') 
   DROP VIEW MainTaskView
GO 
CREATE VIEW MainTaskView
AS

SELECT   dbo.MainTask.*,
				'' as  isfinishedText,-- 是否完成
				
				'' as containertypeText,'' as tasktypeText,'' as statusText
FROM      dbo.MainTask WITH(NOLOCK)

Go