|
@@ -85,11 +85,10 @@
|
|
|
<!--多条件分页查询年检记录-->
|
|
|
<select id="pageByCondition" resultMap="BaseResultMap" parameterType="cn.com.ty.lift.business.annualinspection.dto.InspectionRequest" >
|
|
|
SELECT
|
|
|
- DISTINCT
|
|
|
t.*,
|
|
|
ui.name AS worker_name
|
|
|
FROM
|
|
|
- (SELECT
|
|
|
+ (SELECT DISTINCT
|
|
|
ai.*,
|
|
|
re.area_name,
|
|
|
pr.id AS project_id,
|
|
@@ -102,14 +101,15 @@
|
|
|
FROM
|
|
|
annual_inspection ai
|
|
|
LEFT JOIN platform_company_lift_relevance pclr
|
|
|
- ON ai.mt_company_id = pclr.mt_company_id AND ai.lift_id = pclr.lift_id
|
|
|
+ ON ai.mt_company_id = pclr.mt_company_id AND ai.lift_id = pclr.lift_id AND pclr.lift_company_status != '1'
|
|
|
LEFT JOIN project_lift_relevance plr ON ai.lift_id = plr.lift_id AND ai.mt_company_id = plr.mt_company_id
|
|
|
+ AND plr.delete_flag = '0'
|
|
|
LEFT JOIN project_user pu ON pu.project_id = plr.project_id AND pu.mt_company_id = ai.mt_company_id
|
|
|
LEFT JOIN lift li ON ai.lift_id = li.id
|
|
|
LEFT JOIN project pr ON pr.id = plr.project_id
|
|
|
LEFT JOIN region re ON pr.region_id = re.id
|
|
|
LEFT JOIN user_info ui ON ui.user_id = re.user_id
|
|
|
- WHERE plr.delete_flag = '0' AND pclr.lift_company_status != '1'
|
|
|
+ WHERE 1=1
|
|
|
<if test="cond.status != null">
|
|
|
AND ai.status = #{cond.status}
|
|
|
</if>
|
|
@@ -128,11 +128,20 @@
|
|
|
<if test="cond.projectId != null and cond.projectId > 0">
|
|
|
AND pr.id = #{cond.projectId}
|
|
|
</if>
|
|
|
- <if test="cond.workerId != null">
|
|
|
- AND pu.user_id = #{cond.workerId}
|
|
|
+ <if test="cond.workerId !=null ">
|
|
|
+ <choose>
|
|
|
+ <when test="cond.currentRoleCode == 'REGION_DIRECTOR' or cond.currentRoleCode == 'CLERK' ">
|
|
|
+ AND pu.user_id = #{cond.userId,jdbcType=BIGINT}
|
|
|
+ </when>
|
|
|
+ <when test="cond.currentRoleCode == 'ROLEMTWORK' ">
|
|
|
+ AND plr.worker_id = #{cond.workerId}
|
|
|
+ </when>
|
|
|
+ <otherwise/>
|
|
|
+ </choose>
|
|
|
</if>
|
|
|
) t
|
|
|
LEFT JOIN user_info ui ON ui.user_id = t.worker_id
|
|
|
+ ORDER BY plan_date,finish_time
|
|
|
</select>
|
|
|
|
|
|
<select id="pageByLift" resultMap="BaseResultMap" parameterType="cn.com.ty.lift.business.annualinspection.dto.InspectionRequest" >
|
|
@@ -242,15 +251,83 @@
|
|
|
count(*)
|
|
|
FROM
|
|
|
annual_inspection ai
|
|
|
+ <if test="cond.currentRoleCode == 'REGION_DIRECTOR' or cond.currentRoleCode == 'CLERK' ">
|
|
|
LEFT JOIN project_lift_relevance plr ON plr.mt_company_id = ai.mt_company_id AND plr.lift_id = ai.lift_id
|
|
|
LEFT JOIN project_user pu ON pu.project_id = plr.project_id AND pu.mt_company_id = ai.mt_company_id
|
|
|
+ </if>
|
|
|
WHERE
|
|
|
ai.`status` = 0
|
|
|
- <if test="cond.userId != null and cond.userId > 0">
|
|
|
+ <if test="cond.currentRoleCode == 'REGION_DIRECTOR' or cond.currentRoleCode == 'CLERK'">
|
|
|
AND pu.user_id = #{cond.userId}
|
|
|
</if>
|
|
|
<if test="cond.mtCompanyId != null and cond.mtCompanyId > 0">
|
|
|
AND ai.mt_company_id = #{cond.mtCompanyId}
|
|
|
</if>
|
|
|
</select>
|
|
|
+
|
|
|
+ <!--app统计年检列表待确认总数 -->
|
|
|
+ <select id="countInspectionConfirmByUserId" resultType="java.lang.Integer"
|
|
|
+ parameterType="cn.com.ty.lift.business.annualinspection.dto.InspectionRequest">
|
|
|
+ SELECT count(1) toConfirm
|
|
|
+ FROM lift li
|
|
|
+ LEFT JOIN platform_company_lift_relevance pclr ON li.id = pclr.lift_id AND pclr.lift_company_status!=1
|
|
|
+ <choose>
|
|
|
+ <when test=" request.currentRoleCode == 'REGION_DIRECTOR' or request.currentRoleCode == 'CLERK' or request.currentRoleCode == 'ROLEMTWORK' ">
|
|
|
+ LEFT JOIN project_lift_relevance plr ON li.id = plr.lift_id AND plr.delete_flag = '0'
|
|
|
+ LEFT JOIN annual_inspection ai ON ai.lift_id = li.id AND AND ai.plan_date = li.annual_inspection_date
|
|
|
+ AND ai.mt_company_id = plr.mt_company_id
|
|
|
+ </when>
|
|
|
+ <when test="request.currentRoleCode == 'REGION_DIRECTOR' or request.currentRoleCode == 'CLERK' ">
|
|
|
+ LEFT JOIN project_user pu ON pu.project_id = plr.project_id
|
|
|
+ LEFT JOIN annual_inspection ai ON ai.lift_id = li.id AND ai.plan_date = li.annual_inspection_date AND
|
|
|
+ pu.mt_company_id = ai.mt_company_id
|
|
|
+ </when>
|
|
|
+ <otherwise>
|
|
|
+ LEFT JOIN annual_inspection ai ON ai.lift_id = li.id AND pclr.mt_company_id = ai.mt_company_id
|
|
|
+ AND ai.plan_date = li.annual_inspection_date
|
|
|
+ </otherwise>
|
|
|
+ </choose>
|
|
|
+ WHERE <![CDATA[li.annual_inspection_date <= date_add(curdate(), INTERVAL 45 DAY)]]>
|
|
|
+ AND <![CDATA[li.annual_inspection_date >= curdate() AND isnull(ai.id)]]>
|
|
|
+ AND pclr.mt_company_id = #{request.mtCompanyId}
|
|
|
+ <choose>
|
|
|
+ <when test="request.currentRoleCode == 'REGION_DIRECTOR' or request.currentRoleCode == 'CLERK' ">
|
|
|
+ AND pu.user_id = #{request.userId,jdbcType=BIGINT}
|
|
|
+ </when>
|
|
|
+ <when test="request.currentRoleCode == 'ROLEMTWORK' ">
|
|
|
+ AND plr.worker_id = #{request.userId,jdbcType=BIGINT}
|
|
|
+ </when>
|
|
|
+ <otherwise/>
|
|
|
+ </choose>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!--app统计年检列表执行中和已完成总数 -->
|
|
|
+ <select id="countInspectionByUserId" parameterType="cn.com.ty.lift.business.annualinspection.dto.InspectionRequest"
|
|
|
+ resultType="cn.com.ty.lift.business.annualinspection.dto.InspectionCount">
|
|
|
+ SELECT MAX(CASE t.status WHEN '0' THEN t.total ELSE 0 END) processing,
|
|
|
+ MAX(CASE t.status WHEN '1' THEN t.total ELSE 0 END) complete
|
|
|
+ FROM (
|
|
|
+ SELECT count(1) total,
|
|
|
+ status
|
|
|
+ FROM annual_inspection ai
|
|
|
+ LEFT JOIN platform_company_lift_relevance pc
|
|
|
+ ON ai.lift_id = pc.lift_id AND pc.lift_company_status !=1 AND ai.mt_company_id = pc.mt_company_id
|
|
|
+ <if test="request.currentRoleCode == 'REGION_DIRECTOR' or request.currentRoleCode == 'CLERK' or request.currentRoleCode == 'ROLEMTWORK' ">
|
|
|
+ LEFT JOIN project_lift_relevance plr ON plr.mt_company_id = pc.mt_company_id AND plr.lift_id = ai.lift_id AND plr.delete_flag = '0'
|
|
|
+ </if>
|
|
|
+ <if test="request.currentRoleCode == 'REGION_DIRECTOR' or request.currentRoleCode == 'CLERK' ">
|
|
|
+ LEFT JOIN project_user pu ON plr.project_id = pu.project_id AND pu.mt_company_id = plr.mt_company_id
|
|
|
+ </if>
|
|
|
+ WHERE ai.mt_company_id = #{request.mtCompanyId}
|
|
|
+ <choose>
|
|
|
+ <when test="request.currentRoleCode == 'REGION_DIRECTOR' or request.currentRoleCode == 'CLERK' ">
|
|
|
+ AND pu.user_id = #{request.userId,jdbcType=BIGINT}
|
|
|
+ </when>
|
|
|
+ <when test="request.currentRoleCode == 'ROLEMTWORK' ">
|
|
|
+ AND plr.worker_id = #{request.userId,jdbcType=BIGINT}
|
|
|
+ </when>
|
|
|
+ <otherwise/>
|
|
|
+ </choose>
|
|
|
+ GROUP BY status) t
|
|
|
+ </select>
|
|
|
</mapper>
|