| | |
| | | and h.self_inspection_id = #{selfInspectionId} |
| | | </select> |
| | | |
| | | <select id="getStatisticHiddenDanger" resultType="com.gk.hotwork.Domain.Do.CompanyInspectionCountDO"> |
| | | select |
| | | l.checked_company_id as companyId, |
| | | count(l.id) as checkTotal, |
| | | sum(l.unRectifyTotal) as sUnReTotal, |
| | | sum(l.reTotal) as sReTotal, |
| | | sum(l.hdTocal) as sHdTotal, |
| | | sum(l.saTotal) as sSaTotal, |
| | | sum(l.maTotal) as sMaTotal, |
| | | sum(l.saReTotal) as sSaReTotal, |
| | | sum(l.maReTotal) as sMaReTotal |
| | | from ( |
| | | SELECT |
| | | s.id, |
| | | s.checked_company_id, |
| | | t.* |
| | | FROM |
| | | safety_self_inspection s |
| | | INner JOIN company c on s.checked_company_id = c.id |
| | | LEFT JOIN ( |
| | | SELECT |
| | | h.self_Inspection_id, |
| | | count( h.`status` = - 1 OR NULL ) unRectifyTotal, |
| | | count( h.`status` = 1 OR NULL ) reTotal, |
| | | count( h.`status` ) hdTocal, |
| | | count( h.LEVEL = 1 OR NULL ) saTotal, |
| | | count( h.LEVEL = 2 OR NULL ) maTotal, |
| | | count( h.LEVEL = 1 AND h.`status` = 1 OR NULL ) saReTotal, |
| | | count( h.LEVEL = 2 AND h.`status` = 1 OR NULL ) maReTotal |
| | | FROM |
| | | inspection_hidden_danger h |
| | | WHERE |
| | | h.valid_flag = 1 |
| | | GROUP BY |
| | | h.self_Inspection_id |
| | | ) t ON t.self_Inspection_id = s.id |
| | | WHERE |
| | | s.valid_flag = 1 |
| | | and s.flag = 2 |
| | | <if test="query.startTime != null" > |
| | | and s.inspection_time <![CDATA[ >= ]]> #{query.startTime} |
| | | </if> |
| | | <if test="query.endTime != null" > |
| | | and s.inspection_time <![CDATA[ <= ]]> #{query.endTime} |
| | | </if> |
| | | <if test="query.area != null and query.area != ''" > |
| | | and c.area = #{query.area} |
| | | </if> |
| | | ) l |
| | | GROUP BY l.checked_company_id |
| | | </select> |
| | | |
| | | </mapper> |