|
@@ -2,38 +2,233 @@
|
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
<mapper namespace="com.qmth.sop.business.mapper.TBDingSubmitMapper">
|
|
<mapper namespace="com.qmth.sop.business.mapper.TBDingSubmitMapper">
|
|
|
|
|
|
- <select id="findDingSubmitPage" resultType="com.qmth.sop.business.bean.result.TBDingSubmitResult">
|
|
|
|
|
|
+ <select id="findDingSubmitPage" resultType="com.qmth.sop.business.bean.result.DingSubmitResult">
|
|
SELECT
|
|
SELECT
|
|
- service_id,
|
|
|
|
- sop_no,
|
|
|
|
- crm_no,
|
|
|
|
- user_archives_id,
|
|
|
|
- MAX(role_type) AS roleType,
|
|
|
|
- MIN(sign_in_time) AS approachTime,
|
|
|
|
- MAX(sign_out_time) AS departureTime,
|
|
|
|
- COUNT(1) AS actualDays,
|
|
|
|
- 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 legalHolidays,
|
|
|
|
- ROUND(SUM(IF(sign_out_time IS NOT NULL
|
|
|
|
- AND sign_in_time IS NOT NULL,
|
|
|
|
- TIMESTAMPDIFF(MINUTE,
|
|
|
|
- FROM_UNIXTIME(SUBSTRING(sign_out_time, 1, 10),
|
|
|
|
- '%Y-%m-%d %H:%i:%s'),
|
|
|
|
- FROM_UNIXTIME(SUBSTRING(sign_in_time, 1, 10),
|
|
|
|
- '%Y-%m-%d %H:%i:%s')),
|
|
|
|
- 0)) / 60,
|
|
|
|
- 1) AS workHours,
|
|
|
|
- SUM(IF((sign_in_time IS NULL
|
|
|
|
- OR sign_out_time IS NULL),
|
|
|
|
- 1,
|
|
|
|
- 0)) AS violationDays,
|
|
|
|
- SUM(IF((sign_in_time IS NULL
|
|
|
|
- OR sign_out_time IS NULL),
|
|
|
|
- 1,
|
|
|
|
- 0)) AS dingExceptionCount
|
|
|
|
|
|
+ *
|
|
FROM
|
|
FROM
|
|
- t_b_ding
|
|
|
|
- GROUP BY service_id , sop_no , crm_no , user_archives_id;
|
|
|
|
|
|
+ (SELECT
|
|
|
|
+ tbd.service_id AS serviceUnitId,
|
|
|
|
+ tbs.name AS serviceUnitName,
|
|
|
|
+ tbd.sop_no AS sopNo,
|
|
|
|
+ sc.name AS customName,
|
|
|
|
+ sc.province AS province,
|
|
|
|
+ sc.city AS city,
|
|
|
|
+ tbd.approach_time AS approachTime,
|
|
|
|
+ tbd.departure_time AS departureTime,
|
|
|
|
+ tbua.name AS archivesName,
|
|
|
|
+ tbd.role_type AS roleType,
|
|
|
|
+ ss.id AS supplierId,
|
|
|
|
+ ss.name AS supplierName,
|
|
|
|
+ tbd.actual_days AS actualDays,
|
|
|
|
+ tbd.weekdays AS weekdays,
|
|
|
|
+ tbd.weekends AS weekends,
|
|
|
|
+ tbd.legal_holidays AS legalHolidays,
|
|
|
|
+ tbd.work_hours AS workHours,
|
|
|
|
+ tbd.violation_days AS violationDays,
|
|
|
|
+ tbd.ding_exception_count AS dingExceptionCount,
|
|
|
|
+ (sdg.reissue_card_count - tbd.submit_exception_count) AS remainCount,
|
|
|
|
+ tbd.exception_count AS exceptionCount,
|
|
|
|
+ IFNULL(tbds.submit_status, 'WILL_SUBMIT') AS submitStatus,
|
|
|
|
+ tbds.submit_user_id AS submitUserId,
|
|
|
|
+ su.real_name AS submitUserName,
|
|
|
|
+ tbds.submit_time AS submitTime
|
|
|
|
+ FROM
|
|
|
|
+ (SELECT
|
|
|
|
+ service_id,
|
|
|
|
+ sop_no,
|
|
|
|
+ crm_no,
|
|
|
|
+ user_archives_id,
|
|
|
|
+ MAX(role_type) AS role_type,
|
|
|
|
+ MIN(sign_in_time) AS approach_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_out_time, 1, 10), '%Y-%m-%d %H:%i:%s'), FROM_UNIXTIME(SUBSTRING(sign_in_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 NULL
|
|
|
|
+ OR sign_out_time IS NULL), 1, 0)) AS ding_exception_count,
|
|
|
|
+ (SELECT
|
|
|
|
+ COUNT(*)
|
|
|
|
+ FROM
|
|
|
|
+ t_b_ding_apply
|
|
|
|
+ WHERE
|
|
|
|
+ ding_id = id) AS submit_exception_count,
|
|
|
|
+ (SELECT
|
|
|
|
+ COUNT(*)
|
|
|
|
+ FROM
|
|
|
|
+ t_b_ding_apply
|
|
|
|
+ WHERE
|
|
|
|
+ ding_id = id AND approve IS NULL) AS exception_count
|
|
|
|
+ FROM
|
|
|
|
+ t_b_ding
|
|
|
|
+ GROUP BY service_id , sop_no , crm_no , user_archives_id) tbd
|
|
|
|
+ LEFT JOIN t_b_ding_submit tbds ON tbd.sop_no = tbds.sop_no
|
|
|
|
+ AND tbd.user_archives_id = tbds.user_archives_id
|
|
|
|
+ LEFT JOIN t_b_service tbs ON tbd.service_id = tbs.id AND tbs.enable
|
|
|
|
+ LEFT JOIN t_b_crm tbc ON tbd.crm_no = tbc.crm_no
|
|
|
|
+ LEFT JOIN sys_custom sc ON tbc.custom_id = sc.id
|
|
|
|
+ LEFT JOIN t_b_user_archives tbua ON tbd.user_archives_id = tbua.id
|
|
|
|
+ LEFT JOIN t_b_user_archives_supplier tbuas ON tbuas.user_archives_id = tbua.id
|
|
|
|
+ LEFT JOIN sys_supplier ss ON tbuas.supplier_id = ss.id
|
|
|
|
+ LEFT JOIN sys_user su ON tbds.submit_user_id = su.id
|
|
|
|
+ LEFT JOIN sys_ding_group sdg ON sdg.service_id = tbd.service_id
|
|
|
|
+ AND sdg.supplier_id = ss.id) main
|
|
|
|
+ <where>
|
|
|
|
+ <if test="serviceUnitId != null">
|
|
|
|
+ AND main.serviceUnitId = #{serviceUnitId}
|
|
|
|
+ </if>
|
|
|
|
+ <if test="dingSubmitStatusList != null and dingSubmitStatusList != '' and dingSubmitStatusList.size > 0">
|
|
|
|
+ AND main.submitStatus IN
|
|
|
|
+ <foreach collection="dingSubmitStatusList" item="item" index="index" open="(" separator="," close=")">
|
|
|
|
+ #{item}
|
|
|
|
+ </foreach>
|
|
|
|
+ </if>
|
|
|
|
+ <if test="submitUserId != null">
|
|
|
|
+ AND main.submitUserId = #{serviceUnitId}
|
|
|
|
+ </if>
|
|
|
|
+ <if test="archivesName != null and archivesName != ''">
|
|
|
|
+ AND main.archivesName LIKE CONCAT('%',#{archivesName},'%')
|
|
|
|
+ </if>
|
|
|
|
+ <if test="supplierId != null">
|
|
|
|
+ AND main.supplierId = #{supplierId}
|
|
|
|
+ </if>
|
|
|
|
+ <if test="customName != null and customName != ''">
|
|
|
|
+ AND main.customName LIKE CONCAT('%',#{customName},'%')
|
|
|
|
+ </if>
|
|
|
|
+ <if test="sopNo != null and sopNo != ''">
|
|
|
|
+ AND main.sopNo = #{sopNo}
|
|
|
|
+ </if>
|
|
|
|
+ <if test="violationHoursLimit != null">
|
|
|
|
+ AND main.violationDays > #{violationHoursLimit}
|
|
|
|
+ </if>
|
|
|
|
+ <if test="dingExceptionLimit != null">
|
|
|
|
+ AND main.dingExceptionCount > #{dingExceptionLimit}
|
|
|
|
+ </if>
|
|
|
|
+ <if test="remainLimit != null">
|
|
|
|
+ AND main.remainCount > #{remainLimit}
|
|
|
|
+ </if>
|
|
|
|
+ <if test="exceptionLimit != null">
|
|
|
|
+ AND main.exceptionCount > #{exceptionLimit}
|
|
|
|
+ </if>
|
|
|
|
+ </where>
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+ <select id="findDingSubmitList" resultType="com.qmth.sop.business.bean.result.DingSubmitResult">
|
|
|
|
+ SELECT
|
|
|
|
+ *
|
|
|
|
+ FROM
|
|
|
|
+ (SELECT
|
|
|
|
+ tbd.service_id AS serviceUnitId,
|
|
|
|
+ tbs.name AS serviceUnitName,
|
|
|
|
+ tbd.sop_no AS sopNo,
|
|
|
|
+ sc.name AS customName,
|
|
|
|
+ sc.province AS province,
|
|
|
|
+ sc.city AS city,
|
|
|
|
+ tbd.approach_time AS approachTime,
|
|
|
|
+ tbd.departure_time AS departureTime,
|
|
|
|
+ tbua.name AS archivesName,
|
|
|
|
+ tbd.role_type AS roleType,
|
|
|
|
+ ss.id AS supplierId,
|
|
|
|
+ ss.name AS supplierName,
|
|
|
|
+ tbd.actual_days AS actualDays,
|
|
|
|
+ tbd.weekdays AS weekdays,
|
|
|
|
+ tbd.weekends AS weekends,
|
|
|
|
+ tbd.legal_holidays AS legalHolidays,
|
|
|
|
+ tbd.work_hours AS workHours,
|
|
|
|
+ tbd.violation_days AS violationDays,
|
|
|
|
+ tbd.ding_exception_count AS dingExceptionCount,
|
|
|
|
+ (sdg.reissue_card_count - tbd.submit_exception_count) AS remainCount,
|
|
|
|
+ tbd.exception_count AS exceptionCount,
|
|
|
|
+ IFNULL(tbds.submit_status, 'WILL_SUBMIT') AS submitStatus,
|
|
|
|
+ tbds.submit_user_id AS submitUserId,
|
|
|
|
+ su.real_name AS submitUserName,
|
|
|
|
+ tbds.submit_time AS submitTime
|
|
|
|
+ FROM
|
|
|
|
+ (SELECT
|
|
|
|
+ service_id,
|
|
|
|
+ sop_no,
|
|
|
|
+ crm_no,
|
|
|
|
+ user_archives_id,
|
|
|
|
+ MAX(role_type) AS role_type,
|
|
|
|
+ MIN(sign_in_time) AS approach_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_out_time, 1, 10), '%Y-%m-%d %H:%i:%s'), FROM_UNIXTIME(SUBSTRING(sign_in_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 NULL
|
|
|
|
+ OR sign_out_time IS NULL), 1, 0)) AS ding_exception_count,
|
|
|
|
+ (SELECT
|
|
|
|
+ COUNT(*)
|
|
|
|
+ FROM
|
|
|
|
+ t_b_ding_apply
|
|
|
|
+ WHERE
|
|
|
|
+ ding_id = id) AS submit_exception_count,
|
|
|
|
+ (SELECT
|
|
|
|
+ COUNT(*)
|
|
|
|
+ FROM
|
|
|
|
+ t_b_ding_apply
|
|
|
|
+ WHERE
|
|
|
|
+ ding_id = id AND approve IS NULL) AS exception_count
|
|
|
|
+ FROM
|
|
|
|
+ t_b_ding
|
|
|
|
+ GROUP BY service_id , sop_no , crm_no , user_archives_id) tbd
|
|
|
|
+ LEFT JOIN t_b_ding_submit tbds ON tbd.sop_no = tbds.sop_no
|
|
|
|
+ AND tbd.user_archives_id = tbds.user_archives_id
|
|
|
|
+ LEFT JOIN t_b_service tbs ON tbd.service_id = tbs.id AND tbs.enable
|
|
|
|
+ LEFT JOIN t_b_crm tbc ON tbd.crm_no = tbc.crm_no
|
|
|
|
+ LEFT JOIN sys_custom sc ON tbc.custom_id = sc.id
|
|
|
|
+ LEFT JOIN t_b_user_archives tbua ON tbd.user_archives_id = tbua.id
|
|
|
|
+ LEFT JOIN t_b_user_archives_supplier tbuas ON tbuas.user_archives_id = tbua.id
|
|
|
|
+ LEFT JOIN sys_supplier ss ON tbuas.supplier_id = ss.id
|
|
|
|
+ LEFT JOIN sys_user su ON tbds.submit_user_id = su.id
|
|
|
|
+ LEFT JOIN sys_ding_group sdg ON sdg.service_id = tbd.service_id
|
|
|
|
+ AND sdg.supplier_id = ss.id) main
|
|
|
|
+ <where>
|
|
|
|
+ <if test="serviceUnitId != null">
|
|
|
|
+ AND main.serviceUnitId = #{serviceUnitId}
|
|
|
|
+ </if>
|
|
|
|
+ <if test="dingSubmitStatusList != null and dingSubmitStatusList != '' and dingSubmitStatusList.size > 0">
|
|
|
|
+ AND main.submitStatus IN
|
|
|
|
+ <foreach collection="dingSubmitStatusList" item="item" index="index" open="(" separator="," close=")">
|
|
|
|
+ #{item}
|
|
|
|
+ </foreach>
|
|
|
|
+ </if>
|
|
|
|
+ <if test="submitUserId != null">
|
|
|
|
+ AND main.submitUserId = #{serviceUnitId}
|
|
|
|
+ </if>
|
|
|
|
+ <if test="archivesName != null and archivesName != ''">
|
|
|
|
+ AND main.archivesName LIKE CONCAT('%',#{archivesName},'%')
|
|
|
|
+ </if>
|
|
|
|
+ <if test="supplierId != null">
|
|
|
|
+ AND main.supplierId = #{supplierId}
|
|
|
|
+ </if>
|
|
|
|
+ <if test="customName != null and customName != ''">
|
|
|
|
+ AND main.customName LIKE CONCAT('%',#{customName},'%')
|
|
|
|
+ </if>
|
|
|
|
+ <if test="sopNo != null and sopNo != ''">
|
|
|
|
+ AND main.sopNo = #{sopNo}
|
|
|
|
+ </if>
|
|
|
|
+ <if test="violationHoursLimit != null">
|
|
|
|
+ AND main.violationDays > #{violationHoursLimit}
|
|
|
|
+ </if>
|
|
|
|
+ <if test="dingExceptionLimit != null">
|
|
|
|
+ AND main.dingExceptionCount > #{dingExceptionLimit}
|
|
|
|
+ </if>
|
|
|
|
+ <if test="remainLimit != null">
|
|
|
|
+ AND main.remainCount > #{remainLimit}
|
|
|
|
+ </if>
|
|
|
|
+ <if test="exceptionLimit != null">
|
|
|
|
+ AND main.exceptionCount > #{exceptionLimit}
|
|
|
|
+ </if>
|
|
|
|
+ </where>
|
|
</select>
|
|
</select>
|
|
</mapper>
|
|
</mapper>
|