| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489 |
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="cn.com.goldenwater.dcproj.dao.BisInspSelAreaDao">
- <resultMap type="cn.com.goldenwater.dcproj.model.BisInspSelArea" id="bisInspSelAreaResultMap">
- <result property="areaId" column="AREA_ID"/>
- <result property="id" column="ID"/>
- <result property="adCode" column="AD_CODE"/>
- <result property="adName" column="AD_NAME"/>
- <result property="idtm" column="IDTM"/>
- <result property="pnm" column="PNM"/>
- <result property="impData" column="IMP_DATA"/>
- <result property="orgId" column="ORG_ID"/>
- </resultMap>
- <resultMap type="cn.com.goldenwater.dcproj.model.BisInspSelArea" id="bisInspSelAreaResultMap2">
- <result property="areaId" column="AREA_ID"/>
- <result property="id" column="ID"/>
- <result property="adCode" column="AD_CODE"/>
- <result property="adName" column="AD_NAME"/>
- <result property="idtm" column="IDTM"/>
- <result property="pnm" column="PNM"/>
- <result property="orgId" column="ORG_ID"/>
- </resultMap>
- <sql id="table_columns">
- AREA_ID,
- ID,
- AD_CODE,
- AD_NAME,
- IDTM,
- IMP_DATA,ORG_ID
- </sql>
- <sql id="table_columns2">
- a.AREA_ID,
- a.ID,
- a.AD_CODE,
- a.AD_NAME,
- a.IDTM,
- b.PNM,
- a.ORG_ID
- </sql>
- <sql id="entity_properties">
- #{areaId},
- #{id},
- #{adCode},
- #{adName},
- #{idtm},
- #{impData},#{orgId}
- </sql>
- <!-- 使用like用法:columnName like concat('%',#columnName#,'%') -->
- <sql id="page_where">
- <trim prefix="where" prefixOverrides="and | or ">
- <if test="id != null and id != ''">and ID = #{id}</if>
- <if test='adCode != null and adCode != ""'>and AD_CODE like '${adCode}%'</if>
- <if test='adName != null and adName != ""'>and AD_NAME like '%${adName}%'</if>
- <if test="idtm != null">and IDTM = #{idtm}</if>
- <if test="orgId != null and orgId !=''">and ORG_ID = #{orgId}</if>
- </trim>
- </sql>
- <sql id="page_where4">
- <trim prefix="where" prefixOverrides="and | or ">
- <if test="adCodes != null and adCodes != ''">and AD_CODE in
- <foreach collection="adCodes.split(',')" index="index" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- </trim>
- </sql>
- <sql id="page_where3">
- <trim prefix="where" prefixOverrides="and | or ">
- <if test="id != null and id != ''">and a.ID = #{id}</if>
- <if test='adCode != null and adCode != ""'>and a.AD_CODE like CONCAT(#{adCode},'%') </if>
- <if test='adName != null and adName != ""'>and a.AD_NAME like '%${adName}%'</if>
- <if test="idtm != null">and a.IDTM = #{idtm}</if>
- <include refid="choseSql"/>
- </trim>
- </sql>
- <sql id="page_where2">
- <trim prefix="where" prefixOverrides="and | or ">
- <if test='id != null and id != "" '>and a.ID like CONCAT(#{id},'%')</if>
- <if test='adCode != null and adCode != "" '>and a.AD_CODE = #{adCode}</if>
- <if test='adName != null and adName != "" '>and a.AD_NAME like '%${adName}%'</if>
- <if test="idtm != null">and a.IDTM = #{idtm}</if>
- <include refid="choseSql"/>
- <choose>
- <when test="province !=null and province !=''">
- and a.AD_CODE like '${province}%'
- </when>
- </choose>
- </trim>
- </sql>
- <select id="get" resultMap="bisInspSelAreaResultMap" parameterType="String">
- select
- <include refid="table_columns"/>
- from BIS_INSP_SEL_AREA where AREA_ID = #{areaId}
- </select>
- <select id="getBy" resultMap="bisInspSelAreaResultMap">
- select
- <include refid="table_columns"/>
- from BIS_INSP_SEL_AREA
- <include refid="page_where"/>
- </select>
- <select id="getAllSub" resultMap="bisInspSelAreaResultMap2">
- select
- <include refid="table_columns2"/>
- from BIS_INSP_SEL_AREA a
- LEFT JOIN BIS_INSP_ALL b ON a.ID = b.ID
- <include refid="page_where2"/>
- </select>
- <sql id="choseSql">
- <choose>
- <when test="orgId !=null and orgId !=''">
- and a.org_id=#{orgId}
- </when>
- <otherwise>
- and a.org_id is null
- </otherwise>
- </choose>
- </sql>
- <select id="findAll" resultMap="bisInspSelAreaResultMap">
- select
- <include refid="table_columns"/>
- from BIS_INSP_SEL_AREA
- </select>
- <select id="findList" resultMap="bisInspSelAreaResultMap2">
- <choose>
- <when test="id!=null and id!=''">
- select
- <include refid="table_columns2"/>
- from BIS_INSP_SEL_AREA a
- LEFT JOIN BIS_INSP_ALL b ON a.ID = b.ID
- <include refid="page_where3"/>
- </when>
- <otherwise>
- SELECT GUID ID,AD_CODE,AD_NAME
- from att_ad_x_base
- <include refid="page_where4"/>
- </otherwise>
- </choose>
- </select>
- <select id="selectCount" resultType="int">
- select count(ID) from BIS_INSP_SEL_AREA
- <include refid="page_where"/>
- </select>
- <insert id="insert" parameterType="cn.com.goldenwater.dcproj.model.BisInspSelArea">
- insert into BIS_INSP_SEL_AREA(
- <include refid="table_columns"/>
- )
- values (
- <include refid="entity_properties"/>
- )
- </insert>
- <delete id="delete" parameterType="java.lang.String">
- delete from BIS_INSP_SEL_AREA where AREA_ID = #{areaId}
- </delete>
- <delete id="deleteBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspSelArea">
- delete from BIS_INSP_SEL_AREA
- <include refid="page_where"/>
- </delete>
- <update id="deleteInFlag" parameterType="java.lang.String">
- update BIS_INSP_SEL_AREA set flag_valid = 0 where AREA_ID = #{areaId}
- </update>
- <update id="update" parameterType="cn.com.goldenwater.dcproj.model.BisInspSelArea">
- update BIS_INSP_SEL_AREA
- <trim prefix="set" suffixOverrides=",">
- <if test="id != null and id != ''">ID = #{id},</if>
- <if test="adCode != null and adCode != ''">AD_CODE = #{adCode},</if>
- <if test="adName != null and adName != ''">AD_NAME = #{adName},</if>
- <if test="idtm != null">IDTM = #{idtm},</if>
- <if test="impData != null">IMP_DATA = #{impData},</if>
- <if test="orgId != null and orgId !=''">ORG_ID = #{orgId},</if>
- </trim>
- <where>AREA_ID = #{areaId}</where>
- </update>
- <update id="updateBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspSelArea">
- update BIS_INSP_SEL_AREA
- <trim prefix="set" suffixOverrides=",">
- <if test="id != null and id != ''">ID = #{id},</if>
- <if test="adCode != null and adCode != ''">AD_CODE = #{adCode},</if>
- <if test="adName != null and adName != ''">AD_NAME = #{adName},</if>
- <if test="idtm != null">IDTM = #{idtm},</if>
- <if test="impData != null">IMP_DATA = #{impData},</if>
- <if test="orgId != null and orgId !=''">ORG_ID = #{orgId},</if>
- </trim>
- <include refid="page_where"/>
- </update>
- <!-- 其他自定义SQL -->
- <!-- 根据人员id查询可选区域 -->
- <select id="getAreaByPersid" resultType="java.util.HashMap">
- SELECT
- d.AREA_ID,
- d.ID,
- DATE_FORMAT(d.IDTM,'%Y-%m-%d %T') idtm,
- d.AD_NAME,
- d.AD_CODE
- FROM BIS_INSP_ALL_RLATION_PERS e
- LEFT JOIN BIS_INSP_ALL_RLATION b ON E.GUID = B.PERSID
- LEFT JOIN BIS_INSP_ALL c ON b.ID = c.ID
- LEFT JOIN BIS_INSP_SEL_AREA a ON a.ID like CONCAT(c.ID, '%')
- WHERE E.GUID = #{persId} AND a.AREA_ID IS NOT NULL
- <include refid="choseSql"/>
- </select>
- <!-- 根据人员id查询可选区域 -->
- <select id="getProvinceAreaByPersid" resultType="java.util.HashMap">
- SELECT DISTINCT
- B.AD_CODE,
- B.AD_NAME
- FROM
- (
- SELECT
- concat(substr( e.AD_CODE, 1, #{end} ), #{str}) AD_CODE2,
- e.AD_NAME
- FROM
- (
- SELECT
- a.*
- FROM
- BIS_INSP_SEL_AREA a
- LEFT JOIN BIS_INSP_ALL_RLATION b ON a.ID LIKE CONCAT( b.ID, '%' )
- LEFT JOIN BIS_INSP_ALL_RLATION_PERS c ON c.guid = b.PERSID
- <!--JOIN BIS_INSP_ALL l on b.id=l.id
- JOIN BIS_INSP_ALL_OBJ j on b.id=j.id-->
- WHERE
- c.guid = #{persId}
- <include refid="choseSql"/>
- ) e
- WHERE
- AD_CODE like concat('%',#{pattern},'%')
- ) a
- LEFT JOIN ATT_AD_BASE b ON a.AD_CODE2 = b.AD_CODE
- WHERE B.AD_CODE != #{adCode}
- ORDER BY B.AD_CODE
- </select>
- <select id="getAddvcdByAdCode" resultType="java.util.HashMap">
- SELECT
- AD_CODE,
- AD_NAME
- FROM
- ATT_AD_BASE
- WHERE
- AD_CODE LIKE #{adCode}
- <if test="adGrad != null and adGrad.length()>0">AND AD_GRAD = #{adGrad}</if>
- ORDER BY
- AD_CODE
- </select>
- <select id="getAddvcdCacheByAdCode" resultType="java.util.HashMap">
- SELECT
- AD_CODE,
- AD_NAME
- FROM
- ATT_AD_BASE
- WHERE
- AD_CODE like concat('%',#{adCode},'%')
- <if test="adGrad != null and adGrad.length()>0">AND AD_GRAD = #{adGrad}</if>
- ORDER BY
- AD_CODE
- </select>
- <!-- 根据区域id,查询区域包含人员信息 -->
- <select id="getPersByArea" resultType="java.util.HashMap">
- SELECT E.* FROM BIS_INSP_ALL_RLATION_PERS e
- LEFT JOIN BIS_INSP_ALL_RLATION a ON E.GUID = A.PERSID
- LEFT JOIN BIS_INSP_ALL c ON A.ID = c.ID
- LEFT JOIN BIS_INSP_SEL_AREA d ON c.ID = d.ID
- WHERE d.AD_CODE = #{adCode} AND d.AREA_ID IS NOT NULL
- <include refid="choseSql"/>
- </select>
- <!-- 水库同组范围内只能督查一次 -->
- <select id="getResByArea" resultType="java.util.HashMap">
- SELECT
- a.*,j.obj_id,rg.RGSTR_ID,rg.STATE
- FROM
- ATT_RS_BASE a
- LEFT JOIN ( SELECT * FROM BIS_INSP_ALL_OBJ
- WHERE FIND_IN_SET(ID, getSubNodes_bis_insp_all( #{id},1,0)) > 0
- ) b ON b.CODE = a.RS_CODE
- LEFT JOIN BIS_INSP_ALL_OBJ J ON a.RS_CODE = J.code
- left join BIS_INSP_RSVR_RGSTR rg on j.obj_id = rg.obj_id
- WHERE
- a.ADM_DIV like concat('%',#{adCode},'%')
- <if test="province !=null and province !=''">
- and a.ADM_DIV like '${province}%'
- </if>
- AND b.CODE IS NULL
- <if test="adName != null and adName.length()>0">AND a.RS_NAME like CONCAT('%',CONCAT(#{adName}, '%'))</if>
- <if test="areaId != null and areaId.length()>0">AND a.ENG_SCAL in (${areaId})</if>
- <if test="pType =='1'.toString()">
- AND a.ENG_SCAL in(4,5)
- </if>
- <if test="pType =='36'.toString()">
- AND a.ENG_SCAL in(1,2,3)
- </if>
- </select>
- <!-- 稽察项目同组范围内只能督查一次 -->
- <select id="getPawpByArea" resultType="java.util.HashMap">
- SELECT
- a.*,j.obj_id,rg.RGSTR_ID,rg.STATE
- FROM
- TAC_ATT_PAWP_BASE a
- LEFT JOIN ( SELECT * FROM BIS_INSP_ALL_OBJ a
- WHERE FIND_IN_SET(a.ID ,getSubNodes_bis_insp_all(#{id},1,0) ) > 0
- ) b ON b.CODE = a.ID
- LEFT JOIN BIS_INSP_ALL_OBJ J ON a.ID = J.code
- left join TAC_PAWP_RGSTR rg on j.obj_id = rg.obj_id
- WHERE
- 1=1
- AND b.CODE IS NULL
- <if test="province !=null and province !=''">
- AND a.ad_code like '${province}%'
- </if>
- <if test="orgId != null and orgId !=''">AND J.ORG_ID = #{orgId}</if>
- <if test="adCode != null and adCode.length()>0">AND a.AD_CODE like concat('%',#{adCode},'%') </if>
- <if test="objName != null and objName.length()>0">AND a.NAME like CONCAT('%',CONCAT(#{objName}, '%'))</if>
- </select>
- <!--根据节点id查询可选行政区-->
- <select id="getOptionalArea" resultType="java.util.HashMap">
- SELECT A.AD_CODE, A.AD_NAME, A.AD_GRAD
- FROM ATT_AD_BASE A
- WHERE A.AD_GRAD != '1'
- AND A.AD_CODE NOT IN (
- SELECT AD_CODE FROM BIS_INSP_SEL_AREA A WHERE ID = #{id})
- AND a.AD_CODE like #{adGrid}
- AND a.AD_CODE != #{adCode}
- <if test="adName != null">AND a.AD_NAME like CONCAT('%',CONCAT(#{adName}, '%'))</if>
- ORDER BY a.AD_CODE
- </select>
- <!--根据节点id查询可选行政区-->
- <select id="getPnmByBatchAndAdCode" resultType="java.util.HashMap">
- SELECT A.ID, P.PNM
- FROM BIS_INSP_SEL_AREA A
- JOIN BIS_INSP_ALL P ON A.ID = P.ID
- WHERE A.ID LIKE CONCAT(#{id},'%') AND A.AD_CODE = #{adCode}
- </select>
- <select id="getResByGroup" parameterType="cn.com.goldenwater.dcproj.param.InGroupResParam"
- resultType="cn.com.goldenwater.dcproj.model.AttRsBase">
- SELECT * FROM (
- SELECT A.rs_code,
- A.rs_name,
- A.longitude,
- A.latitude,
- A.location,
- A.eng_scal,
- A.lim_stag,
- A.tot_cap,
- A.rs_adm_name,
- A.rs_adm_code,
- A.rs_adm_dep,
- A.adm_att_rel,
- A.adm_div,
- A.rs_type,
- A.dam_type_mat,
- A.dam_type_str,
- A.dam_size_hig,
- A.center_x,
- A.center_y,
- A.src,
- A.data_quality,
- A.center_x_gd,
- A.center_y_gd,
- A.rs_loc,
- A.reg_code,
- A.comp_date,
- A.intm,
- A.reg_no,
- ifnull(B.state, 0) as hst_insp,
- A.pers_id,
- A.uptm,
- A.chk_state,
- A.edtr_pesr,
- A.slpc_adm_div,
- A.adm_div_name,
- A.PROVINCIAL
- FROM ATT_RS_BASE A
- LEFT JOIN (
- SELECT a.RS_CODE, '1' as state
- FROM ATT_RS_BASE a
- WHERE Exists (select code FROM BIS_INSP_ALL_OBJ o
- where o.code = a.RS_CODE
- <if test="pType != null and pType != '' ">
- and o.ptype = #{pType}
- </if>
- and DATE_FORMAT(o.OBJ_INTM,'%Y')=DATE_FORMAT(now(),'%Y')
- )
- ) B ON A.RS_CODE = B.RS_CODE
- ) A
- WHERE RS_CODE NOT IN (
- SELECT CODE FROM BIS_INSP_ALL_OBJ a WHERE ID = #{groupId}
- )
- <if test="hstInsp !=null and hstInsp !=''">
- and hst_insp = #{hstInsp}
- </if>
- <if test="province !=null and province !=''">
- and adm_div like '${province}%'
- </if>
- <!--四川加入部分中型水库,按照小水库督查来检查-->
- <choose>
- <when test="pType =='1'.toString() and province =='51'.toString()">
- and ENG_SCAL in (3,4,5)
- </when>
- <otherwise>
- and ENG_SCAL in (4,5)
- </otherwise>
- </choose>
- <if test="pType =='36'.toString()">
- and ENG_SCAL in (1,2,3)
- </if>
- <if test="pType =='26'.toString()">
- and ENG_SCAL in (1,2,3)
- </if>
- <if test="province =='51'.toString()">
- and ENG_SCAL in (3,4,5)
- </if>
- <if test="adcd != null and adcd != ''">and ${adcd}</if>
- <if test="adnm != null and adnm != ''">and ADM_DIV_NAME LIKE '%${adnm}%'</if>
- <if test="rsName != null and rsName != ''">and RS_NAME LIKE '%${rsName}%'</if>
- <if test="engScal != null and engScal != ''">and ENG_SCAL = #{engScal}</if>
- <if test="isTask != null and isTask != ''">and A.IS_TASK = #{isTask}</if>
- order by rs_code
- </select>
- <delete id="deleteByGroupId">
- DELETE FROM BIS_INSP_SEL_AREA a WHERE ID = #{id} AND AD_CODE = #{adCode}
- <include refid="choseSql"/>
- </delete>
- <sql id="choseSqlBak">
- <choose>
- <when test="orgId !=null and orgId !=''">
- and B.org_id =#{orgId}
- </when>
- <otherwise>
- and B.org_id is null
- </otherwise>
- </choose>
- </sql>
- <select id="getAreaByGroup" resultType="java.util.HashMap">
- SELECT A.AD_CODE,
- A.AD_NAME,
- A.AD_GRAD FROM ATT_AD_X_BASE A LEFT JOIN BIS_INSP_SEL_AREA B ON A.AD_CODE = B.AD_CODE
- WHERE B.ID = #{id}
- <if test="adGrid !=null and adGrid !=''">
- AND A.AD_CODE LIKE #{adGrid}
- </if>
- AND A.AD_CODE != #{adCode}
- <if test="adName != null and adName != ''">AND A.AD_NAME like CONCAT('%',CONCAT(#{adName}, '%'))</if>
- <if test="province !=null and province !=''">
- AND A.AD_CODE like '${province}%'
- </if>
- ORDER BY A.AD_CODE
- </select>
- <select id="getAreaByAdCode" resultType="java.util.HashMap">
- SELECT AD_CODE,AD_NAME,AD_GRAD FROM ATT_AD_BASE WHERE AD_FCODE = #{adCode}
- <if test="adName != null and adName != ''">AND AD_NAME like CONCAT('%',CONCAT(#{adName}, '%'))</if>
- ORDER BY AD_CODE
- </select>
- </mapper>
|