shudonghui 1 年之前
父節點
當前提交
70a80770c9
共有 1 個文件被更改,包括 8 次插入6 次删除
  1. 8 6
      sop-business/src/main/resources/mapper/TBDingMapper.xml

+ 8 - 6
sop-business/src/main/resources/mapper/TBDingMapper.xml

@@ -173,7 +173,8 @@
         d.user_id,
         bs.service_lead_id AS serviceUnitLeaderId,
         crm.lead_id AS regionManagerId,
-        crm.region_coordinator_id AS coordinatorId
+        crm.region_coordinator_id AS coordinatorId,
+        bs.status serviceStatus
         FROM
         (
         SELECT d.*,d.axis_in_x AS axis_x, d.axis_in_y AS axis_y,d.sign_in_address address, d.sign_in_time sign_time,'IN' AS type FROM t_b_ding d UNION ALL
@@ -181,7 +182,7 @@
         where
         d.sign_out_time is not null  or
         (d.sign_out_time is  null and
-        date_format(from_unixtime(d.create_time/1000),'%Y-%m-%d') != date_format(now(),'%Y-%m-%d'))
+        CONCAT(d.sign_year,d.sign_date) != date_format(now(),'%Y年%m月%日'))
         ) d
         LEFT JOIN t_b_user_archives ua ON ua.id = d.user_archives_id
         LEFT JOIN t_b_user_archives_supplier us ON us.user_archives_id = ua.id
@@ -192,6 +193,7 @@
         LEFT JOIN sys_supplier s ON s.id = us.supplier_id
         ) a
         <where>
+            and a.serviceStatus = 'PUBLISH'
             <if test="serviceId != null and serviceId != ''">
                 and a.service_id = #{serviceId}
             </if>
@@ -236,7 +238,7 @@
                 where
                 d.sign_out_time is not null  or
                 (d.sign_out_time is  null and
-                date_format(from_unixtime(d.create_time/1000),'%Y-%m-%d') != date_format(now(),'%Y-%m-%d'))
+                CONCAT(d.sign_year,d.sign_date) != date_format(now(),'%Y年%m月%日'))
                 ) d
 
                 GROUP BY d.user_id
@@ -270,9 +272,8 @@
 
     <select id="attendanceCount" resultType="com.qmth.sop.business.bean.result.TBDingAttendanceCountResult">
         SELECT
-<!--        sum( CASE WHEN d.sign_in_time IS NOT NULL THEN 1 ELSE 0 END )+ sum( CASE WHEN d.sign_out_time IS NOT NULL THEN 1 ELSE 0 END ) total,-->
-        count(d.id)*2 total,
-        sum( CASE WHEN d.sign_in_time IS NULL THEN 1 ELSE 0 END )+ sum( CASE WHEN d.sign_out_time IS NULL THEN 1 ELSE 0 END ) abnormal,
+        count(d.id)*2-sum( CASE WHEN d.sign_out_time IS NULL and  CONCAT(d.sign_year,d.sign_date) = date_format(now(),'%Y年%m月%日') THEN 1 ELSE 0 END ) total,
+        sum( CASE WHEN d.sign_in_time IS NULL THEN 1 ELSE 0 END )+ sum( CASE WHEN d.sign_out_time IS NULL and  CONCAT(d.sign_year,d.sign_date) != date_format(now(),'%Y年%m月%日') THEN 1 ELSE 0 END ) abnormal,
         SUM( CASE WHEN d.sign_in_time IS NOT NULL AND d.sign_out_time IS NOT NULL THEN 1 ELSE 0 END ) all_days,
         SUM( CASE WHEN d.sign_in_time IS NOT NULL AND d.sign_out_time IS NOT NULL THEN
         (d.sign_out_time-d.sign_in_time)
@@ -288,6 +289,7 @@
         LEFT JOIN sys_custom c ON c.id = crm.custom_id
         LEFT JOIN t_b_service tbs ON d.service_id = tbs.id
         <where>
+            and tbs.status = 'PUBLISH'
             <if test="serviceId != null and serviceId != ''">
                 and d.service_id = #{serviceId}
             </if>