| | |
| | | |
| | | <select id="selectAttResBaseGeneralInvestigation" |
| | | resultType="cn.gistack.sm.sjztmd.vo.AttResBaseGeneralInvestigationVO"> |
| | | |
| | | SELECT base.* from ( |
| | | select |
| | | a.*, |
| | | b."check_state" AS tb_state, |
| | | b."guid" as tbStateId, |
| | | b."tb_year", |
| | | b."tb_quarter", |
| | | (CASE WHEN tmp.totalDangerNum>0 THEN true ELSE false END) as hasDanger, |
| | | tmp.totalDangerNum, |
| | | tmp.termiteNum, |
| | | tmp.otherNum |
| | | a.*, |
| | | b."check_state" AS tb_state, |
| | | b."guid" as tbStateId, |
| | | b."tb_year", |
| | | b."tb_quarter", |
| | | (CASE WHEN tmp.totalDangerNum>0 THEN 1 ELSE 2 END) as hasDanger, |
| | | tmp.totalDangerNum, |
| | | tmp.termiteNum, |
| | | tmp.otherNum |
| | | from sjzt_md."att_res_base" a |
| | | left join "SJZT_MD"."att_ad_base" aab on aab."guid" = a."interior_ad_guid" |
| | | left join "SJZT_MD"."att_ad_base" aa on aab."p_ad_code" = aa."ad_code" |
| | |
| | | left join |
| | | |
| | | ( |
| | | SELECT TRGI."tb_state_id",TRGI."res_guid", |
| | | SELECT TRGI."tb_state_id",TRGI."res_guid", |
| | | |
| | | SUM(CASE WHEN (trgi."hazard_rating" != '无危害') THEN 1 ELSE 0 END) AS totalDangerNum, |
| | | SUM(CASE WHEN (trgi."investigation_variety" = '白蚁' and trgi."hazard_rating" != '无危害') THEN 1 ELSE 0 END) AS termiteNum, |
| | | SUM(CASE WHEN (trgi."investigation_variety" != '白蚁' and trgi."hazard_rating" != '无危害') THEN 1 ELSE 0 END) AS otherNum |
| | | from sjzt_md."tb_res_general_investigation" trgi |
| | | where 1=1 |
| | | <if test="attResBase.tbYear !=null and attResBase.tbYear !=''"> |
| | | AND TRGI."tb_year" = #{attResBase.tbYear} |
| | | </if> |
| | | group by TRGI."tb_state_id",TRGI."res_guid" |
| | | SUM(CASE WHEN (trgi."hazard_rating" != '无危害') THEN 1 ELSE 0 END) AS totalDangerNum, |
| | | SUM(CASE WHEN (trgi."investigation_variety" = '白蚁' and trgi."hazard_rating" != '无危害') THEN 1 ELSE 0 END) AS termiteNum, |
| | | SUM(CASE WHEN (trgi."investigation_variety" != '白蚁' and trgi."hazard_rating" != '无危害') THEN 1 ELSE 0 END) AS otherNum |
| | | from sjzt_md."tb_res_general_investigation" trgi |
| | | where 1=1 |
| | | <if test="attResBase.tbYear !=null and attResBase.tbYear !=''"> |
| | | AND TRGI."tb_year" = #{attResBase.tbYear} |
| | | </if> |
| | | group by TRGI."tb_state_id",TRGI."res_guid" |
| | | |
| | | ) tmp on tmp."tb_state_id" = b."guid" |
| | | |
| | |
| | | and (aab."ad_code" = #{attResBase.adCode} or aa."ad_code" = #{attResBase.adCode} or ab."ad_code" = |
| | | #{attResBase.adCode} or ac."ad_code" = #{attResBase.adCode}) |
| | | </if> |
| | | ) base where 1=1 |
| | | <if test="attResBase.hasDanger != null and attResBase.hasDanger != '' "> |
| | | and base.hasDanger = #{attResBase.hasDanger} |
| | | </if> |
| | | |
| | | |
| | | </select> |
| | | |
| | | <select id="getListByRegion" resultType="cn.gistack.sm.sjztmd.entity.AttResBase"> |