|
@@ -41,10 +41,7 @@
|
|
tbc.region_coordinator_id AS coordinatorId,
|
|
tbc.region_coordinator_id AS coordinatorId,
|
|
tbs.update_time AS serviceUpdateTime,
|
|
tbs.update_time AS serviceUpdateTime,
|
|
tbc.update_time AS crmUpdateTime,
|
|
tbc.update_time AS crmUpdateTime,
|
|
- IF(tffa.status IN ('CANCEL','END','FINISH'),
|
|
|
|
- TIMESTAMPDIFF(DAY, FROM_UNIXTIME(SUBSTRING(tffa.create_time, 1, 10), '%Y-%m-%d'), FROM_UNIXTIME(SUBSTRING(tffa.update_time, 1, 10), '%Y-%m-%d')),
|
|
|
|
- TIMESTAMPDIFF(DAY, FROM_UNIXTIME(SUBSTRING(tffa.create_time, 1, 10), '%Y-%m-%d'), NOW()))
|
|
|
|
- - normal_days + 1 AS dingExceptionCount
|
|
|
|
|
|
+ tbd.sign_in_exception_count + tbd.sign_out_exception_count AS dingExceptionCount
|
|
FROM
|
|
FROM
|
|
(SELECT
|
|
(SELECT
|
|
service_id,
|
|
service_id,
|
|
@@ -55,15 +52,14 @@
|
|
MAX(role_type) AS role_type,
|
|
MAX(role_type) AS role_type,
|
|
MIN(sign_in_time) AS approach_time,
|
|
MIN(sign_in_time) AS approach_time,
|
|
MAX(sign_out_time) AS departure_time,
|
|
MAX(sign_out_time) AS departure_time,
|
|
- COUNT(1) AS actual_days,
|
|
|
|
- SUM(IF(date_type = 'WEEKDAY', 1, 0)) AS weekdays,
|
|
|
|
- SUM(IF(date_type = 'WEEKEND', 1, 0)) AS weekends,
|
|
|
|
- SUM(IF(date_type = 'LEGAL_HOLIDAYS', 1, 0)) AS legal_holidays,
|
|
|
|
- ROUND(SUM(IF(sign_out_time IS NOT NULL
|
|
|
|
- AND sign_in_time IS NOT NULL, TIMESTAMPDIFF(MINUTE, FROM_UNIXTIME(SUBSTRING(sign_in_time, 1, 10), '%Y-%m-%d %H:%i:%s'), FROM_UNIXTIME(SUBSTRING(sign_out_time, 1, 10), '%Y-%m-%d %H:%i:%s')), 0)) / 60, 1) AS work_hours,
|
|
|
|
- SUM(IF((sign_in_time IS NULL
|
|
|
|
- OR sign_out_time IS NULL), 1, 0)) AS violation_days,
|
|
|
|
- SUM(IF((sign_in_time IS NOT NULL AND sign_out_time IS NOT NULL), 1, 0)) AS normal_days
|
|
|
|
|
|
+ SUM(IF((sign_in_time IS NOT NULL AND sign_out_time IS NOT NULL), 1, 0)) AS actual_days,
|
|
|
|
+ SUM(IF(date_type = 'WEEKDAY' AND (sign_in_time IS NOT NULL AND sign_out_time IS NOT NULL), 1, 0)) AS weekdays,
|
|
|
|
+ SUM(IF(date_type = 'WEEKEND' AND (sign_in_time IS NOT NULL AND sign_out_time IS NOT NULL), 1, 0)) AS weekends,
|
|
|
|
+ SUM(IF(date_type = 'LEGAL_HOLIDAYS' AND (sign_in_time IS NOT NULL AND sign_out_time IS NOT NULL), 1, 0)) AS legal_holidays,
|
|
|
|
+ ROUND(SUM(IF(sign_out_time IS NOT NULL AND sign_in_time IS NOT NULL, TIMESTAMPDIFF(MINUTE, FROM_UNIXTIME(SUBSTRING(sign_in_time, 1, 10), '%Y-%m-%d %H:%i:%s'), FROM_UNIXTIME(SUBSTRING(sign_out_time, 1, 10), '%Y-%m-%d %H:%i:%s')), 0)) / 60, 1) AS work_hours,
|
|
|
|
+ SUM(IF((sign_in_time IS NULL OR sign_out_time IS NULL) AND (sign_in_time IS NOT NULL OR sign_out_time IS NOT NULL), 1, 0)) AS violation_days,
|
|
|
|
+ SUM(IF(sign_in_time IS NULL, 1, 0)) AS sign_in_exception_count,
|
|
|
|
+ SUM(IF(sign_out_time IS NULL, 1, 0)) AS sign_out_exception_count
|
|
FROM
|
|
FROM
|
|
t_b_ding
|
|
t_b_ding
|
|
GROUP BY service_id , sop_no , crm_no , user_archives_id) tbd
|
|
GROUP BY service_id , sop_no , crm_no , user_archives_id) tbd
|
|
@@ -195,10 +191,7 @@
|
|
tbc.region_coordinator_id AS coordinatorId,
|
|
tbc.region_coordinator_id AS coordinatorId,
|
|
tbs.update_time AS serviceUpdateTime,
|
|
tbs.update_time AS serviceUpdateTime,
|
|
tbc.update_time AS crmUpdateTime,
|
|
tbc.update_time AS crmUpdateTime,
|
|
- IF(tffa.status IN ('CANCEL','END','FINISH'),
|
|
|
|
- TIMESTAMPDIFF(DAY, FROM_UNIXTIME(SUBSTRING(tffa.create_time, 1, 10), '%Y-%m-%d'), FROM_UNIXTIME(SUBSTRING(tffa.update_time, 1, 10), '%Y-%m-%d')),
|
|
|
|
- TIMESTAMPDIFF(DAY, FROM_UNIXTIME(SUBSTRING(tffa.create_time, 1, 10), '%Y-%m-%d'), NOW()))
|
|
|
|
- - normal_days + 1 AS dingExceptionCount
|
|
|
|
|
|
+ tbd.sign_in_exception_count + tbd.sign_out_exception_count AS dingExceptionCount
|
|
FROM
|
|
FROM
|
|
(SELECT
|
|
(SELECT
|
|
service_id,
|
|
service_id,
|
|
@@ -209,15 +202,14 @@
|
|
MAX(role_type) AS role_type,
|
|
MAX(role_type) AS role_type,
|
|
MIN(sign_in_time) AS approach_time,
|
|
MIN(sign_in_time) AS approach_time,
|
|
MAX(sign_out_time) AS departure_time,
|
|
MAX(sign_out_time) AS departure_time,
|
|
- COUNT(1) AS actual_days,
|
|
|
|
- SUM(IF(date_type = 'WEEKDAY', 1, 0)) AS weekdays,
|
|
|
|
- SUM(IF(date_type = 'WEEKEND', 1, 0)) AS weekends,
|
|
|
|
- SUM(IF(date_type = 'LEGAL_HOLIDAYS', 1, 0)) AS legal_holidays,
|
|
|
|
- ROUND(SUM(IF(sign_out_time IS NOT NULL
|
|
|
|
- AND sign_in_time IS NOT NULL, TIMESTAMPDIFF(MINUTE, FROM_UNIXTIME(SUBSTRING(sign_in_time, 1, 10), '%Y-%m-%d %H:%i:%s'), FROM_UNIXTIME(SUBSTRING(sign_out_time, 1, 10), '%Y-%m-%d %H:%i:%s')), 0)) / 60, 1) AS work_hours,
|
|
|
|
- SUM(IF((sign_in_time IS NULL
|
|
|
|
- OR sign_out_time IS NULL), 1, 0)) AS violation_days,
|
|
|
|
- SUM(IF((sign_in_time IS NOT NULL AND sign_out_time IS NOT NULL), 1, 0)) AS normal_days
|
|
|
|
|
|
+ SUM(IF((sign_in_time IS NOT NULL AND sign_out_time IS NOT NULL), 1, 0)) AS actual_days,
|
|
|
|
+ SUM(IF(date_type = 'WEEKDAY' AND (sign_in_time IS NOT NULL AND sign_out_time IS NOT NULL), 1, 0)) AS weekdays,
|
|
|
|
+ SUM(IF(date_type = 'WEEKEND' AND (sign_in_time IS NOT NULL AND sign_out_time IS NOT NULL), 1, 0)) AS weekends,
|
|
|
|
+ SUM(IF(date_type = 'LEGAL_HOLIDAYS' AND (sign_in_time IS NOT NULL AND sign_out_time IS NOT NULL), 1, 0)) AS legal_holidays,
|
|
|
|
+ ROUND(SUM(IF(sign_out_time IS NOT NULL AND sign_in_time IS NOT NULL, TIMESTAMPDIFF(MINUTE, FROM_UNIXTIME(SUBSTRING(sign_in_time, 1, 10), '%Y-%m-%d %H:%i:%s'), FROM_UNIXTIME(SUBSTRING(sign_out_time, 1, 10), '%Y-%m-%d %H:%i:%s')), 0)) / 60, 1) AS work_hours,
|
|
|
|
+ SUM(IF((sign_in_time IS NULL OR sign_out_time IS NULL) AND (sign_in_time IS NOT NULL OR sign_out_time IS NOT NULL), 1, 0)) AS violation_days,
|
|
|
|
+ SUM(IF(sign_in_time IS NULL, 1, 0)) AS sign_in_exception_count,
|
|
|
|
+ SUM(IF(sign_out_time IS NULL, 1, 0)) AS sign_out_exception_count
|
|
FROM
|
|
FROM
|
|
t_b_ding
|
|
t_b_ding
|
|
GROUP BY service_id , sop_no , crm_no , user_archives_id) tbd
|
|
GROUP BY service_id , sop_no , crm_no , user_archives_id) tbd
|