IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[proj_view_show_schedule]') AND type = 'P')
DROP PROCEDURE [dbo].[proj_view_show_schedule]
GO

CREATE proc [dbo].[proj_view_show_schedule]
as
begin

set nocount on ;




select jh.ord_id as[主表ID], mx.ord2_id as[明细ID],jh.ord_no as [业务单号],
jh.ord_ygtx as [员工体系],jh.ord_createdepart as [建单部门],
da.ord_gh as [建单人工号],jh.ord_creator as [建单人],
da.ord_zhij as [职级],
CONVERT(varchar(100), jh.ord_ksrq , 23)as [开始日期],
CONVERT(varchar(100), jh.ord_jsrq , 23)as [结束日期],
jh.ord_jhym as [行程说明],
jh.ord_bz as [备注],mx.ord2_xclx as [行程类型],
CONVERT(varchar(100), mx.ord2_kssj , 23) as [行程开始时间],
CONVERT(varchar(100),  mx.ord2_jssj  , 23) as [行程结束时间], 
mx.ord2_xcmdd as [行程目的地],mx.ord2_xcms as [行程说明],
mx.ord2_status as [行程状态],
CONVERT(varchar(100),  dk.ord_sjdqsj  , 111) as  [打卡日期],
CONVERT(varchar(100),  dk.ord_sjdqsj,8) as [打卡时间],  
dk.ord_dkdd as [打卡地点],dk.ord_ycxc as [异常说明],
(case when isnull(dk.ord_photos,'')='' then NULL else 'http://ebs.shesyea.com.cn'+dbo.[chaifenlie](dk.ord_photos,'|',1) end) firstphoto,
(case when dbo.[chaifenlie](dk.ord_photos,'|',1)=dbo.[chaifenlie](dk.ord_photos,'|',2) then NULL else 'http://ebs.shesyea.com.cn'+dbo.[chaifenlie](dk.ord_photos,'|',2) end) secondphoto,
(case when dbo.[chaifenlie](dk.ord_photos,'|',2)=dbo.[chaifenlie](dk.ord_photos,'|',3) then NULL else 'http://ebs.shesyea.com.cn'+dbo.[chaifenlie](dk.ord_photos,'|',3) end) thirdphoto
from order_89 jh,order_40 da,mps_employee cu,order_89_2 mx 
left join order_91 dk 
on ord2_id = dk.ord_xcmxord2id 
wherejh.ord_id = mx.ord2_ordid 
and jh.ord_createcuid = cu.cu_id
and cu.cu_code = da.ord_gh
and jh.ord_status = '已完成'
--and dk.ord_createcuid = cu.cu_id
set nocount off;

end