|
|
@@ -1,18 +1,26 @@
|
|
|
select
|
|
|
- ifnull(SUM(CASE WHEN t1.status = '待分配' THEN 1 ELSE 0 END),0) noacceptCount,
|
|
|
- ifnull(SUM(CASE WHEN t1.status = '待分配' and t1.submitdate < DATE_SUB(NOW(), INTERVAL 24 HOUR) THEN 1 ELSE 0 END),0) noacceptCount24,
|
|
|
- ifnull(SUM(CASE WHEN t1.status = '拒绝受理' THEN 1 ELSE 0 END),0) refuseacceptCount,
|
|
|
- ifnull(SUM(CASE WHEN (t1.status = '待服务' or t1.status='服务中') THEN 1 ELSE 0 END),0) processingCount
|
|
|
- FROM sa_serviceorder t1
|
|
|
- LEFT JOIN sys_enterprise t2 ON t1.sys_enterpriseid = t2.sys_enterpriseid
|
|
|
+ ifnull(SUM(CASE WHEN t1.status != '新建' and DATE(t1.submitdate) = CURDATE() THEN 1 ELSE 0 END),0) todaysubmitCount,
|
|
|
+ ifnull(SUM(CASE WHEN t1.status != '新建' and t10.type='安装' and DATE(t1.submitdate) = CURDATE() THEN 1 ELSE 0 END),0) todayazsubmitCount,
|
|
|
+ ifnull(SUM(CASE WHEN t1.status != '新建' and t10.type='维修' and DATE(t1.submitdate) = CURDATE() THEN 1 ELSE 0 END),0) todaywxsubmitCount,
|
|
|
+ ifnull(SUM(CASE WHEN t1.status != '新建' and t10.type='清洗' and DATE(t1.submitdate) = CURDATE() THEN 1 ELSE 0 END),0) todayqxsubmitCount,
|
|
|
+ ifnull(SUM(CASE WHEN t1.status = '待分配' THEN 1 ELSE 0 END),0) tobeassignedCount,
|
|
|
+ ifnull(SUM(CASE WHEN t1.status = '待分配' and t1.submitdate < DATE_SUB(NOW(), INTERVAL 24 HOUR) THEN 1 ELSE 0 END),0) tobeassignedCount24,
|
|
|
+ ifnull(SUM(CASE WHEN t1.status = '待受理' THEN 1 ELSE 0 END),0) pendingCount,
|
|
|
+ ifnull(SUM(CASE WHEN t1.status = '待受理' and t1.allocationdate < DATE_SUB(NOW(), INTERVAL 24 HOUR) THEN 1 ELSE 0 END),0) pendingCount24,
|
|
|
+ ifnull(SUM(CASE WHEN t1.status = '拒绝受理' THEN 1 ELSE 0 END),0) refuseacceptCount,
|
|
|
+ ifnull(SUM(CASE WHEN t1.status = '待服务' THEN 1 ELSE 0 END),0) tobeservedCount,
|
|
|
+ ifnull(SUM(CASE WHEN t1.status = '服务中' THEN 1 ELSE 0 END),0) inserviceCount
|
|
|
+FROM sa_serviceorder t1
|
|
|
+ LEFT JOIN sys_enterprise t2 ON t1.sys_enterpriseid = t2.sys_enterpriseid
|
|
|
AND t1.siteid = t2.siteid
|
|
|
- LEFT JOIN sa_agents t3 ON t2.sys_enterpriseid = t3.sys_enterpriseid
|
|
|
+ LEFT JOIN sa_agents t3 ON t2.sys_enterpriseid = t3.sys_enterpriseid
|
|
|
AND t2.siteid = t3.siteid
|
|
|
- LEFT JOIN sys_enterprise t4 ON t1.sys_enterpriseid_service = t4.sys_enterpriseid
|
|
|
+ LEFT JOIN sys_enterprise t4 ON t1.sys_enterpriseid_service = t4.sys_enterpriseid
|
|
|
AND t1.siteid = t4.siteid
|
|
|
- LEFT JOIN sa_agents t5 ON t4.sys_enterpriseid = t5.sys_enterpriseid
|
|
|
+ LEFT JOIN sa_agents t5 ON t4.sys_enterpriseid = t5.sys_enterpriseid
|
|
|
AND t4.siteid = t5.siteid
|
|
|
- left join sys_hr t7 on t7.hrid=t1.saler_hrid and t7.siteid=t1.siteid
|
|
|
- left join (SELECT * FROM (SELECT *,ROW_NUMBER() OVER (PARTITION BY sa_serviceorderid ORDER BY sa_serviceorderitemsid ASC) AS rowno FROM sa_serviceorderitems) t WHERE rowno = 1) t8 on t8.sa_serviceorderid=t1.sa_serviceorderid and t8.siteid=t1.siteid
|
|
|
- left join plm_item t9 on t9.itemid=t8.itemid and t9.siteid=t8.siteid
|
|
|
+ left join sys_hr t7 on t7.hrid=t1.saler_hrid and t7.siteid=t1.siteid
|
|
|
+ left join (SELECT * FROM (SELECT *,ROW_NUMBER() OVER (PARTITION BY sa_serviceorderid ORDER BY sa_serviceorderitemsid ASC) AS rowno FROM sa_serviceorderitems) t WHERE rowno = 1) t8 on t8.sa_serviceorderid=t1.sa_serviceorderid and t8.siteid=t1.siteid
|
|
|
+ left join plm_item t9 on t9.itemid=t8.itemid and t9.siteid=t8.siteid
|
|
|
+ left join sa_workorder t10 on t10.sa_serviceorderid=t1.sa_serviceorderid and t10.siteid=t1.siteid
|
|
|
where t1.siteid=$siteid$ and $where$
|