155 lines
No EOL
5.9 KiB
XML
155 lines
No EOL
5.9 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="ru.nbch.credit_tracker.mapper.signal.PhonesMapMapper">
|
|
|
|
<resultMap id="PhoneMap" type="ru.nbch.credit_tracker.entities.app.PhonesMap">
|
|
<result property="fid" column="fid"/>
|
|
<result property="phone" column="phone"/>
|
|
<result property="name1" column="name_1"/>
|
|
<result property="first" column="first"/>
|
|
<result property="middle" column="middle"/>
|
|
<result property="birthDt" column="birth_dt"/>
|
|
<result property="serNum" column="ser_num"/>
|
|
<result property="idType" column="id_type"/>
|
|
<result property="flagDebt5000" column="flag_debt5000"/>
|
|
<result property="flag90days" column="flag_90_12"/>
|
|
<result property="searchedAt" column="searched_at"/>
|
|
<result property="calculatedAt" column="calculated_at"/>
|
|
</resultMap>
|
|
|
|
<select id="findByPhone" resultMap="PhoneMap">
|
|
select fid,
|
|
phone,
|
|
name_1,
|
|
first,
|
|
middle,
|
|
birth_dt,
|
|
ser_num,
|
|
id_type,
|
|
flag_debt5000,
|
|
flag_90_12,
|
|
searched_at,
|
|
calculated_at
|
|
FROM signals_phones_map
|
|
WHERE phone = #{phone}
|
|
</select>
|
|
|
|
<select id="getCachedData" resultMap="PhoneMap" resultType="java.util.List">
|
|
SELECT fid,
|
|
phone,
|
|
name_1,
|
|
first,
|
|
middle,
|
|
birth_dt,
|
|
ser_num,
|
|
id_type,
|
|
flag_debt5000,
|
|
flag_90_12,
|
|
searched_at,
|
|
calculated_at
|
|
FROM signals_phones_map
|
|
WHERE phone in
|
|
<foreach item="phone" collection="phones" open="(" separator="," close=")">
|
|
#{phone}
|
|
</foreach>
|
|
</select>
|
|
|
|
<select id="registerJson" parameterType="string">
|
|
WITH src AS (SELECT row_number() OVER () AS rn,
|
|
fid,
|
|
phone,
|
|
name_1,
|
|
first,
|
|
middle,
|
|
birth_dt
|
|
FROM json_to_recordset(#{json}::json) AS t(
|
|
fid int,
|
|
phone bigint,
|
|
name_1 varchar(2000),
|
|
first varchar(2000),
|
|
middle varchar(2000),
|
|
birth_dt timestamp
|
|
))
|
|
INSERT
|
|
INTO signals_phones_map
|
|
(fid, phone, name_1, first, middle, birth_dt)
|
|
SELECT fid,
|
|
phone,
|
|
name_1,
|
|
first,
|
|
middle,
|
|
birth_dt
|
|
FROM src
|
|
ON CONFLICT (phone) DO UPDATE
|
|
SET fid = EXCLUDED.fid,
|
|
phone = EXCLUDED.phone,
|
|
name_1 = EXCLUDED.name_1,
|
|
first = EXCLUDED.first,
|
|
middle = EXCLUDED.middle,
|
|
birth_dt = EXCLUDED.birth_dt
|
|
</select>
|
|
|
|
<update id="updateIdCachedData" parameterType="string">
|
|
update signals_phones_map dst
|
|
set ser_num = src.ser_num,
|
|
id_type = src.id_type
|
|
FROM json_to_recordset(#{json}::json) AS src(
|
|
phone bigint,
|
|
ser_num varchar(255),
|
|
id_type varchar(255)
|
|
)
|
|
where dst.phone = src.phone;
|
|
</update>
|
|
|
|
<update id="updateFlagCachedData" parameterType="string">
|
|
update signals_phones_map dst
|
|
set flag_debt5000 = src.flag_debt5000,
|
|
flag_90_12 = src.flag_90_12
|
|
FROM json_to_recordset(#{json}::json) AS src(
|
|
phone bigint,
|
|
flag_debt5000 smallint,
|
|
flag_90_12 smallint
|
|
)
|
|
where dst.phone = src.phone;
|
|
</update>
|
|
|
|
<update id="setFidJson" parameterType="string">
|
|
update signals_phones_map dst
|
|
set fid = src.fid,
|
|
searched_at = now()
|
|
FROM json_to_recordset(#{json}::json) AS src(
|
|
id bigint,
|
|
fid int
|
|
)
|
|
where dst.id = src.id;
|
|
</update>
|
|
|
|
|
|
<!-- <select id="pageByPackageIdAndOlderThanN" resultMap="PhoneFidMapResultMap" resultType="java.util.List">-->
|
|
<!-- SELECT id,-->
|
|
<!-- package_id,-->
|
|
<!-- subject_id,-->
|
|
<!-- phone,-->
|
|
<!-- error_text-->
|
|
<!-- FROM signals_phone_fid_map-->
|
|
<!-- WHERE package_id = #{packageId} and searched_at < now() - make_interval(days => #{daysCount})-->
|
|
<!-- ORDER BY id-->
|
|
<!-- LIMIT #{limit} OFFSET #{offset}-->
|
|
<!-- </select>-->
|
|
|
|
<!-- <select id="pageByPackageIdAndNewerThanN" resultMap="PhoneFidMapResultMap" resultType="java.util.List">-->
|
|
<!-- SELECT id,-->
|
|
<!-- package_id,-->
|
|
<!-- subject_id,-->
|
|
<!-- phone,-->
|
|
<!-- fid,-->
|
|
<!-- error_text-->
|
|
<!-- FROM signals_phone_fid_map-->
|
|
<!-- WHERE package_id = #{packageId} and searched_at >= now() - make_interval(days => #{daysCount})-->
|
|
<!-- ORDER BY id-->
|
|
<!-- LIMIT #{limit} OFFSET #{offset}-->
|
|
<!-- </select>-->
|
|
</mapper> |