,Case When a.ConfirmUserClass='PG' Then '程序' When a.ConfirmUserClass='PE' Then '承辦人' When a.ConfirmUserClass='Leader' Then '主管' else '其他' End as ConfirmUserClass
,Case When a.ConfirmMethod='CF' Then '確認' When a.ConfirmMethod='RJ' Then '退回' When a.ConfirmMethod='RV' Then '撤回' else '其他' End as ConfirmMethod
,a.Create_time,a.Create_User_id,b.Step_Text as ""From"",c.Step_Text as ""To"",a.Description
from esn_Todos_flow_his a
left
join esn_todos_Flow_StepType b on a.FromType_id = b.id
left
join esn_todos_Flow_StepType c on a.ToType_id = c.id
sqlstr=@"select distinct td.SN, case_id, finishedDate as finish_date, attorneyDueDate as int_due_date,
LegalDueDate as legal_due_date, todosStatus_name as todos_status_name, taskDescription as taskName, assignedTo_userID,
AssignStatus_name,Points as point_num,
Case When pointsType='POINT' Then '點數' When pointsType='AMT' Then '金額' When ISNULL(PointsType,'')='MP' Then '加乘點數' Else '點數' END as point_type
, '' as point_note, proc_id, matter_name
,case when (ISNULL(points,0)<>0 AND ISNULL(PointsType,'') <>'MP') AND ISNULL(exchangeRate,0)=0 THEn 1 ELSE ISNULL(exchangeRate,0) END as exchangeRate
from esn_Todos td where td.SN in ("+SN+")";
sqlstr="select distinct td.*, tds.date_points_settlement, tds.date_points_settlement_pic_confirm from ("+sqlstr+") td left join esn_todos_points tds on tds.sn=td.sn ";
//'gDebugha_wade(sqlstr)
//'---+ 承辦人員
sqlstr="select t11.*, isnull(ui1.cn_name, ' ') as cn_name from ("+sqlstr+") t11 left join s_user_info ui1 on ui1.user_id=t11.assignedTo_userID";
//sqlstr = sqlstr & " finish_date as 完成日, int_due_date as 事務所到期日, 'tdr' as class_1, point_num as 點數,point_type as 點數類型, 'LL' as class_assignStatus, AssignStatus_name as '指派狀態', 'tdr' as class_1, exchangeRate as 評分, 'date_points_settlement' as class_2, date_points_settlement as 點數結算日, Flow_id as attr_Flowid,isnull(Map_Class,'PG') as attr_MapClass ,StepType_id_Previous as attr_StepTypeidPrevious ,Is_Settlement as attr_IsSettlement,isnull(StepType_id,'1') as 目前結算流程, 'checkbox2' as attr_type,'Field_PG' AS class_c1, (case when PG_IsConfirm =1 then 1 else null end) as 程序已確認, 'checkbox2' as attr_type ,'Field_PE' AS class_c2 ,(case when PE_IsConfirm =1 then 1 else null end) as 承辦人已確認, 'checkbox2' as attr_type ,'Field_Leader' AS class_c3, (case when Leader_IsConfirm =1 then 1 else null end) as 主管已確認,Description as 退回原因, date_points_settlement_pic_confirm as attr_title, 'checkbox2' as attr_type, 'date_points_settlement_pic_confirm' as class_3 /* , case when date_points_settlement_pic_confirm is null then null else 1 end as 確認結算, point_note as 備註 */ "