| | |
| | | (CASE WHEN tmp.totalDangerNum>0 THEN 1 ELSE 2 END) as hasDanger, |
| | | tmp.totalDangerNum, |
| | | tmp.termiteNum, |
| | | tmp.otherNum |
| | | tmp.otherNum, |
| | | tmp.totalDangerLength, |
| | | ifnull(tmp.totalDanger,0) totalDanger, |
| | | ifnull(tmp.totalDangerSr,0) totalDangerSr, |
| | | ifnull(tmp.totalDangerCb,0) totalDangerCb, |
| | | ifnull(tmp.totalDangerDw,0) totalDangerDw, |
| | | ( |
| | | select sum(tdud."danger_length") from sjzt_md."tb_dyke_unit_danger" tdud |
| | | left join "SJZT_MD"."tb_dyke_investigation_state" tdis on (tdud."dyke_id" = tdis."dyke_guid") |
| | | where trd."guid" = tdud."dyke_id" and tdud."danger_level" = 1 and tdis."check_state" > 1 |
| | | ) as firstLength, |
| | | ( |
| | | select sum(tdud."danger_length") from sjzt_md."tb_dyke_unit_danger" tdud |
| | | left join "SJZT_MD"."tb_dyke_investigation_state" tdis on (tdud."dyke_id" = tdis."dyke_guid") |
| | | where trd."guid" = tdud."dyke_id" and tdud."danger_level" = 2 and tdis."check_state" > 1 |
| | | ) as secondLength, |
| | | ( |
| | | select sum(tdud."danger_length") from sjzt_md."tb_dyke_unit_danger" tdud |
| | | left join "SJZT_MD"."tb_dyke_investigation_state" tdis on (tdud."dyke_id" = tdis."dyke_guid") |
| | | where trd."guid" = tdud."dyke_id" and tdud."danger_level" = 3 and tdis."check_state" > 1 |
| | | ) as thirdLength |
| | | |
| | | from sjzt_md."tb_res_dyke" trd |
| | | left join "SJZT_MD"."tb_dyke_investigation_state" tdis on trd."guid" = tdis."dyke_guid" |
| | | left join YWXT."att_ad_base" aa on aa."guid" = trd."ad_code" |
| | | left join YWXT."att_ad_base" ab on ab."ad_code" = aa."p_ad_code" |
| | | left join YWXT."att_ad_base" ac on ac."ad_code" = ab."p_ad_code" |
| | | left join YWXT."att_ad_base" ad on ad."ad_code" = ac."p_ad_code" |
| | | left join |
| | | ( |
| | | select |
| | | temp2."tb_state_id", |
| | | temp2."dyke_guid", |
| | | temp2.totalDangerNum, |
| | | temp2.termiteNum, |
| | | temp2.otherNum, |
| | | SUM(CASE WHEN temp2.dangerLength THEN temp2.dangerLength ELSE 0 END) AS totalDangerLength |
| | | sum(temp2.totalDangerNum) as totalDangerNum, |
| | | sum(temp2.termiteNum) as termiteNum, |
| | | sum(temp2.otherNum) as otherNum, |
| | | SUM(CASE WHEN temp2.dangerLength THEN temp2.dangerLength ELSE 0 END) AS totalDangerLength, |
| | | sum(temp2.totalDanger) as totalDanger, |
| | | sum(temp2.totalDangerSr) as totalDangerSr, |
| | | sum(temp2.totalDangerCb) as totalDangerCb, |
| | | sum(temp2.totalDangerDw) as totalDangerDw |
| | | from( |
| | | SELECT |
| | | TEMP1.*, |
| | |
| | | SUM(CASE WHEN (tdi."danger_length") THEN tdi."danger_length" ELSE 0 END) AS dangerLength, |
| | | SUM(CASE WHEN (tdi."hazard_rating" != '无危害') THEN 1 ELSE 0 END) AS totalDangerNum, |
| | | SUM(CASE WHEN (tdi."investigation_variety" = '白蚁' and tdi."hazard_rating" != '无危害') THEN 1 ELSE 0 END) AS termiteNum, |
| | | SUM(CASE WHEN (tdi."investigation_variety" != '白蚁' and tdi."hazard_rating" != '无危害') THEN 1 ELSE 0 END) AS otherNum |
| | | SUM(CASE WHEN (tdi."investigation_variety" != '白蚁' and tdi."hazard_rating" != '无危害') THEN 1 ELSE 0 END) AS otherNum, |
| | | SUM(CASE WHEN (tdi."is_danger" != '否') THEN 1 ELSE 0 END) AS totalDanger, |
| | | SUM(CASE WHEN (json_value(tdi."danger_info", '$.sr') != '') THEN json_value(tdi."danger_info", '$.sr') ELSE 0 END) AS totalDangerSr, |
| | | SUM(CASE WHEN (json_value(tdi."danger_info", '$.cb') != '') THEN json_value(tdi."danger_info", '$.cb') ELSE 0 END) AS totalDangerCb, |
| | | SUM(CASE WHEN (json_value(tdi."danger_info", '$.dw') != '') THEN json_value(tdi."danger_info", '$.dw') ELSE 0 END) AS totalDangerDw |
| | | from sjzt_md."tb_dyke_investigation" tdi |
| | | where 1=1 |
| | | <if test="vo.tbYear !=null and vo.tbYear !=''"> |
| | |
| | | )TEMP1 |
| | | )temp2 group by |
| | | temp2."tb_state_id", |
| | | temp2."dyke_guid", |
| | | temp2.totalDangerNum, |
| | | temp2.termiteNum, |
| | | temp2.otherNum |
| | | temp2."dyke_guid" |
| | | ) tmp on tmp."tb_state_id" = tdis."guid" |
| | | where 1 = 1 |
| | | <if test="vo.name !=null and vo.name !=''"> |
| | |
| | | ) |
| | | </if> |
| | | <if test="vo.adCode != null and vo.adCode != '' "> |
| | | and trd."ad_code" LIKE #{vo.adCode} |
| | | and concat(aa."ad_code",ab."ad_code",ac."ad_code",ad."ad_code") LIKE concat('%',#{vo.adCode},'%') |
| | | </if> |
| | | ) base where 1=1 |
| | | <if test="vo.hasDanger != null and vo.hasDanger != '' "> |
| | | and base.hasDanger = #{vo.hasDanger} |
| | | </if> |
| | | <if test="vo.dangerLevelQuery != null and vo.dangerLevelQuery == 0 "> |
| | | and base.firstLength is null and base.secondLength is null and base.thirdLength is null |
| | | </if> |
| | | <if test="vo.dangerLevelQuery != null and vo.dangerLevelQuery == 1 "> |
| | | and base.firstLength > 0 |
| | | </if> |
| | | <if test="vo.dangerLevelQuery != null and vo.dangerLevelQuery == 2 "> |
| | | and base.secondLength > 0 |
| | | </if> |
| | | <if test="vo.dangerLevelQuery != null and vo.dangerLevelQuery == 3 "> |
| | | and base.thirdLength > 0 |
| | | </if> |
| | | |
| | | </select> |
| | | </mapper> |