瀏覽代碼

修复bug:年检、急修、大修统计sql错误

别傲 5 年之前
父節點
當前提交
98a418218c

+ 16 - 8
lift-business-service/src/main/resources/mapper/annualinspection/AnnualInspectionMapper.xml

@@ -248,21 +248,29 @@
 
     <select id="countDoingByUser" resultType="java.lang.Long" parameterType="cn.com.ty.lift.business.common.CommonRequest">
         SELECT
-            count(*)
+            count(1)
         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="cond.currentRoleCode == 'REGION_DIRECTOR' or cond.currentRoleCode == 'CLERK' or cond.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="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
+            LEFT JOIN project_user pu ON plr.project_id = pu.project_id AND pu.mt_company_id = plr.mt_company_id
         </if>
         WHERE
             ai.`status` = 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>
+        <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.userId,jdbcType=BIGINT}
+            </when>
+            <otherwise/>
+        </choose>
     </select>
 
     <!--app统计年检列表待确认总数 -->

+ 3 - 8
lift-business-service/src/main/resources/mapper/capital/CapitalRepairLiftRelevanceMapper.xml

@@ -80,9 +80,7 @@
             SELECT count(1) total,
                 project_status
             FROM capital_repair cr
-        <if test="request.currentRoleCode == 'REGION_DIRECTOR' or request.currentRoleCode == 'CLERK' or request.currentRoleCode == 'ROLEMTWORK' ">
             LEFT JOIN project_user pu ON cr.id = pu.project_id
-        </if>
         WHERE cr.mt_company_id = #{request.mtCompanyId,jdbcType=BIGINT}
         <if test="request.currentRoleCode == 'REGION_DIRECTOR' or request.currentRoleCode == 'CLERK' or request.currentRoleCode == 'ROLEMTWORK' ">
             AND pu.user_id = #{request.userId,jdbcType=BIGINT}
@@ -138,12 +136,9 @@
         count(1)
         FROM capital_repair cr
         LEFT JOIN project_user pu ON cr.id = pu.project_id AND cr.mt_company_id = pu.mt_company_id
-        WHERE cr.project_status = '2'
-        <if test="request.userId != null and request.userId > 0">
-            AND pu.user_id = #{request.userId}
-        </if>
-        <if test="request.mtCompanyId != null and request.mtCompanyId > 0">
-            AND cr.mt_company_id = #{request.mtCompanyId}
+        WHERE cr.project_status = '2' AND cr.mt_company_id = #{request.mtCompanyId}
+        <if test="request.currentRoleCode == 'REGION_DIRECTOR' or request.currentRoleCode == 'CLERK' or request.currentRoleCode == 'ROLEMTWORK' ">
+            AND pu.user_id = #{request.userId,jdbcType=BIGINT}
         </if>
     </select>
 </mapper>

+ 3 - 0
lift-business-service/src/main/resources/mapper/emergency/EmergencyRepairMapper.xml

@@ -315,7 +315,10 @@
             count(1)
         FROM
             emergency_repair er
+        LEFT JOIN platform_company_lift_relevance pc
+             ON er.lift_id = pc.lift_id AND pc.lift_company_status !=1 AND er.mt_company_id = pc.mt_company_id
         <if test="cond.currentRoleCode == 'REGION_DIRECTOR' or cond.currentRoleCode == 'CLERK' ">
+            LEFT JOIN project_lift_relevance pl ON pl.mt_company_id = pc.mt_company_id AND pl.lift_id = er.lift_id
             LEFT JOIN project_user pu ON er.project_id = pu.project_id AND er.mt_company_id = pu.mt_company_id
         </if>
         WHERE er.status = 1