495 lines
16 KiB
XML
495 lines
16 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.population.dao.population.IPopulationDao">
|
|
|
|
<resultMap id="populationDTO" type="com.cm.population.pojo.dtos.population.PopulationDTO">
|
|
<result column="population_id" property="populationId"/>
|
|
<result column="house_id" property="houseId"/>
|
|
<result column="population_info_id" property="populationInfoId"/>
|
|
<result column="name" property="name"/>
|
|
<result column="card_num" property="cardNum"/>
|
|
<result column="bind_time" property="bindTime"/>
|
|
<result column="phone" property="phone"/>
|
|
<result column="out_house" property="outHouse"/>
|
|
<result column="creator" property="creator"/>
|
|
<result column="gmt_create" property="gmtCreate"/>
|
|
<result column="modifier" property="modifier"/>
|
|
<result column="gmt_modified" property="gmtModified"/>
|
|
<result column="is_delete" property="isDelete"/>
|
|
</resultMap>
|
|
|
|
<resultMap id="populationBO" type="com.cm.population.pojo.bos.population.PopulationBO">
|
|
<result column="population_id" property="populationId"/>
|
|
<result column="house_id" property="houseId"/>
|
|
<result column="population_info_id" property="populationInfoId"/>
|
|
<result column="name" property="name"/>
|
|
<result column="card_num" property="cardNum"/>
|
|
<result column="bind_time" property="bindTime"/>
|
|
<result column="phone" property="phone"/>
|
|
<result column="out_house" property="outHouse"/>
|
|
<result column="creator" property="creator"/>
|
|
<result column="gmt_create" property="gmtCreate"/>
|
|
<result column="modifier" property="modifier"/>
|
|
<result column="gmt_modified" property="gmtModified"/>
|
|
<result column="is_delete" property="isDelete"/>
|
|
</resultMap>
|
|
|
|
<resultMap id="populationPO" type="com.cm.population.pojo.pos.population.PopulationPO">
|
|
<result column="population_id" property="populationId"/>
|
|
<result column="house_id" property="houseId"/>
|
|
<result column="population_info_id" property="populationInfoId"/>
|
|
<result column="name" property="name"/>
|
|
<result column="card_num" property="cardNum"/>
|
|
<result column="bind_time" property="bindTime"/>
|
|
<result column="phone" property="phone"/>
|
|
<result column="out_house" property="outHouse"/>
|
|
<result column="creator" property="creator"/>
|
|
<result column="gmt_create" property="gmtCreate"/>
|
|
<result column="modifier" property="modifier"/>
|
|
<result column="gmt_modified" property="gmtModified"/>
|
|
<result column="is_delete" property="isDelete"/>
|
|
</resultMap>
|
|
|
|
<!-- 新增人房绑定 -->
|
|
<insert id="save" parameterType="map">
|
|
INSERT INTO house_population(
|
|
population_id,
|
|
house_id,
|
|
population_info_id,
|
|
name,
|
|
card_num,
|
|
phone,
|
|
bind_time,
|
|
out_house,
|
|
creator,
|
|
gmt_create,
|
|
modifier,
|
|
gmt_modified,
|
|
is_delete
|
|
) VALUES(
|
|
#{populationId},
|
|
#{houseId},
|
|
#{populationInfoId},
|
|
#{name},
|
|
#{cardNum},
|
|
#{phone},
|
|
#{bindTime},
|
|
#{outHouse},
|
|
#{creator},
|
|
#{gmtCreate},
|
|
#{modifier},
|
|
#{gmtModified},
|
|
#{isDelete}
|
|
)
|
|
</insert>
|
|
|
|
<!-- 删除人房绑定 -->
|
|
<update id="remove" parameterType="map">
|
|
UPDATE
|
|
house_population
|
|
SET
|
|
gmt_modified = #{gmtModified},
|
|
modifier = #{modifier},
|
|
is_delete = 1
|
|
WHERE
|
|
population_id IN
|
|
<foreach collection="populationIds" index="index" open="(" separator="," close=")">
|
|
#{populationIds[${index}]}
|
|
</foreach>
|
|
</update>
|
|
|
|
<!-- 删除人房绑定(物理) -->
|
|
<update id="delete" parameterType="map">
|
|
DELETE FROM
|
|
house_population
|
|
WHERE
|
|
population_id IN
|
|
<foreach collection="populationIds" index="index" open="(" separator="," close=")">
|
|
#{populationIds[${index}]}
|
|
</foreach>
|
|
</update>
|
|
|
|
<!-- 删除人房绑定(物理) -->
|
|
<update id="deleteByHouseId" parameterType="String">
|
|
DELETE FROM
|
|
house_population
|
|
WHERE
|
|
house_id = #{houseId} AND out_house != 1
|
|
</update>
|
|
|
|
<update id="updateOuthouseTrue" parameterType="map">
|
|
UPDATE
|
|
house_population
|
|
SET
|
|
out_house = '1',
|
|
gmt_modified = #{gmtModified},
|
|
modifier = #{modifier}
|
|
WHERE
|
|
is_delete = 0
|
|
<if test="populationIds != null and populationIds.size > 0">
|
|
AND
|
|
population_id IN
|
|
<foreach collection="populationIds" index="index" open="(" separator="," close=")">
|
|
#{populationIds[${index}]}
|
|
</foreach>
|
|
</if>
|
|
</update>
|
|
|
|
<update id="updateBindTime" parameterType="map">
|
|
UPDATE
|
|
house_population
|
|
SET
|
|
bind_time = #{bindTime}
|
|
WHERE
|
|
population_id = #{populationId}
|
|
</update>
|
|
|
|
<!-- 修改人房绑定 -->
|
|
<update id="update" parameterType="map">
|
|
UPDATE
|
|
house_population
|
|
SET
|
|
<if test="houseId != null and houseId != ''">
|
|
house_id = #{houseId},
|
|
</if>
|
|
<if test="populationInfoId != null and populationInfoId != ''">
|
|
population_info_id = #{populationInfoId},
|
|
</if>
|
|
<if test="name != null and name != ''">
|
|
name = #{name},
|
|
</if>
|
|
<if test="cardNum != null and cardNum != ''">
|
|
card_num = #{cardNum},
|
|
</if>
|
|
<if test="phone != null and phone != ''">
|
|
phone = #{phone},
|
|
</if>
|
|
<if test="bindTime != null and bindTime != ''">
|
|
bind_time = #{bindTime},
|
|
</if>
|
|
<if test="outHouse != null and outHouse != ''">
|
|
out_house = #{outHouse},
|
|
</if>
|
|
gmt_modified = #{gmtModified},
|
|
modifier = #{modifier},
|
|
population_id = population_id
|
|
WHERE
|
|
population_id = #{populationId}
|
|
</update>
|
|
|
|
<!-- 人房绑定详情 -->
|
|
<select id="get" parameterType="map" resultMap="populationDTO">
|
|
SELECT
|
|
t1.house_id,
|
|
t1.population_info_id,
|
|
t1.name,
|
|
t1.card_num,
|
|
t1.phone,
|
|
t1.bind_time,
|
|
t1.out_house,
|
|
t1.population_id
|
|
FROM
|
|
house_population t1
|
|
WHERE
|
|
t1.is_delete = 0
|
|
<if test="populationId != null and populationId != ''">
|
|
AND
|
|
t1.population_id = #{populationId}
|
|
</if>
|
|
</select>
|
|
|
|
<!-- 人房绑定详情 -->
|
|
<select id="getBO" parameterType="map" resultMap="populationBO">
|
|
SELECT
|
|
t1.population_id,
|
|
t1.house_id,
|
|
t1.population_info_id,
|
|
t1.name,
|
|
t1.card_num,
|
|
t1.phone,
|
|
t1.bind_time,
|
|
t1.out_house,
|
|
t1.creator,
|
|
t1.gmt_create,
|
|
t1.modifier,
|
|
t1.gmt_modified,
|
|
t1.is_delete
|
|
FROM
|
|
house_population t1
|
|
WHERE
|
|
t1.is_delete = 0
|
|
<if test="populationId != null and populationId != ''">
|
|
AND
|
|
t1.population_id = #{populationId}
|
|
</if>
|
|
</select>
|
|
|
|
<!-- 人房绑定详情 -->
|
|
<select id="getPO" parameterType="map" resultMap="populationPO">
|
|
SELECT
|
|
t1.population_id,
|
|
t1.house_id,
|
|
t1.population_info_id,
|
|
t1.name,
|
|
t1.card_num,
|
|
t1.phone,
|
|
t1.bind_time,
|
|
t1.out_house,
|
|
t1.creator,
|
|
t1.gmt_create,
|
|
t1.modifier,
|
|
t1.gmt_modified,
|
|
t1.is_delete
|
|
FROM
|
|
house_population t1
|
|
WHERE
|
|
t1.is_delete = 0
|
|
<if test="populationId != null and populationId != ''">
|
|
AND
|
|
t1.population_id = #{populationId}
|
|
</if>
|
|
</select>
|
|
|
|
<!-- 人房绑定列表 -->
|
|
<select id="listAll" parameterType="map" resultMap="populationDTO">
|
|
SELECT
|
|
t1.population_id,
|
|
t1.house_id,
|
|
t1.population_info_id,
|
|
t1.name,
|
|
t1.card_num,
|
|
t1.phone,
|
|
t1.bind_time,
|
|
t1.out_house,
|
|
t1.creator,
|
|
t1.gmt_create,
|
|
t1.modifier,
|
|
t1.gmt_modified,
|
|
t1.is_delete
|
|
FROM
|
|
house_population t1
|
|
WHERE
|
|
t1.is_delete = 0 AND t1.house_id = #{houseId}
|
|
<if test="outHouse != null and outHouse != ''">
|
|
AND t1.out_house = #{outHouse}
|
|
</if>
|
|
<if test="keywords != null and keywords != ''">
|
|
AND (t1.card_num LIKE CONCAT('%', #{keywords}, '%')
|
|
OR t1.phone LIKE CONCAT('%', #{keywords}, '%')
|
|
OR t1.name LIKE CONCAT('%', #{keywords}, '%')
|
|
)
|
|
</if>
|
|
ORDER BY t1.gmt_modified DESC, t1.gmt_create DESC
|
|
</select>
|
|
|
|
<!-- 人房绑定列表 -->
|
|
<select id="list" parameterType="map" resultMap="populationDTO">
|
|
SELECT
|
|
t1.population_id,
|
|
t1.house_id,
|
|
t1.population_info_id,
|
|
t1.name,
|
|
t1.card_num,
|
|
t1.phone,
|
|
t1.bind_time,
|
|
t1.out_house,
|
|
t1.creator,
|
|
t1.gmt_create,
|
|
t1.modifier,
|
|
t1.gmt_modified,
|
|
t1.is_delete
|
|
FROM
|
|
house_population t1
|
|
INNER JOIN
|
|
house_house hh
|
|
ON
|
|
t1.house_id = hh.house_id
|
|
WHERE
|
|
t1.is_delete = 0
|
|
AND (t1.out_house = 0
|
|
OR t1.out_house IS NULL)
|
|
AND
|
|
hh.is_delete = 0
|
|
<if test="keywords != null and keywords != ''">
|
|
AND (
|
|
t1.card_num LIKE CONCAT('%', #{keywords}, '%')
|
|
OR t1.phone LIKE CONCAT('%', #{keywords}, '%')
|
|
OR t1.name LIKE CONCAT('%', #{keywords}, '%')
|
|
OR t1.house_id LIKE CONCAT('%', #{keywords}, '%')
|
|
)
|
|
</if>
|
|
<if test="houseId != null and houseId != ''">
|
|
AND t1.house_id = #{houseId}
|
|
</if>
|
|
<if test="outHouse != null and outHouse != ''">
|
|
AND t1.out_house = #{outHouse}
|
|
</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="populationIds != null and populationIds.size > 0">
|
|
AND
|
|
t1.population_id IN
|
|
<foreach collection="populationIds" index="index" open="(" separator="," close=")">
|
|
#{populationIds[${index}]}
|
|
</foreach>
|
|
</if>
|
|
</select>
|
|
|
|
<!-- 人房绑定列表 -->
|
|
<select id="listBO" parameterType="map" resultMap="populationBO">
|
|
SELECT
|
|
t1.population_id,
|
|
t1.house_id,
|
|
t1.population_info_id,
|
|
t1.name,
|
|
t1.card_num,
|
|
t1.phone,
|
|
t1.bind_time,
|
|
t1.out_house,
|
|
t1.creator,
|
|
t1.gmt_create,
|
|
t1.modifier,
|
|
t1.gmt_modified,
|
|
t1.is_delete
|
|
FROM
|
|
house_population t1
|
|
WHERE
|
|
t1.is_delete = 0
|
|
<if test="keywords != null and keywords != ''">
|
|
AND (
|
|
t1.id LIKE CONCAT('%', #{keywords}, '%')
|
|
)
|
|
</if>
|
|
<if test="populationInfoId != null and populationInfoId != ''">
|
|
AND t1.population_info_id = #{populationInfoId}
|
|
</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="populationIds != null and populationIds.size > 0">
|
|
AND
|
|
t1.population_id IN
|
|
<foreach collection="populationIds" index="index" open="(" separator="," close=")">
|
|
#{populationIds[${index}]}
|
|
</foreach>
|
|
</if>
|
|
</select>
|
|
|
|
<!-- 人房绑定列表 -->
|
|
<select id="listPO" parameterType="map" resultMap="populationPO">
|
|
SELECT
|
|
t1.population_id,
|
|
t1.house_id,
|
|
t1.population_info_id,
|
|
t1.name,
|
|
t1.card_num,
|
|
t1.phone,
|
|
t1.bind_time,
|
|
t1.out_house,
|
|
t1.creator,
|
|
t1.gmt_create,
|
|
t1.modifier,
|
|
t1.gmt_modified,
|
|
t1.is_delete
|
|
FROM
|
|
house_population t1
|
|
WHERE
|
|
t1.is_delete = 0
|
|
<if test="keywords != null and keywords != ''">
|
|
AND (
|
|
<!-- 这里添加其他条件 -->
|
|
t1.id LIKE CONCAT('%', #{keywords}, '%')
|
|
)
|
|
</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="populationIds != null and populationIds.size > 0">
|
|
AND
|
|
t1.population_id IN
|
|
<foreach collection="populationIds" index="index" open="(" separator="," close=")">
|
|
#{populationIds[${index}]}
|
|
</foreach>
|
|
</if>
|
|
</select>
|
|
|
|
<!-- 人房绑定统计 -->
|
|
<select id="count" parameterType="map" resultType="Integer">
|
|
SELECT
|
|
COUNT(*)
|
|
FROM
|
|
house_population t1
|
|
WHERE
|
|
t1.is_delete = 0
|
|
AND (t1.out_house != 1 OR t1.out_house IS NOT NULL)
|
|
<if test="houseId != null and houseId != ''">
|
|
AND t1.house_id = #{houseId}
|
|
</if>
|
|
<if test="populationInfoId != null and populationInfoId != ''">
|
|
AND t1.population_info_id = #{populationInfoId}
|
|
</if>
|
|
</select>
|
|
|
|
<select id="listBatch" parameterType="map" resultMap="populationDTO">
|
|
SELECT
|
|
t1.population_id,
|
|
t1.house_id,
|
|
t1.population_info_id,
|
|
t1.name,
|
|
t1.card_num,
|
|
t1.phone,
|
|
t1.bind_time,
|
|
t1.out_house,
|
|
t1.creator,
|
|
t1.gmt_create,
|
|
t1.modifier,
|
|
t1.gmt_modified,
|
|
t1.is_delete
|
|
FROM
|
|
house_population t1
|
|
LEFT JOIN house_house t2 ON t1.house_id = t2.house_id
|
|
WHERE
|
|
t1.is_delete = 0
|
|
AND t2.is_delete = 0
|
|
AND (t1.out_house = 0
|
|
OR t1.out_house IS NULL)
|
|
<if test="keywords != null and keywords != ''">
|
|
AND (
|
|
t1.card_num LIKE CONCAT('%', #{keywords}, '%')
|
|
OR t1.phone LIKE CONCAT('%', #{keywords}, '%')
|
|
OR t1.name LIKE CONCAT('%', #{keywords}, '%')
|
|
OR t1.house_id LIKE CONCAT('%', #{keywords}, '%')
|
|
)
|
|
</if>
|
|
<if test="houseId != null and houseId != ''">
|
|
AND t1.house_id = #{houseId}
|
|
</if>
|
|
<if test="outHouse != null and outHouse != ''">
|
|
AND t1.out_house = #{outHouse}
|
|
</if>
|
|
<if test="populationIds != null and populationIds.size > 0">
|
|
AND
|
|
t1.population_id IN
|
|
<foreach collection="populationIds" index="index" open="(" separator="," close=")">
|
|
#{populationIds[${index}]}
|
|
</foreach>
|
|
</if>
|
|
</select>
|
|
|
|
</mapper> |