search_tools_service/search-tool/src/main/resources/mapper/SouthMapper.xml

171 lines
4.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="com.bonus.tool.mapper.SouthMapper">
<insert id="addSouthTemp" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
insert into tb_south_mdel(name,
create_user)
values (#{name},
#{createUser})
</insert>
<insert id="insertComCore">
insert into tb_south_company_user(
south_id,
key_id,
position,
pro_perf
)values
<foreach collection="list" item="item" separator=",">
(
#{item.parentId},
#{item.id},
#{item.postName},
#{item.proPerf}
)
</foreach>
</insert>
<insert id="insertComOther">
insert into tb_south_other_user(
south_id,
other_id,
position
)values
<foreach collection="list" item="item" separator=",">
(
#{item.parentId},
#{item.id},
#{item.postName}
)
</foreach>
</insert>
<insert id="insertSubPerson">
insert into tb_south_sub_user(
south_id,
user_id,
position
)values
<foreach collection="list" item="item" separator=",">
(
#{item.parentId},
#{item.id},
#{item.postName}
)
</foreach>
</insert>
<update id="updateSouthTemp">
update tb_south_mdel
set
name = #{name},
update_user = #{updateUser}
where id = #{id}
</update>
<delete id="delSouthTemp">
update tb_south_mdel
set del_flag = 1
where id = #{id}
</delete>
<delete id="delAssociatedData">
delete
from tb_south_company_user
where south_id = #{id};
delete
from tb_south_other_user
where south_id = #{id};
delete
from tb_south_sub_user
where south_id = #{id};
</delete>
<select id="getSouthList" resultType="com.bonus.tool.dto.TbGwModelVo">
select
id,
name,
create_user as createUser,
create_time,
update_time
from
tb_south_mdel where del_flag =0
<if test="name != '' and name != null">
and name = #{name}
</if>
<if test="startDate != null and startDate != null and endDate != null and endDate != null">
and STR_TO_DATE(create_time, '%Y-%m-%d') between #{startDate} and #{endDate}
</if>
</select>
<select id="getSouthTempById" resultType="com.bonus.tool.dto.TbGwModelVo">
select id,
name
from tb_south_mdel
where del_flag = 0
and id = #{id}
</select>
<select id="selectComPerfList" resultType="com.bonus.tool.dto.ComPerformanceBean">
SELECT id,
pro_name,
voltage,
station_num,
line_scale,
stop_time,
contract_rang,
owner_unit,
owner_phone
FROM tb_gw_perf_rel tgpr
LEFT JOIN tb_company_perf tcp ON tgpr.perf_id = tcp.id
WHERE tgpr.south_id = #{id}
</select>
<select id="selectComCoreList" resultType="com.bonus.tool.dto.ComCorePersonBean">
SELECT tgku.id,
tkp.id as userId,
tkp.user_name,
tkp.id_card,
tkp.title,
tkp.diploma,
tgku.position as post_name,
tkp.major,
tkp.`level`,
tgku.pro_perf
FROM tb_south_company_user tgku
LEFT JOIN tb_key_people tkp ON tgku.key_id = tkp.id
WHERE tgku.south_id = #{id}
</select>
<select id="selectComOtherList" resultType="com.bonus.tool.dto.ComOtherPersonBean">
SELECT tgou.id,
tkp.id as userId,
tkp.user_name,
tkp.id_card,
tkp.title,
tkp.diploma,
tkp.diploma_num,
tkp.major,
tkp.`level`,
tgou.position as post_name
FROM tb_south_other_user tgou
LEFT JOIN tb_other_people tkp ON tgou.other_id = tkp.id
WHERE tgou.south_id = #{id}
</select>
<select id="selectSubOtherList" resultType="com.bonus.tool.dto.ComOtherPersonBean">
SELECT tgou.id,
tkp.id as userId,
tkp.user_name,
tkp.id_card,
tkp.title,
tkp.diploma,
tkp.diploma_num,
tgou.position as post_name
FROM tb_south_sub_user tgou
LEFT JOIN tb_sub_people tkp ON tgou.user_id = tkp.id
WHERE tgou.south_id = #{id}
</select>
</mapper>