SELECT u.org_name AS '分公司', u.case_no AS '报案号', u.loss_id AS '车易赔任务ID',
(CASE WHEN u.loss_type='1' THEN '查勘' WHEN u.loss_type='2' THEN '定损' ELSE '' END )AS '任务类型',
u.license_no AS '车牌号',
(CASE WHEN u.user_type='1' THEN '修理厂端' WHEN u.user_type='2' THEN '查勘员端' WHEN u.user_type='3' THEN '客户端' ELSE '' END )AS '案件类型',
(CASE WHEN u.inflow_way='1' THEN '支付宝' WHEN u.inflow_way='2' THEN '自助报案'
WHEN u.inflow_way='3' THEN '95505' WHEN u.inflow_way='4' THEN '快处易赔'
WHEN u.inflow_way='5' THEN 'B转C' WHEN u.inflow_way='6' THEN '退回'
WHEN u.inflow_way='7' THEN '改派' ELSE '' END )AS '流入方式',
(CASE WHEN u.used_type='1' THEN '拍照' WHEN u.used_type='2' THEN '视频' ELSE '无' END )AS '使用方式',
(CASE WHEN u.outflow_way='1' THEN 'B转C' WHEN u.outflow_way='2' THEN '改派'
WHEN u.outflow_way='3' THEN '转常规' WHEN u.outflow_way='4' THEN '完成'
WHEN u.outflow_way='5' THEN '注销' WHEN u.outflow_way='6' THEN '退回'
 ELSE '' END )AS '流出方式',
u.hand_name AS '处理人姓名',
u.hand_phone AS '处理人电话',
u.hand_code AS '处理人代码',
(CASE WHEN u.user_type='3' THEN '' ELSE o.org_name END )AS '处理人所属分公司',
u.report_time AS '报案时间',
u.inflow_time AS '任务流入时间',
u.outflow_time AS '任务流出时间',
u.back_hand_name AS '后台处理人姓名',
-- 结束方式：1-结束/ 2-改派/ 3-重派
(CASE WHEN u.end_type ='1' THEN '结束'  WHEN u.end_type ='2' THEN '改派'   WHEN u.end_type ='3' THEN '重派'  END ) AS '后台处理方式',
org.org_name AS '后台处理人所属机构',
u.hand_time as '处理时间'
FROM prpm_item_used u
JOIN prpm_case_info c ON u.case_no = c.case_no
LEFT JOIN prpm_survey_user s ON u.hand_code = s.survey_user_code
LEFT JOIN prpm_org o ON s.org_id = o.org_id
LEFT JOIN prpm_user  userer on u.back_hand_code=userer.user_code
LEFT JOIN prpm_org org on userer.org_id=org.org_id



