btxtgxq-system-city/src/main/resources/mybatis/mapper/buildinghouse/building-house-mapper.xml
2021-07-13 17:46:12 +08:00

289 lines
9.6 KiB
XML

<?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.cm.systemcity.dao.buildinghouse.IBuildingHouseDao">
<resultMap id="buildingHouseDTO" type="com.cm.systemcity.pojo.dtos.buildinghouse.BuildingHouseDTO">
<result column="building_house_id" property="buildingHouseId"/>
<result column="city_building_id" property="cityBuildingId"/>
<result column="city_building_name" property="cityBuildingName"/>
<result column="house_number" property="houseNumber"/>
<result column="district_name" property="districtName"/>
<result column="district_id" property="districtId"/>
<result column="house_status" property="houseStatus"/>
<result column="data_type" property="dataType"/>
<result column="owner_name" property="ownerName"/>
<result column="owner_card" property="ownerCard"/>
<result column="owner_phone" property="ownerPhone"/>
<result column="longitude" property="longitude"/>
<result column="latitude" property="latitude"/>
</resultMap>
<!-- 新增房屋管理表 -->
<insert id="save" parameterType="map">
INSERT INTO city_building_house(
building_house_id,
city_building_id,
city_building_name,
house_number,
district_name,
district_id,
house_status,
data_type,
owner_name,
owner_card,
owner_phone,
longitude,
latitude,
creator,
gmt_create,
modifier,
gmt_modified,
is_delete
) VALUES(
#{buildingHouseId},
#{cityBuildingId},
#{cityBuildingName},
#{houseNumber},
#{districtName},
#{districtId},
#{houseStatus},
#{dataType},
#{ownerName},
#{ownerCard},
#{ownerPhone},
#{longitude},
#{latitude},
#{creator},
#{gmtCreate},
#{modifier},
#{gmtModified},
#{isDelete}
)
</insert>
<!-- 删除房屋管理表 -->
<update id="remove" parameterType="map">
UPDATE
city_building_house
SET
gmt_modified = #{gmtModified},
modifier = #{modifier},
is_delete = 1
WHERE
1 = 1
<if test="cityBuildingId != null and cityBuildingId != ''">
AND city_building_id = #{cityBuildingId}
</if>
<if test="houseNumber != null and houseNumber != ''">
AND house_number = #{houseNumber}
</if>
<if test="buildingHouseIds != null and buildingHouseIds.size > 0">
AND
building_house_id IN
<foreach collection="buildingHouseIds" index="index" open="(" separator="," close=")">
#{buildingHouseIds[${index}]}
</foreach>
</if>
</update>
<!-- 删除房屋管理表(物理) -->
<update id="delete" parameterType="map">
DELETE FROM
city_building_house
WHERE
building_house_id IN
<foreach collection="buildingHouseIds" index="index" open="(" separator="," close=")">
#{buildingHouseIds[${index}]}
</foreach>
</update>
<!-- 修改房屋管理表 -->
<update id="update" parameterType="map">
UPDATE
city_building_house
SET
<if test="cityBuildingName != null and cityBuildingName != ''">
city_building_name = #{cityBuildingName},
</if>
<if test="houseNumber != null and houseNumber != ''">
house_number = #{houseNumber},
</if>
<if test="districtName != null and districtName != ''">
district_name = #{districtName},
</if>
<if test="districtId != null and districtId != ''">
district_id = #{districtId},
</if>
<if test="houseStatus != null and houseStatus != ''">
house_status = #{houseStatus},
</if>
<if test="dataType != null">
data_type = #{dataType},
</if>
<if test="ownerName != null and ownerName != ''">
owner_name = #{ownerName},
</if>
<if test="ownerCard != null and ownerCard != ''">
owner_card = #{ownerCard},
</if>
<if test="ownerPhone != null and ownerPhone != ''">
owner_phone = #{ownerPhone},
</if>
<if test="longitude != null and longitude != ''">
longitude = #{longitude},
</if>
<if test="latitude != null and latitude != ''">
latitude = #{latitude},
</if>
<if test="newHouseNumber != null and newHouseNumber != ''">
<if test="oldHouseNumber != null and oldHouseNumber != ''">
house_number = replace(house_number, #{oldHouseNumber}, #{newHouseNumber}),
</if>
</if>
gmt_modified = #{gmtModified},
modifier = #{modifier},
building_house_id = building_house_id
WHERE
1 = 1
<if test="buildingHouseId != null and buildingHouseId != ''">
AND building_house_id = #{buildingHouseId}
</if>
<if test="cityBuildingId != null and cityBuildingId != ''">
AND city_building_id = #{cityBuildingId}
</if>
</update>
<!-- 房屋管理表详情 -->
<select id="get" parameterType="map" resultMap="buildingHouseDTO">
SELECT
t1.city_building_id,
t1.city_building_name,
t1.house_number,
t1.district_name,
t1.district_id,
t1.house_status,
t1.data_type,
t1.owner_name,
t1.owner_card,
t1.owner_phone,
t1.longitude,
t1.latitude,
t1.building_house_id
FROM
city_building_house t1
WHERE
t1.is_delete = 0
<if test="buildingHouseId != null and buildingHouseId != ''">
AND
t1.building_house_id = #{buildingHouseId}
</if>
</select>
<!-- 房屋管理表列表 -->
<select id="list" parameterType="map" resultMap="buildingHouseDTO">
SELECT
t1.building_house_id,
t1.city_building_id,
t1.city_building_name,
t1.house_number,
t1.district_name,
t1.district_id,
t1.house_status,
t1.data_type,
t1.owner_name,
t1.owner_card,
t1.owner_phone,
t1.longitude,
t1.latitude,
1
FROM
city_building_house t1
WHERE
t1.is_delete = 0
<if test="keywords != null and keywords != ''">
AND (
t1.city_building_name LIKE CONCAT('%', #{keywords}, '%')
OR
t1.district_name LIKE CONCAT('%', #{keywords}, '%')
OR
t1.owner_name LIKE CONCAT('%', #{keywords}, '%')
OR
t1.owner_card LIKE CONCAT('%', #{keywords}, '%')
)
</if>
<if test="cityBuildingId != null and cityBuildingId != ''">
AND t1.city_building_id = #{cityBuildingId}
</if>
<if test="startTime != null and startTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
</if>
<if test="buildingHouseIds != null and buildingHouseIds.size > 0">
AND
t1.building_house_id IN
<foreach collection="buildingHouseIds" index="index" open="(" separator="," close=")">
#{buildingHouseIds[${index}]}
</foreach>
</if>
</select>
<!-- 房屋管理表统计 -->
<select id="count" parameterType="map" resultType="Integer">
SELECT
COUNT(*)
FROM
city_building_house t1
WHERE
t1.is_delete = 0
</select>
<update id="deleteNoData" parameterType="map">
DELETE
FROM
city_building_house
WHERE
id IN (
SELECT
id
FROM
(
SELECT
max(id) AS id,
count(house_number) AS ucount
FROM
city_building_house
WHERE
city_building_id = #{cityBuildingId}
GROUP BY
house_number
HAVING
ucount > 1
ORDER BY
ucount DESC
) AS tab
)
</update>
<update id="removeData" parameterType="map">
UPDATE
city_building_house
SET
gmt_modified = #{gmtModified},
modifier = #{modifier},
is_delete = 1
WHERE
1 = 1
<if test="cityBuildingIds != null and cityBuildingIds.size > 0">
AND
city_building_id IN
<foreach collection="cityBuildingIds" index="index" open="(" separator="," close=")">
#{cityBuildingIds[${index}]}
</foreach>
</if>
</update>
</mapper>