123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442 |
- <?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="com.bz.smart_city.dao.CommunityMapper">
- <!--auto generated Code-->
- <resultMap id="BaseResultMap" type="com.bz.smart_city.entity.Community">
- <result column="id" property="id" jdbcType="INTEGER"/>
- <result column="site_id" property="siteId" jdbcType="INTEGER"/>
- <result column="name" property="name" jdbcType="VARCHAR"/>
- <result column="code" property="code" jdbcType="VARCHAR"/>
- <result column="customer_id" property="customerId" jdbcType="INTEGER"/>
- <result column="province" property="province" jdbcType="INTEGER"/>
- <result column="city" property="city" jdbcType="INTEGER"/>
- <result column="region" property="region" jdbcType="INTEGER"/>
- <result column="longitude" property="longitude" jdbcType="VARCHAR"/>
- <result column="latitude" property="latitude" jdbcType="VARCHAR"/>
- <result column="district_id" property="districtId" jdbcType="INTEGER"/>
- <result column="address" property="address" jdbcType="VARCHAR"/>
- <result column="remark" property="remark" jdbcType="VARCHAR"/>
- <result column="status" property="status" jdbcType="INTEGER"/>
- <result column="date_create" property="dateCreate" jdbcType="TIMESTAMP"/>
- <result column="date_update" property="dateUpdate" jdbcType="TIMESTAMP"/>
- <result column="create_by" property="createBy" jdbcType="VARCHAR"/>
- <result column="update_by" property="updateBy" jdbcType="VARCHAR"/>
- </resultMap>
- <!--auto generated Code-->
- <sql id="Base_Column_List">
- id,
- site_id,
- code,
- `name`,
- customer_id,
- province,
- city,
- region,
- longitude,
- latitude,
- district_id,
- address,
- remark,
- `status`,
- date_create,
- date_update,
- create_by,
- update_by
- </sql>
- <sql id="General_Column_List">
- sc.id,
- sc.site_id,
- sc.`name`,
- sc.code,
- sc.customer_id,
- sc.province,
- sc.city,
- sc.region,
- sc.longitude,
- sc.latitude,
- sc.district_id,
- sc.address,
- sc.remark,
- sc.`status`,
- sc.date_create,
- sc.date_update,
- sc.create_by,
- sc.update_by
- </sql>
- <!--auto generated Code-->
- <insert id="insert" useGeneratedKeys="true" keyProperty="community.id">
- INSERT INTO sc_community (
- id,
- site_id,
- `name`,
- code,
- customer_id,
- org_id,
- province,
- city,
- region,
- longitude,
- latitude,
- district_id,
- address,
- remark,
- `status`,
- date_create,
- date_update,
- create_by,
- update_by
- ) VALUES (
- #{community.id,jdbcType=INTEGER},
- #{community.siteId,jdbcType=INTEGER},
- #{community.name,jdbcType=VARCHAR},
- #{community.code,jdbcType=VARCHAR},
- #{community.customerId,jdbcType=INTEGER},
- #{community.orgId,jdbcType=INTEGER},
- #{community.province,jdbcType=INTEGER},
- #{community.city,jdbcType=INTEGER},
- #{community.region,jdbcType=INTEGER},
- #{community.longitude,jdbcType=VARCHAR},
- #{community.latitude,jdbcType=VARCHAR},
- #{community.districtId,jdbcType=INTEGER},
- #{community.address,jdbcType=VARCHAR},
- #{community.remark,jdbcType=VARCHAR},
- #{community.status,jdbcType=INTEGER},
- #{community.dateCreate,jdbcType=TIMESTAMP},
- #{community.dateUpdate,jdbcType=TIMESTAMP},
- #{community.createBy,jdbcType=VARCHAR},
- #{community.updateBy,jdbcType=VARCHAR}
- )
- </insert>
- <!--auto generated Code-->
- <insert id="insertSelective" useGeneratedKeys="true" keyProperty="community.id">
- INSERT INTO sc_community
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="community.id!=null"> id,</if>
- <if test="community.siteId!=null"> site_id,</if>
- <if test="community.name!=null"> `name`,</if>
- <if test="community.code!=null"> code,</if>
- <if test="community.customerId!=null"> customer_id,</if>
- <if test="community.province!=null"> province,</if>
- <if test="community.city!=null"> city,</if>
- <if test="community.region!=null"> region,</if>
- <if test="community.longitude!=null"> longitude,</if>
- <if test="community.latitude!=null"> latitude,</if>
- <if test="community.districtId!=null"> district_id,</if>
- <if test="community.address!=null"> address,</if>
- <if test="community.remark!=null"> remark,</if>
- <if test="community.status!=null"> `status`,</if>
- <if test="community.dateCreate!=null"> date_create,</if>
- <if test="community.dateUpdate!=null"> date_update,</if>
- <if test="community.createBy!=null"> create_by,</if>
- <if test="community.updateBy!=null"> update_by,</if>
- </trim>
- VALUES
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="community.id!=null">#{community.id,jdbcType=INTEGER},
- </if>
- <if test="community.siteId!=null">#{community.siteId,jdbcType=INTEGER},
- </if>
- <if test="community.name!=null">#{community.name,jdbcType=VARCHAR},
- </if>
- <if test="community.code!=null">#{community.code,jdbcType=VARCHAR},
- </if>
- <if test="community.customerId!=null">#{community.customerId,jdbcType=INTEGER},
- </if>
- <if test="community.province!=null">#{community.province,jdbcType=INTEGER},
- </if>
- <if test="community.city!=null">#{community.city,jdbcType=INTEGER},
- </if>
- <if test="community.region!=null">#{community.region,jdbcType=INTEGER},
- </if>
- <if test="community.longitude!=null"> #{community.longitude,jdbcType=VARCHAR},</if>
- <if test="community.latitude!=null"> #{community.latitude,jdbcType=VARCHAR},</if>
- <if test="community.districtId!=null">#{community.districtId,jdbcType=INTEGER},
- </if>
- <if test="community.address!=null">#{community.address,jdbcType=VARCHAR},
- </if>
- <if test="community.remark!=null">#{community.remark,jdbcType=VARCHAR},
- </if>
- <if test="community.status!=null">#{community.status,jdbcType=INTEGER},
- </if>
- <if test="community.dateCreate!=null">#{community.dateCreate,jdbcType=TIMESTAMP},
- </if>
- <if test="community.dateUpdate!=null">#{community.dateUpdate,jdbcType=TIMESTAMP},
- </if>
- <if test="community.createBy!=null">#{community.createBy,jdbcType=VARCHAR},
- </if>
- <if test="community.updateBy!=null">#{community.updateBy,jdbcType=VARCHAR},
- </if>
- </trim>
- </insert>
- <!--auto generated Code-->
- <insert id="insertList">
- INSERT INTO sc_community (
- id,
- site_id,
- `name`,
- code,
- customer_id,
- province,
- city,
- region,
- longitude,
- latitude,
- district_id,
- address,
- remark,
- `status`,
- date_create,
- date_update,
- create_by,
- update_by
- )VALUES
- <foreach collection="communitys" item="community" index="index" separator=",">
- (
- #{community.id,jdbcType=INTEGER},
- #{community.siteId,jdbcType=INTEGER},
- #{community.name,jdbcType=VARCHAR},
- #{community.code,jdbcType=VARCHAR},
- #{community.customerId,jdbcType=INTEGER},
- #{community.province,jdbcType=INTEGER},
- #{community.city,jdbcType=INTEGER},
- #{community.region,jdbcType=INTEGER},
- #{community.longitude,jdbcType=VARCHAR},
- #{community.latitude,jdbcType=VARCHAR},
- #{community.districtId,jdbcType=INTEGER},
- #{community.address,jdbcType=VARCHAR},
- #{community.remark,jdbcType=VARCHAR},
- #{community.status,jdbcType=INTEGER},
- #{community.dateCreate,jdbcType=TIMESTAMP},
- #{community.dateUpdate,jdbcType=TIMESTAMP},
- #{community.createBy,jdbcType=VARCHAR},
- #{community.updateBy,jdbcType=VARCHAR}
- )
- </foreach>
- </insert>
- <!--auto generated Code-->
- <update id="updateByPrimaryKeySelective">
- UPDATE sc_community
- <set>
- <if test="community.siteId != null"> site_id= #{community.siteId,jdbcType=INTEGER},</if>
- <if test="community.name != null"> `name`= #{community.name,jdbcType=VARCHAR},</if>
- <if test="community.customerId != null"> customer_id= #{community.customerId,jdbcType=INTEGER},</if>
- <if test="community.orgId != null"> org_id= #{community.orgId,jdbcType=INTEGER},</if>
- <if test="community.province != null"> province= #{community.province,jdbcType=INTEGER},</if>
- <if test="community.city != null"> city= #{community.city,jdbcType=INTEGER},</if>
- <if test="community.region != null"> region= #{community.region,jdbcType=INTEGER},</if>
- <if test="community.longitude != null"> longitude = #{community.longitude,jdbcType=VARCHAR},</if>
- <if test="community.latitude != null"> latitude = #{community.latitude,jdbcType=VARCHAR},</if>
- <if test="community.districtId != null"> district_id= #{community.districtId,jdbcType=INTEGER},</if>
- <if test="community.address != null"> address= #{community.address,jdbcType=VARCHAR},</if>
- <if test="community.remark != null"> remark= #{community.remark,jdbcType=VARCHAR},</if>
- <if test="community.status != null"> `status`= #{community.status,jdbcType=INTEGER},</if>
- <if test="community.dateCreate != null"> date_create= #{community.dateCreate,jdbcType=TIMESTAMP},</if>
- <if test="community.dateUpdate != null"> date_update= #{community.dateUpdate,jdbcType=TIMESTAMP},</if>
- <if test="community.createBy != null"> create_by= #{community.createBy,jdbcType=VARCHAR},</if>
- <if test="community.updateBy != null"> update_by= #{community.updateBy,jdbcType=VARCHAR}</if>
- </set>
- WHERE id = #{community.id,jdbcType=INTEGER}
- </update>
- <select id="findBySiteId" resultType="com.bz.smart_city.dto.CommunityDto">
- select
- sc.*,
- sa1.name as province_name,
- sa2.name as city_name,
- sa3.name as region_name
- from sc_community sc
- left join sc_area sa1 on sc.province =sa1.id
- left join sc_area sa2 on sc.city=sa2.id
- left join sc_area sa3 on sc.region=sa3.id
- where sc.status = 1
- <if test="siteId != null"> and sc.site_id = #{siteId} </if>
- <if test="customerIds != null and customerIds.size() != 0">
- and customer_id in <foreach collection="customerIds" item="item" open="(" separator="," close=")">#{item}</foreach>
- </if>
- </select>
- <select id="findByCustomerId" resultType="com.bz.smart_city.dto.CommunityDto">
- select
- sc.*,
- sa1.name as province_name,
- sa2.name as city_name,
- sa3.name as region_name
- from sc_community sc
- left join sc_area sa1 on sc.province =sa1.id
- left join sc_area sa2 on sc.city=sa2.id
- left join sc_area sa3 on sc.region=sa3.id
- where sc.status = 1
- <if test="customerId != null"> and sc.customer_id = #{customerId} </if>
- </select>
- <select id="findByIds" resultMap="BaseResultMap">
- select id,name,province,city,region from sc_community where status = 1
- and id in <foreach collection="ids" item="item" open="(" separator="," close=")">#{item}</foreach>
- order by name asc
- </select>
-
- <select id="queryList" resultType="com.bz.smart_city.dto.CommunityDto">
- select
- sc.id as id,
- sc.name as name ,
- sc.code as code,
- sc.province as province,
- sc.city as city,
- sc.region as region,
- sc.longitude as longitude,
- sc.latitude as latitude,
- sc.address as address,
- sa1.name as province_name,
- sa2.name as city_name,
- sa3.name as region_name
- from sc_community sc
- left join sc_area sa1 on sc.province =sa1.id
- left join sc_area sa2 on sc.city=sa2.id
- left join sc_area sa3 on sc.region=sa3.id
- where sc.status = 1
- <if test="param.siteId "> and sc.site_id = #{param.siteId} </if>
- <if test="param.customerId != null and param.customerId != 0 "> and sc.customer_id = #{param.customerId} </if>
- <if test="param.province != null"> and sc.province = #{param.province} </if>
- <if test="param.city != null"> and sc.city = #{param.city} </if>
- <if test="param.region != null"> and sc.region = #{param.region} </if>
- <if test="param.id != null"> and sc.id = #{param.id}</if>
- <if test="param.name != null and param.name != '' "> and sc.name like #{param.name}</if>
- </select>
- <select id="queryCommunity" resultType="com.bz.smart_city.dto.CommunityDto">
- select
- sc.id as id,
- sc.name as name ,
- sc.code as code,
- sc.province as province,
- sc.city as city,
- sc.region as region,
- sc.longitude as longitude,
- sc.latitude as latitude,
- sc.address as address,
- sa1.name as province_name,
- sa2.name as city_name,
- sa3.name as region_name
- from sc_community sc
- left join sc_area sa1 on sc.province =sa1.id
- left join sc_area sa2 on sc.city=sa2.id
- left join sc_area sa3 on sc.region=sa3.id
- where sc.status = 1
- <if test="param.siteId != null"> and sc.site_id = #{param.siteId} </if>
- <if test="param.customerId != null and param.customerId != 0 "> and sc.customer_id = #{param.customerId} </if>
- <if test="param.province != null"> and sc.province = #{param.province} </if>
- <if test="param.city != null"> and sc.city = #{param.city} </if>
- <if test="param.region != null"> and sc.region = #{param.region} </if>
- <if test="param.id != null"> and sc.id = #{param.id}</if>
- <if test="param.name != null and param.name != '' "> and sc.name like #{param.name}</if>
- <if test="customerIds != null and customerIds.size() != 0">
- and sc.customer_id in <foreach collection="customerIds" item="item" open="(" separator="," close=")">#{item}</foreach>
- </if>
- </select>
- <select id="getList" resultType="com.bz.smart_city.dto.CommunityDto">
- select
- sc.*,
- sa1.name as province_name,
- sa2.name as city_name,
- sa3.name as region_name,
- so.name as org_name
- from sc_community sc
- left join sc_area sa1 on sa1.id = sc.province
- left join sc_area sa2 on sa2.id = sc.city
- left join sc_area sa3 on sa3.id = sc.region
- left join sc_organization so on so.id=sc.org_id
- where sc.status = 1
- <if test="siteId != null"> and sc.site_id = #{siteId} </if>
- <if test="customerId != null"> and sc.customer_id = #{customerId} </if>
- <if test="communityName != null and communityName != ''"> and sc.name like concat('%',#{communityName} ,'%')</if>
- <if test="province != null"> and sc.province = #{province}</if>
- <if test="city != null"> and sc.city = #{city}</if>
- <if test="region != null"> and sc.region = #{region}</if>
- order by sc.date_create desc
- </select>
- <select id="findByNameUnique" resultType="java.lang.Integer">
- select count(1) from sc_community where status = 1 and province = #{province} and city = #{city} and region = #{region} and name = #{name}
- <if test="siteId != null"> and site_id = #{siteId} </if>
- <if test="id != null"> and id != #{id}</if>
- </select>
- <select id="findByName" resultMap="BaseResultMap">
- SELECT <include refid="Base_Column_List"></include> from sc_community where status = 1 and site_id = #{siteId} and name = #{communityName}
- </select>
- <select id="findByNameV2" resultMap="BaseResultMap">
- SELECT <include refid="Base_Column_List"></include> from sc_community where status = 1 and site_id = #{siteId}
- and province = #{province} and city = #{city} and region = #{region} and name = #{communityName}
- </select>
- <select id="findById" resultMap="BaseResultMap">
- select
- <include refid="Base_Column_List"/>
- from sc_community
- where status = 1 and id=#{id}
- </select>
- <select id="getBySiteId" resultMap="BaseResultMap">
- select <include refid="Base_Column_List"></include> from sc_community where status = 1 and site_id = #{siteId}
- </select>
- <select id="findCommunityContainBuilding" resultType="com.bz.smart_city.dto.CommunityDto">
- select
- <include refid="Base_Column_List" />
- from sc_community
- where status = 1
- and site_id = #{siteId}
- and id in (select distinct b.community from sc_building b where b.site_id = #{siteId})
- <if test="name != null and name !='' ">
- and name like concat('%',#{name} ,'%')
- </if>
- </select>
- <select id="getMaxCodeBySiteId" resultMap="BaseResultMap">
- select MAX(ifnull(code,0))+1 code
- from sc_community
- where status = 1 and site_id = #{siteId}
- </select>
- <select id="getListByCustomerIds" resultType="com.bz.smart_city.dto.CommunityDto">
- select
- sc.*,
- sa1.name as province_name,
- sa2.name as city_name,
- sa3.name as region_name,
- sc.name as org_name
- from sc_community sc
- left join sc_area sa1 on sa1.id = sc.province
- left join sc_area sa2 on sa2.id = sc.city
- left join sc_area sa3 on sa3.id = sc.region
- left join sc_organization so on so.id = sc.org_id
- where sc.status = 1
- <if test="siteId != null"> and sc.site_id = #{siteId} </if>
- <if test="customerIds != null">
- and sc.customer_id in <foreach collection="customerIds" item="item" open="(" separator="," close=")">#{item}</foreach>
- </if>
- <if test="communityName != null and communityName != ''"> and sc.name like concat('%',#{communityName} ,'%')</if>
- <if test="province != null"> and sc.province = #{province}</if>
- <if test="city != null"> and sc.city = #{city}</if>
- <if test="region != null"> and sc.region = #{region}</if>
- order by sc.date_create desc
- </select>
- <select id="findCommunityByArea" parameterType="com.bz.smart_city.dto.syncdata.AreaRequstData" resultType="com.bz.smart_city.dto.syncdata.AreaResponseData">
- select a.address,b.manger_name,a.`name`, a.city,a.customer_id,a.latitude,
- a.longitude,a.province,a.region,a.remark,b.`name` regionName
- from sc_community a join sc_area b on a.region=b.id
- <where>
- <if test="name != null"> and a.name = #{name} </if>
- <if test="province != null"> and a.province = #{province} </if>
- <if test="city != null"> and a.city = #{city} </if>
- <if test="region != null"> and a.region = #{region} </if>
- <if test="communityId != null"> and a.id = #{communityId} </if>
- </where>
- limit 1
- </select>
- </mapper>
|