|
|
@@ -50,16 +50,43 @@
|
|
|
where a.guid = #{guid}
|
|
|
</select>
|
|
|
<select id="selectObjAcciList" parameterType="com.goldenwater.slaj.acci.domain.ObjAcciVo" resultMap="ObjAcciResult">
|
|
|
- select a.guid, a.p_guid, a.acci_wiun_guid, a.acci_wiun_type, a.acci_cate, a.occu_time,
|
|
|
- a.occu_loc, a.miss_num, a.ser_inj_num, a.cas_num, a.econ_loss, a.otlcol_guui_vicm,
|
|
|
- a.resc_trea_meas, a.conta_pers, a.offi_tel, a.rep_stat, a.note, a.coll_time,
|
|
|
- a. upd_time, a.rec_pers, a.sgdw_name, a.acci_grad, a.eng_guid, a.to_date, a.tend_guid,
|
|
|
- a.sgdw_name || '事故' as acci_name,
|
|
|
- e.eng_name, t.tend_name, bi.if_resp_acci as if_duty, bi.if_pho_rep as if_phone, bi.acci_cause
|
|
|
- from obj_acci a
|
|
|
- left join att_eng_base e on a.eng_guid = e.guid
|
|
|
- left join obj_tend t on a.tend_guid = t.guid
|
|
|
- left join bis_acci_inve bi on a.guid = bi.acci_guid
|
|
|
+ <choose>
|
|
|
+ <when test="orgGuid != null and orgGuid != ''">
|
|
|
+ WITH RECURSIVE subOrgs AS (
|
|
|
+ SELECT guid, org_name FROM att_org_base WHERE guid = #{orgGuid}
|
|
|
+ UNION ALL
|
|
|
+ SELECT e.org_guid, o.org_name FROM att_org_ext e
|
|
|
+ LEFT JOIN att_org_base o ON o.guid = e.org_guid
|
|
|
+ WHERE e.admin_wiun_guid = #{orgGuid}
|
|
|
+ UNION ALL
|
|
|
+ SELECT b.guid, b.org_name FROM att_org_base b
|
|
|
+ INNER JOIN subOrgs s ON b.pguid = s.guid
|
|
|
+ )
|
|
|
+ select a.guid, a.p_guid, a.acci_wiun_guid, a.acci_wiun_type, a.acci_cate, a.occu_time,
|
|
|
+ a.occu_loc, a.miss_num, a.ser_inj_num, a.cas_num, a.econ_loss, a.otlcol_guui_vicm,
|
|
|
+ a.resc_trea_meas, a.conta_pers, a.offi_tel, a.rep_stat, a.note, a.coll_time,
|
|
|
+ a.upd_time, a.rec_pers, a.sgdw_name, a.acci_grad, a.eng_guid, a.to_date, a.tend_guid,
|
|
|
+ a.sgdw_name || '事故' as acci_name,
|
|
|
+ e.eng_name, t.tend_name, bi.if_resp_acci as if_duty, bi.if_pho_rep as if_phone, bi.acci_cause
|
|
|
+ from obj_acci a
|
|
|
+ inner join subOrgs s on a.acci_wiun_guid = s.guid
|
|
|
+ left join att_eng_base e on a.eng_guid = e.guid
|
|
|
+ left join obj_tend t on a.tend_guid = t.guid
|
|
|
+ left join bis_acci_inve bi on a.guid = bi.acci_guid
|
|
|
+ </when>
|
|
|
+ <otherwise>
|
|
|
+ select a.guid, a.p_guid, a.acci_wiun_guid, a.acci_wiun_type, a.acci_cate, a.occu_time,
|
|
|
+ a.occu_loc, a.miss_num, a.ser_inj_num, a.cas_num, a.econ_loss, a.otlcol_guui_vicm,
|
|
|
+ a.resc_trea_meas, a.conta_pers, a.offi_tel, a.rep_stat, a.note, a.coll_time,
|
|
|
+ a.upd_time, a.rec_pers, a.sgdw_name, a.acci_grad, a.eng_guid, a.to_date, a.tend_guid,
|
|
|
+ a.sgdw_name || '事故' as acci_name,
|
|
|
+ e.eng_name, t.tend_name, bi.if_resp_acci as if_duty, bi.if_pho_rep as if_phone, bi.acci_cause
|
|
|
+ from obj_acci a
|
|
|
+ left join att_eng_base e on a.eng_guid = e.guid
|
|
|
+ left join obj_tend t on a.tend_guid = t.guid
|
|
|
+ left join bis_acci_inve bi on a.guid = bi.acci_guid
|
|
|
+ </otherwise>
|
|
|
+ </choose>
|
|
|
<where>
|
|
|
<if test="guid != null and guid != ''">AND a.guid = #{guid}</if>
|
|
|
<if test="acciGrad != null and acciGrad != ''">AND a.acci_grad = #{acciGrad}</if>
|
|
|
@@ -68,7 +95,6 @@
|
|
|
<if test="ifDuty != null and ifDuty != ''">AND bi.if_resp_acci = #{ifDuty}</if>
|
|
|
<if test="orgName != null and orgName != ''">AND a.sgdw_name like '%' || #{orgName} || '%'</if>
|
|
|
<if test="sgdwName != null and sgdwName != ''">AND a.sgdw_name like '%' || #{sgdwName} || '%'</if>
|
|
|
- <if test="acciGrad != null and acciGrad != ''">AND a.acci_grad = #{acciGrad}</if>
|
|
|
<if test="engGuid != null and engGuid != ''">AND a.eng_guid = #{engGuid}</if>
|
|
|
<if test="recPers != null and recPers != ''">AND a.rec_pers = #{recPers}</if>
|
|
|
</where>
|
|
|
@@ -178,21 +204,45 @@
|
|
|
</select>
|
|
|
|
|
|
<select id="selectAcciStatList" parameterType="java.util.Map" resultType="java.util.LinkedHashMap">
|
|
|
- select sgdw_name as orgName,
|
|
|
- count(1) as acciCount,
|
|
|
- sum(cast(coalesce(cas_num, '0') as numeric)) as deathCount,
|
|
|
- sum(cast(coalesce(ser_inj_num, '0') as numeric)) as injuryCount,
|
|
|
- sum(cast(coalesce(econ_loss, '0') as numeric)) as econLoss,
|
|
|
- round(cast(sum(cast(coalesce(cas_num, '0') as numeric)) / count(1) as numeric), 2) as avgDeath,
|
|
|
- round(cast(sum(cast(coalesce(ser_inj_num, '0') as numeric)) / count(1) as numeric), 2) as avgInjury,
|
|
|
- round(cast(sum(cast(coalesce(econ_loss, '0') as numeric)) / count(1) as numeric), 2) as avgEconLoss
|
|
|
- from obj_acci
|
|
|
+ <choose>
|
|
|
+ <when test="orgGuid != null and orgGuid != ''">
|
|
|
+ WITH RECURSIVE subOrgs AS (
|
|
|
+ SELECT guid FROM att_org_base WHERE guid = #{orgGuid}
|
|
|
+ UNION ALL
|
|
|
+ SELECT e.org_guid FROM att_org_ext e WHERE e.admin_wiun_guid = #{orgGuid}
|
|
|
+ UNION ALL
|
|
|
+ SELECT b.guid FROM att_org_base b INNER JOIN subOrgs s ON b.pguid = s.guid
|
|
|
+ )
|
|
|
+ select sgdw_name as orgname,
|
|
|
+ count(1) as accicount,
|
|
|
+ sum(cast(coalesce(cas_num, '0') as numeric)) as deathcount,
|
|
|
+ sum(cast(coalesce(ser_inj_num, '0') as numeric)) as injurycount,
|
|
|
+ sum(cast(coalesce(econ_loss, '0') as numeric)) as econloss,
|
|
|
+ round(cast(sum(cast(coalesce(cas_num, '0') as numeric)) / count(1) as numeric), 2) as avgdeath,
|
|
|
+ round(cast(sum(cast(coalesce(ser_inj_num, '0') as numeric)) / count(1) as numeric), 2) as avginjury,
|
|
|
+ round(cast(sum(cast(coalesce(econ_loss, '0') as numeric)) / count(1) as numeric), 2) as avgeconloss
|
|
|
+ from obj_acci
|
|
|
+ </when>
|
|
|
+ <otherwise>
|
|
|
+ select sgdw_name as orgname,
|
|
|
+ count(1) as accicount,
|
|
|
+ sum(cast(coalesce(cas_num, '0') as numeric)) as deathcount,
|
|
|
+ sum(cast(coalesce(ser_inj_num, '0') as numeric)) as injurycount,
|
|
|
+ sum(cast(coalesce(econ_loss, '0') as numeric)) as econloss,
|
|
|
+ round(cast(sum(cast(coalesce(cas_num, '0') as numeric)) / count(1) as numeric), 2) as avgdeath,
|
|
|
+ round(cast(sum(cast(coalesce(ser_inj_num, '0') as numeric)) / count(1) as numeric), 2) as avginjury,
|
|
|
+ round(cast(sum(cast(coalesce(econ_loss, '0') as numeric)) / count(1) as numeric), 2) as avgeconloss
|
|
|
+ from obj_acci
|
|
|
+ where 1=1
|
|
|
+ </otherwise>
|
|
|
+ </choose>
|
|
|
<where>
|
|
|
<if test="orgNature != null and orgNature != ''">AND acci_wiun_type = #{orgNature}</if>
|
|
|
<if test="beginTime != null and beginTime != ''">AND occu_time >= #{beginTime}</if>
|
|
|
<if test="endTime != null and endTime != ''">AND occu_time <= #{endTime}</if>
|
|
|
+ <if test="orgGuid != null and orgGuid != ''">AND acci_wiun_guid in (select guid from subOrgs)</if>
|
|
|
</where>
|
|
|
group by sgdw_name
|
|
|
- order by acciCount desc
|
|
|
+ order by accicount desc
|
|
|
</select>
|
|
|
</mapper>
|