You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
208 lines
10 KiB
208 lines
10 KiB
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
<mapper namespace="net.lab1024.sa.admin.module.service.dao.ServiceApplicationsDao">
|
|
|
|
<!-- 查询结果列 -->
|
|
<sql id="base_columns">
|
|
t_service_applications.application_id,
|
|
t_service_applications.user_id,
|
|
t_service_applications.firm_id,
|
|
t_service_applications.service_start,
|
|
t_service_applications.service_end,
|
|
t_service_applications.service_duration,
|
|
t_service_applications.beneficiary_count,
|
|
t_service_applications.organizer_name,
|
|
t_service_applications.organizer_contact,
|
|
t_service_applications.organizer_phone,
|
|
t_service_applications.service_content,
|
|
t_service_applications.workload_score,
|
|
t_service_applications.firm_audit_status,
|
|
t_service_applications.firm_audit_opinion,
|
|
t_service_applications.firm_audit_user,
|
|
t_service_applications.firm_audit_time,
|
|
t_service_applications.association_audit_status,
|
|
t_service_applications.association_audit_opinion,
|
|
t_service_applications.association_audit_user,
|
|
t_service_applications.association_audit_time,
|
|
t_service_applications.record_no,
|
|
t_service_applications.record_status,
|
|
t_service_applications.record_time,
|
|
t_service_applications.update_time,
|
|
t_service_applications.create_time,
|
|
t_service_applications.deleted_flag,
|
|
t_service_applications.certificate_number,
|
|
t_service_applications.activity_category_id,
|
|
t_service_applications.activity_name_id,
|
|
t_service_applications.attachment_ids,
|
|
t_service_applications.report_time
|
|
</sql>
|
|
|
|
<!-- 分页查询 -->
|
|
<select id="queryPage" resultType="net.lab1024.sa.admin.module.service.domain.vo.ServiceApplicationsVO">
|
|
SELECT
|
|
<include refid="base_columns"/>
|
|
FROM t_service_applications
|
|
<where>
|
|
deleted_flag = 0
|
|
<if test="queryForm.applicationId != null and queryForm.applicationId != ''">
|
|
and application_id = #{queryForm.applicationId}
|
|
</if>
|
|
<if test="queryForm.userId != null and queryForm.userId != ''">
|
|
and user_id = #{queryForm.userId}
|
|
</if>
|
|
<if test="queryForm.firmId != null and queryForm.firmId != ''">
|
|
and firm_id = #{queryForm.firmId}
|
|
</if>
|
|
<if test="queryForm.serviceStart != null and queryForm.serviceStart != ''">
|
|
and service_start >= #{queryForm.serviceStart}
|
|
</if>
|
|
<if test="queryForm.serviceEnd != null and queryForm.serviceEnd != ''">
|
|
and service_end <= #{queryForm.serviceEnd}
|
|
</if>
|
|
<if test="queryForm.serviceDuration != null and queryForm.serviceDuration != ''">
|
|
and service_duration = #{queryForm.serviceDuration}
|
|
</if>
|
|
<if test="queryForm.beneficiaryCount != null and queryForm.beneficiaryCount != ''">
|
|
and beneficiary_count = #{queryForm.beneficiaryCount}
|
|
</if>
|
|
<if test="queryForm.organizerName != null and queryForm.organizerName != ''">
|
|
and organizer_name = #{queryForm.organizerName}
|
|
</if>
|
|
<if test="queryForm.organizerContact != null and queryForm.organizerContact != ''">
|
|
and organizer_contact = #{queryForm.organizerContact}
|
|
</if>
|
|
<if test="queryForm.certificateNumber != null and queryForm.certificateNumber != ''">
|
|
and certificate_number = #{queryForm.certificateNumber}
|
|
</if>
|
|
<if test="queryForm.activityCategoryId != null and queryForm.activityCategoryId != ''">
|
|
and activity_category_id = #{queryForm.activityCategoryId}
|
|
</if>
|
|
<if test="queryForm.activityNameId != null and queryForm.activityNameId != ''">
|
|
and activity_name_id = #{queryForm.activityNameId}
|
|
</if>
|
|
</where>
|
|
ORDER BY create_time DESC
|
|
</select>
|
|
|
|
<update id="batchUpdateDeleted">
|
|
update t_service_applications set deleted_flag = #{deletedFlag}
|
|
where application_id in
|
|
<foreach collection="idList" open="(" close=")" separator="," item="item">
|
|
#{item}
|
|
</foreach>
|
|
</update>
|
|
|
|
<update id="updateDeleted">
|
|
update t_service_applications set deleted_flag = #{deletedFlag}
|
|
where application_id = #{applicationId}
|
|
</update>
|
|
<update id="batchSubmit">
|
|
update t_service_applications set firm_audit_status = #{deletedFlag}
|
|
where application_id in
|
|
<foreach collection="idList" open="(" close=")" separator="," item="item">
|
|
#{item}
|
|
</foreach>
|
|
</update>
|
|
|
|
<!-- 律师统计查询(无参数,保持向后兼容) -->
|
|
<select id="getLawyerStatistics" resultType="net.lab1024.sa.admin.module.service.domain.vo.LawyerStatisticsVO">
|
|
SELECT
|
|
e.actual_name AS lawyerName,
|
|
tsa.certificate_number AS certificateNumber,
|
|
COALESCE(SUM(CASE WHEN tsa.service_start >= DATE_FORMAT(DATE_SUB(NOW(), INTERVAL 3 MONTH), '%Y-%m-01') THEN tsa.service_duration ELSE 0 END), 0) AS quarterlyServiceDuration,
|
|
COALESCE(SUM(CASE WHEN tsa.service_start >= DATE_FORMAT(DATE_SUB(NOW(), INTERVAL 3 MONTH), '%Y-%m-01') THEN tsa.workload_score ELSE 0 END), 0) AS quarterlyServiceCost,
|
|
COALESCE(SUM(CASE WHEN YEAR(tsa.service_start) = YEAR(NOW()) THEN tsa.service_duration ELSE 0 END), 0) AS annualServiceDuration,
|
|
COALESCE(SUM(CASE WHEN YEAR(tsa.service_start) = YEAR(NOW()) THEN tsa.workload_score ELSE 0 END), 0) AS annualServiceCost
|
|
FROM t_service_applications tsa
|
|
LEFT JOIN t_employee e ON tsa.user_id = e.employee_id
|
|
LEFT JOIN t_department d ON tsa.firm_id = d.department_id
|
|
WHERE tsa.deleted_flag = 0
|
|
GROUP BY tsa.user_id, tsa.certificate_number, e.actual_name
|
|
ORDER BY e.actual_name
|
|
</select>
|
|
|
|
<!-- 律师统计查询(带参数) -->
|
|
<select id="getLawyerStatisticsWithParam" resultType="net.lab1024.sa.admin.module.service.domain.form.ServiceLawyerImportForm">
|
|
SELECT
|
|
e.actual_name AS lawyerName,
|
|
e.employee_id as userId,
|
|
tsa.certificate_number AS certificateNumber,
|
|
COALESCE(SUM(tsa.service_duration), 0) AS annualServiceDuration
|
|
FROM t_service_applications tsa
|
|
LEFT JOIN t_employee e ON tsa.user_id = e.employee_id
|
|
LEFT JOIN t_department d ON tsa.firm_id = d.department_id
|
|
<where>
|
|
tsa.deleted_flag = 0
|
|
<if test="queryForm.startTime != null and queryForm.startTime != ''">
|
|
AND tsa.report_time >= #{queryForm.startTime}
|
|
</if>
|
|
<if test="queryForm.endTime != null and queryForm.endTime != ''">
|
|
AND tsa.report_time <= #{queryForm.endTime}
|
|
</if>
|
|
<if test="queryForm.userId != null and queryForm.userId != ''">
|
|
and user_id = #{queryForm.userId}
|
|
</if>
|
|
<if test="queryForm.lawyerName != null and queryForm.lawyerName != ''">
|
|
AND e.actual_name LIKE CONCAT('%', #{queryForm.lawyerName}, '%')
|
|
</if>
|
|
<if test="queryForm.firmName != null and queryForm.firmName != ''">
|
|
AND d.department_name LIKE CONCAT('%', #{queryForm.firmName}, '%')
|
|
</if>
|
|
</where>
|
|
GROUP BY tsa.user_id
|
|
ORDER BY e.actual_name
|
|
</select>
|
|
<select id="getLawyerStatisticsWithParamYear"
|
|
resultType="net.lab1024.sa.admin.module.service.domain.vo.LawyerStatisticsVO">
|
|
SELECT
|
|
e.actual_name AS lawyerName,
|
|
e.employee_id as userId,
|
|
tsa.certificate_number AS certificateNumber,
|
|
COALESCE(SUM(tsa.service_duration), 0) AS annualServiceDuration
|
|
FROM t_service_applications tsa
|
|
LEFT JOIN t_employee e ON tsa.user_id = e.employee_id
|
|
LEFT JOIN t_department d ON tsa.firm_id = d.department_id
|
|
<where>
|
|
tsa.deleted_flag = 0
|
|
<if test="queryForm.startTime != null and queryForm.startTime != ''">
|
|
AND tsa.report_time >= #{queryForm.startTime}
|
|
</if>
|
|
<if test="queryForm.endTime != null and queryForm.endTime != ''">
|
|
AND tsa.report_time <= #{queryForm.endTime}
|
|
</if>
|
|
<if test="queryForm.userId != null and queryForm.userId != ''">
|
|
and tsa.user_id = #{queryForm.userId}
|
|
</if>
|
|
<if test="queryForm.lawyerName != null and queryForm.lawyerName != ''">
|
|
AND e.actual_name LIKE CONCAT('%', #{queryForm.lawyerName}, '%')
|
|
</if>
|
|
<if test="queryForm.firmName != null and queryForm.firmName != ''">
|
|
AND d.department_name LIKE CONCAT('%', #{queryForm.firmName}, '%')
|
|
</if>
|
|
</where>
|
|
GROUP BY tsa.user_id
|
|
</select>
|
|
<select id="getLawyerStatistic"
|
|
resultType="net.lab1024.sa.admin.module.service.domain.vo.LawyerStatisticsVO">
|
|
SELECT
|
|
e.actual_name AS lawyerName,
|
|
e.employee_id as userId,
|
|
tsa.certificate_number AS certificateNumber,
|
|
COALESCE(SUM(tsa.service_duration), 0) AS quarterlyServiceDuration
|
|
FROM t_service_applications tsa
|
|
LEFT JOIN t_employee e ON tsa.user_id = e.employee_id
|
|
<where>
|
|
tsa.deleted_flag = 0
|
|
<if test="queryForm.startTime != null and queryForm.startTime != ''">
|
|
AND tsa.report_time >= #{queryForm.startTime}
|
|
</if>
|
|
<if test="queryForm.endTime != null and queryForm.endTime != ''">
|
|
AND tsa.report_time <= #{queryForm.endTime}
|
|
</if>
|
|
<if test="queryForm.userId != null and queryForm.userId != ''">
|
|
and tsa.user_id = #{queryForm.userId}
|
|
</if>
|
|
</where>
|
|
</select>
|
|
|
|
</mapper>
|