| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320 |
- <?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.BisInspVillRgstrDao">
- <resultMap type="cn.com.goldenwater.dcproj.model.BisInspVillRgstr" id="bisInspVillRgstrResultMap">
- <result property="dataStat" column="DATA_STAT"/>
- <result property="state" column="STATE"/>
- <result property="engId" column="ENG_ID"/>
- <result property="objId" column="OBJ_ID"/>
- <result property="regsNm" column="REGS_NM"/>
- <result property="groupLeader" column="GROUP_LEADER"/>
- <result property="groupLeaderTel" column="GROUP_LEADER_TEL"/>
- <result property="recPersId" column="REC_PERS_ID"/>
- <result property="recPers" column="REC_PERS"/>
- <result property="recPersTel" column="REC_PERS_TEL"/>
- <result property="intm" column="INTM"/>
- <result property="uptm" column="UPTM"/>
- <result property="note" column="NOTE"/>
- <result property="inspGroupId" column="INSP_GROUP_ID"/>
- <result property="orgId" column="ORG_ID"/>
- </resultMap>
- <sql id="table_columns">
- DATA_STAT ,
- STATE ,
- ENG_ID ,
- OBJ_ID ,
- REGS_NM ,
- GROUP_LEADER ,
- GROUP_LEADER_TEL ,
- REC_PERS_ID ,
- REC_PERS ,
- REC_PERS_TEL ,
- DATE_FORMAT(INTM,'%Y-%m-%d %T') INTM,
- DATE_FORMAT(UPTM,'%Y-%m-%d %T') UPTM,
- NOTE ,ORG_ID
- </sql>
- <sql id="table_columns2">
- DATA_STAT ,
- STATE ,
- ENG_ID ,
- OBJ_ID ,
- REGS_NM ,
- GROUP_LEADER ,
- GROUP_LEADER_TEL ,
- REC_PERS_ID ,
- REC_PERS ,
- REC_PERS_TEL ,
- INTM ,
- UPTM ,
- NOTE ,ORG_ID
- </sql>
- <sql id="entity_properties">
- #{dataStat},
- #{state},
- #{engId},
- #{objId},
- #{regsNm},
- #{groupLeader},
- #{groupLeaderTel},
- #{recPersId},
- #{recPers},
- #{recPersTel},
- DATE_FORMAT(#{intm},'%Y-%m-%d %T') ,
- DATE_FORMAT(#{uptm},'%Y-%m-%d %T') ,
- #{note},#{orgId}
- </sql>
- <!-- 使用like用法:columnName like concat('%',#columnName#,'%') -->
- <sql id="page_where">
- <trim prefix="where" prefixOverrides="and | or ">
- <if test="dataStat != null and dataStat != ''">and DATA_STAT = #{dataStat}</if>
- <if test="state != null and state != ''">and STATE = #{state}</if>
- <if test="engId != null and engId != ''">and ENG_ID = #{engId}</if>
- <if test="objId != null and objId != ''">and OBJ_ID = #{objId}</if>
- <if test="regsNm != null and regsNm != ''">and REGS_NM = #{regsNm}</if>
- <if test="groupLeader != null and groupLeader != ''">and GROUP_LEADER = #{groupLeader}</if>
- <if test="groupLeaderTel != null and groupLeaderTel != ''">and GROUP_LEADER_TEL = #{groupLeaderTel}</if>
- <if test="recPersId != null and recPersId != ''">and REC_PERS_ID = #{recPersId}</if>
- <if test="recPers != null and recPers != ''">and REC_PERS = #{recPers}</if>
- <if test="recPersTel != null and recPersTel != ''">and REC_PERS_TEL = #{recPersTel}</if>
- <if test="intm != null and intm != ''">and INTM = STR_TO_DATE(#{intm},'%Y-%m-%d %T')</if>
- <if test="uptm != null and uptm != ''">and UPTM = STR_TO_DATE(#{uptm},'%Y-%m-%d %T')</if>
- <if test="note != null and note != ''">and NOTE = #{note}</if>
- <if test="orgId != null and orgId != ''">and ORG_ID = #{orgId}</if>
- </trim>
- </sql>
- <select id="get" resultMap="bisInspVillRgstrResultMap" parameterType="String" >
- select <include refid="table_columns" /> from BIS_INSP_VILL_RGSTR where ENG_ID = #{id}
- </select>
- <select id="getBy" resultMap="bisInspVillRgstrResultMap">
- select <include refid="table_columns" /> from BIS_INSP_VILL_RGSTR <include refid="page_where" />
- </select>
- <select id="findAll" resultMap="bisInspVillRgstrResultMap">
- select <include refid="table_columns" /> from BIS_INSP_VILL_RGSTR
- </select>
- <select id="findList" resultMap="bisInspVillRgstrResultMap">
- select <include refid="table_columns" />
- from BIS_INSP_VILL_RGSTR
- <include refid="page_where" />
- ORDER BY UPTM DESC
- </select>
- <select id="findPageByType" resultType="cn.com.goldenwater.dcproj.dto.BisInspVillRgstrDto" parameterType="cn.com.goldenwater.dcproj.param.TypeParam" >
- select * from (select A.*,CASE WHEN b.state IS NULL THEN '0' ELSE b.state END AS wtdstState,B.ENG_ID,B.INTM
- FROM BIS_INSP_ALL_OBJ A
- LEFT JOIN BIS_INSP_VILL_RGSTR B
- ON A.OBJ_ID = B.OBJ_ID
- LEFT JOIN BIS_INSP_ALL ia
- ON A.id=ia.id
- where 1=1
- <if test="tabType =='2'.toString()">
- and ia.entm < DATE_ADD(STR_TO_DATE(#{nowTime},'%Y-%m-%d'),INTERVAL 1 DAY)
- </if>
- <if test="tabType =='1'.toString()">
- and ia.entm >=STR_TO_DATE(#{nowTime},'%Y-%m-%d')
- </if>
- <if test="orgId != null and orgId != ''">and A.ORG_ID = #{orgId}</if>
- and
- A.id in (${inIdsSql})
- ) a
- where ptype=#{pType}
- <if test="plnaId !=null and plnaId !=''">
- and a.id like '${plnaId}%'
- </if>
- <if test="state !=null and state !=''">
- and wtdstState =#{state}
- </if>
- <if test="rsName !=null and rsName !=''">
- and a.nm like '%${rsName}%'
- </if>
- order by wtdstState asc
- <if test="orderBy != null and orderBy != ''">
- ,CONVERT(nm USING gbk)
- </if>
- </select>
- <select id="findTree" resultType="cn.com.goldenwater.dcproj.dto.BisInspVillRgstrDto" parameterType="cn.com.goldenwater.dcproj.param.TypeParam" >
- select *
- from (
- SELECT
- a.id,pid,pnm nm,0 lgtd,0 lttd,'' eng_id,''obj_id,'node'noteType,a.id code
- FROM BIS_INSP_ALL A
- where
- a.id like '002${orgId}%'
- <if test=" inIdsSql != null and inIdsSql != '' ">
- and A.id in (${inIdsSql})
- </if>
- union all
- select
- A.CODE ID,C.ID PID,A.NM NM,A.LTTD,A.LGTD,B.ENG_ID,A.obj_id,'county'noteType,A.ID code
- from bis_insp_all_obj A
- LEFT JOIN BIS_INSP_VILL_RGSTR B ON A.OBJ_ID=B.OBJ_ID
- LEFT JOIN BIS_INSP_ALL C ON A.ID=C.ID
- WHERE
- A.PTYPE='2'
- <if test=" inIdsSql != null and inIdsSql != '' ">
- and A.id in (${inIdsSql})
- </if>
- ) B where 1=1
- order by id
- </select>
- <sql id="choseSql">
- <choose>
- <when test="province !=null and province !=''">
- and B.ad_code=#{province}
- </when>
- <otherwise>
- and B.ad_code is null
- </otherwise>
- </choose>
- </sql>
- <select id="selectCount" resultType="int" >
- select count(ENG_ID) from BIS_INSP_VILL_RGSTR <include refid="page_where" />
- </select>
- <!--</select>-->
- <select id="sumVillNum" resultType="cn.com.goldenwater.dcproj.model.SumVillNUm" parameterType="String">
- select sum(tcNum) as tcNum,sum(proNum) as proNum,sum(surNum) as surNum,sum(waterUserNum) as waterUserNum from (
- SELECT max(num) as tcNum,0 as proNum,0 as surNum,0 as waterUserNum
- FROM (
- SELECT COUNT(B.VILL_ID) num
- FROM BIS_INSP_SECSURVEY_VLG B
- where B.ENG_ID=#{engId}
- UNION
- SELECT count(B.RUNSTSE_ID) num
- FROM BIS_INSP_VLGDRINK_FAC_OPER B
- where B.ENG_ID=#{engId}
- UNION
- SELECT
- COUNT(B.PRSN_WATER_ID) num
- FROM BIS_INSP_WATERUSER_INFO B
- where B.ENG_ID=#{engId} group by village_code
- )
- UNION
- SELECT 0 as tcNum,count(B.RUN_ID) as proNum,0 as surNum,0 as waterUserNum
- FROM BIS_INSP_VLGDRINK_PROJ_MANAGE B
- where B.ENG_ID=#{engId}
- UNION
- SELECT 0 as tcNum,0 as proNum, 0 as surNum, count(B.PRSN_WATER_ID) as waterUserNum
- FROM BIS_INSP_WATERUSER_INFO B
- where B.ENG_ID=#{engId}
- UNION
- SELECT
- 0 as tcNum,0 as proNum,COUNT(B.ENG_SUR_ID) as surNum,0 as waterUserNum
- FROM BIS_INSP_PRO_SOURCE_PROTECT B
- where B.ENG_ID=#{engId}
- ) w
- </select>
- <insert id="insert" parameterType="cn.com.goldenwater.dcproj.model.BisInspVillRgstr">
- insert into BIS_INSP_VILL_RGSTR( <include refid="table_columns2" /> )
- values ( <include refid="entity_properties" /> )
- </insert>
- <delete id="delete" parameterType="java.lang.String">
- delete from BIS_INSP_VILL_RGSTR where ENG_ID = #{id}
- </delete>
- <delete id="deleteBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspVillRgstr">
- delete from BIS_INSP_VILL_RGSTR <include refid="page_where" />
- </delete>
- <update id="deleteInFlag" parameterType="java.lang.String">
- update BIS_INSP_VILL_RGSTR set flag_valid = 0 where ENG_ID = #{id}
- </update>
- <update id="update" parameterType="cn.com.goldenwater.dcproj.model.BisInspVillRgstr">
- update BIS_INSP_VILL_RGSTR
- <trim prefix="set" suffixOverrides=",">
- <if test="dataStat != null and dataStat != ''"> DATA_STAT = #{dataStat},</if>
- <if test="state != null and state != ''"> STATE = #{state},</if>
- <if test="objId != null and objId != ''"> OBJ_ID = #{objId},</if>
- <if test="regsNm != null and regsNm != ''"> REGS_NM = #{regsNm},</if>
- <if test="groupLeader != null and groupLeader != ''"> GROUP_LEADER = #{groupLeader},</if>
- <if test="groupLeaderTel != null and groupLeaderTel != ''"> GROUP_LEADER_TEL = #{groupLeaderTel},</if>
- <if test="recPersId != null and recPersId != ''"> REC_PERS_ID = #{recPersId},</if>
- <if test="recPers != null and recPers != ''"> REC_PERS = #{recPers},</if>
- <if test="recPersTel != null and recPersTel != ''"> REC_PERS_TEL = #{recPersTel},</if>
- <if test="intm != null and intm != ''"> INTM = STR_TO_DATE(#{intm},'%Y-%m-%d %T'),</if>
- <if test="uptm != null and uptm != ''"> UPTM = STR_TO_DATE(#{uptm},'%Y-%m-%d %T'),</if>
- <if test="note != null and note != ''"> NOTE = #{note},</if>
- <if test="orgId != null and orgId != ''">ORG_ID = #{orgId},</if>
- </trim>
- <where>ENG_ID = #{engId}</where>
- </update>
- <update id="updateBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspVillRgstr">
- update BIS_INSP_VILL_RGSTR
- <trim prefix="set" suffixOverrides=",">
- <if test="dataStat != null and dataStat != ''"> DATA_STAT = #{dataStat},</if>
- <if test="state != null and state != ''"> STATE = #{state},</if>
- <if test="objId != null and objId != ''"> OBJ_ID = #{objId},</if>
- <if test="regsNm != null and regsNm != ''"> REGS_NM = #{regsNm},</if>
- <if test="groupLeader != null and groupLeader != ''"> GROUP_LEADER = #{groupLeader},</if>
- <if test="groupLeaderTel != null and groupLeaderTel != ''"> GROUP_LEADER_TEL = #{groupLeaderTel},</if>
- <if test="recPersId != null and recPersId != ''"> REC_PERS_ID = #{recPersId},</if>
- <if test="recPers != null and recPers != ''"> REC_PERS = #{recPers},</if>
- <if test="recPersTel != null and recPersTel != ''"> REC_PERS_TEL = #{recPersTel},</if>
- <if test="intm != null and intm != ''"> INTM = STR_TO_DATE(#{intm},'%Y-%m-%d %T'),</if>
- <if test="uptm != null and uptm != ''"> UPTM = STR_TO_DATE(#{uptm},'%Y-%m-%d %T'),</if>
- <if test="note != null and note != ''"> NOTE = #{note},</if>
- <if test="orgId != null and orgId != ''">ORG_ID = #{orgId},</if>
- </trim>
- <include refid="page_where" />
- </update>
- <!-- 其他自定义SQL -->
- <select id="findListByPersId" resultMap="bisInspVillRgstrResultMap" parameterType="string">
- SELECT
- D.DATA_STAT ,
- D.ENG_ID ,
- D.OBJ_ID ,
- D.REGS_NM ,
- D.GROUP_LEADER ,
- D.GROUP_LEADER_TEL ,
- D.REC_PERS_ID ,
- D.REC_PERS ,
- D.REC_PERS_TEL ,
- DATE_FORMAT(D.INTM,'%Y-%m-%d %T') INTM,
- DATE_FORMAT(D.UPTM,'%Y-%m-%d %T') UPTM,
- D.NOTE
- FROM REL_PERS_INSPGROUP B
- LEFT JOIN BIS_INSP_OBJ C ON B.INSP_GROUP_ID=C.INSP_GROUP_ID
- RIGHT JOIN BIS_INSP_VILL_RGSTR D ON C.OBJ_ID=D.OBJ_ID
- WHERE B.PERS_ID=#{id}
- <if test="orgId != null and orgId != ''"> and B.ORG_ID = #{orgId}</if>
- </select>
- <!--村-->
- <select id="getRgstrByAdXCode" resultType="cn.com.goldenwater.dcproj.dto.VillRgstrEngIdDto">
- SELECT T1.* FROM
- (SELECT A.CODE,A.NM,A.OBJ_ID,B.ENG_ID FROM ATT_AD_X_BASE AD LEFT JOIN
- BIS_INSP_ALL_OBJ A ON CONCAT(SUBSTR(AD.AD_CODE,1,6),'000000') = A.CODE LEFT JOIN BIS_INSP_VILL_RGSTR B ON A.OBJ_ID = B.OBJ_ID
- WHERE A.PTYPE = '2' AND AD.AD_CODE = #{code}
- <if test="orgId != null and orgId != ''">and B.ORG_ID = #{orgId}</if>
- ORDER BY B.ENG_ID ASC) T1 limit 1
- </select>
- <!--农饮工程-->
- <select id="getRgstrByCwsCode" resultType="cn.com.goldenwater.dcproj.dto.VillRgstrEngIdDto">
- SELECT T1.* FROM
- (SELECT A.CODE,A.NM,A.OBJ_ID,B.ENG_ID FROM ATT_cws_BASE AD LEFT JOIN
- BIS_INSP_ALL_OBJ A ON CONCAT(SUBSTR(AD.ADDVCD,1,6),'000000') = A.CODE LEFT JOIN BIS_INSP_VILL_RGSTR B ON A.OBJ_ID = B.OBJ_ID
- WHERE A.PTYPE = '2'
- <if test="orgId != null and orgId != ''"> and A.ORG_ID = #{orgId}</if>
- AND AD.CWS_CODE = #{code} ORDER BY B.ENG_ID ASC) T1 limit 1
- </select>
- </mapper>
|