Kaynağa Gözat

修复bug:急修统计sql错误

别傲 5 yıl önce
ebeveyn
işleme
776fcaa923

+ 16 - 5
lift-business-service/src/main/resources/mapper/emergency/EmergencyRepairMapper.xml

@@ -150,6 +150,11 @@
         FROM
             emergency_repair er
             LEFT JOIN project pr ON er.project_id = pr.id AND pr.mt_company_id = er.mt_company_id
+            <if test="cond.currentRoleCode == 'REGION_DIRECTOR' or cond.currentRoleCode == 'CLERK' ">
+                LEFT JOIN project_user pu ON pu.project_id = pr.id AND pu.mt_company_id = pr.mt_company_id
+                LEFT JOIN project_lift_relevance plr ON plr.mt_company_id = pu.mt_company_id
+                         AND plr.project_id = pr.id AND plr.lift_id = er.lift_id
+            </if>
             LEFT JOIN region re ON pr.region_id = re.id
             LEFT JOIN lift li ON er.lift_id = li.id
             LEFT JOIN user_info ui ON ui.user_id = er.worker_id1
@@ -163,9 +168,6 @@
             <if test="cond.regionId != null and cond.regionId > 0">
                 AND pr.region_id = #{cond.regionId}
             </if>
-            <if test="cond.workerId != null">
-                AND er.worker_id1 = #{cond.workerId}
-            </if>
             <if test="cond.repairBegin != null">
                 AND date(er.caller_date) &gt;= #{cond.repairBegin}
             </if>
@@ -181,6 +183,17 @@
             <if test="cond.info != null and cond.info != ''">
                 AND li.registration_code LIKE concat('%',#{cond.info},'%')
             </if>
+            <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 er.worker_id1 = #{cond.workerId}
+                    </when>
+                    <otherwise/>
+                </choose>
+            </if>
         </where>
     </select>
 
@@ -334,8 +347,6 @@
         ON e.lift_id = pc.lift_id AND pc.lift_company_status !=1 AND e.mt_company_id = pc.mt_company_id
         <if test="request.currentRoleCode == 'REGION_DIRECTOR' or request.currentRoleCode == 'CLERK' ">
             LEFT JOIN project_lift_relevance pl ON pl.mt_company_id = pc.mt_company_id AND pl.lift_id = e.lift_id
-        </if>
-        <if test="request.currentRoleCode == 'REGION_DIRECTOR' or request.currentRoleCode == 'CLERK' ">
             LEFT JOIN project_user pu ON pl.project_id = pu.project_id AND pu.mt_company_id = pl.mt_company_id
         </if>
         WHERE e.mt_company_id = #{request.mtCompanyId}