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

301 lines
9.2 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.StateGridMapper">
<insert id="addStateGridTemp" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
insert into tb_gw_model(name,
create_user)
values (#{name},
#{createUser})
</insert>
<insert id="insertComPerf">
insert into tb_gw_perf_rel(
gw_id,
perf_id
) values
<foreach collection="list" item="item" separator=",">
(
#{item.parentId},
#{item.id}
)
</foreach>
</insert>
<insert id="insertComCore">
insert into tb_gw_key_user(
gw_id,
key_id,
position,
in_time,
out_time,
perf_id,
pro_perf
)values
<foreach collection="list" item="item" separator=",">
(
#{item.parentId},
#{item.id},
#{item.postName},
#{item.einDate},
#{item.exitDate},
#{item.perfId},
#{item.proPerf}
)
</foreach>
</insert>
<insert id="insertComOther">
insert into tb_gw_other_user(
gw_id,
other_id,
position
)values
<foreach collection="list" item="item" separator=",">
(
#{item.parentId},
#{item.id},
#{item.postName}
)
</foreach>
</insert>
<insert id="insertSub">
insert into tb_gw_model_sub(
gw_id,
sub_id
)values
<foreach collection="list" item="item" separator=",">
(
#{item.parentId},
#{item.id}
)
</foreach>
</insert>
<insert id="insertSubPerf">
insert into tb_gw_sub_rel(
gw_id,
sub_id,
perf_id
)values
<foreach collection="list" item="item" separator=",">
(
#{item.parentId},
#{item.subId},
#{item.id}
)
</foreach>
</insert>
<insert id="insertSubPerson">
insert into tb_gw_sub_user(
gw_id,
sub_id,
people_id,
position,
pro_perf
)values
<foreach collection="list" item="item" separator=",">
(
#{item.parentId},
#{item.subId},
#{item.id},
#{item.postName},
#{item.proPerf}
)
</foreach>
</insert>
<update id="updateStateGridTemp">
update tb_gw_model
set
name = #{name},
update_user = #{updateUser}
where id = #{id}
</update>
<delete id="delStateGridTemp">
update tb_gw_model
set del_flag = 1
where id = #{id}
</delete>
<delete id="delAssociatedData">
delete
from tb_gw_perf_rel
where gw_id = #{id};
delete
from tb_gw_key_user
where gw_id = #{id};
delete
from tb_gw_other_user
where gw_id = #{id};
delete
from tb_gw_model_sub
where gw_id = #{id};
delete
from tb_gw_sub_rel
where gw_id = #{id};
delete
from tb_gw_sub_user
where gw_id = #{id};
</delete>
<select id="getStateGridList" resultType="com.bonus.tool.dto.TbGwModelVo">
select
id,
name,
create_user as createUser,
create_time,
update_time
from
tb_gw_model 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="getStateGridTempById" resultType="com.bonus.tool.dto.TbGwModelVo">
select id,
name
from tb_gw_model
where del_flag = 0
and id = #{id}
</select>
<select id="selectComPerfList" resultType="com.bonus.tool.dto.ComPerformanceBean">
SELECT id,
tgpr.perf_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.gw_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.education,
tkp.title,
tkp.diploma,
tkp.diploma_num,
tgku.position as post_name,
tgku.in_time as ein_date,
tgku.out_time as exit_date,
tgku.perf_id,
tgku.pro_perf
FROM tb_gw_key_user tgku
LEFT JOIN tb_key_people tkp ON tgku.key_id = tkp.id
WHERE tgku.gw_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_gw_other_user tgou
LEFT JOIN tb_other_people tkp ON tgou.other_id = tkp.id
WHERE tgou.gw_id = #{id}
</select>
<select id="selectSubList" resultType="com.bonus.tool.dto.SubBean">
SELECT ts.id,
ts.sub_name
FROM tb_gw_model_sub tgms
LEFT JOIN tb_sub ts ON tgms.sub_id = ts.id
WHERE tgms.gw_id = #{id}
</select>
<select id="selectSubPerfList" resultType="com.bonus.tool.dto.SubPerformanceBean">
SELECT tbsr.id,
tbsr.gw_id,
tbsr.sub_id,
tbsr.perf_id,
tsp.pro_name,
tsp.voltage,
tsp.cons_unit,
tsp.start_time,
tsp.end_time,
tsp.money,
tsp.ht_remark
FROM tb_gw_sub_rel tbsr
LEFT JOIN tb_sub_perf tsp ON tbsr.perf_id = tsp.id
WHERE tbsr.gw_id = #{gwId}
and tbsr.sub_id = #{subId}
</select>
<select id="selectSubOtherList" resultType="com.bonus.tool.dto.SubOtherPeopleBean">
SELECT tgsu.id,
tkp.id as userId,
tkp.user_name,
tkp.id_card,
tkp.title,
tkp.diploma,
tkp.diploma_num,
tgsu.position AS post_name,
tgsu.pro_perf
FROM tb_gw_sub_user tgsu
LEFT JOIN tb_sub_people tkp ON tgsu.people_id = tkp.id
WHERE tgsu.gw_id = #{gwId}
AND tgsu.sub_id = #{subId}
</select>
<select id="getFileSourceList" resultType="com.bonus.tool.dto.TbFileSourceVo">
select id,table_name as tableName,table_id as tableId,file_path as filePath,file_type as fileType,
file_name as fileName,file_suffix as fileSuffix,create_time as createTime,upload_user as uploadUser
from tb_file_source where del_flag=0 and table_name = #{tableName} and table_id = #{id}
</select>
<select id="selectComCoreListByKeyId" resultType="com.bonus.tool.dto.ComCorePersonBean">
SELECT tgku.id,
tgku.position as post_name,
tgku.in_time as ein_date,
tgku.out_time as exit_date,
tgku.perf_id,
tgku.pro_perf
FROM tb_gw_key_user tgku
WHERE tgku.key_id = #{keyId}
</select>
<select id="selectComOtherListByOtherId" resultType="com.bonus.tool.dto.ComOtherPersonBean">
SELECT tgou.id,
tgou.position as post_name
FROM tb_gw_other_user tgou
WHERE tgou.other_id = #{otherId}
</select>
<select id="selectComPerfListByPerfId" resultType="com.bonus.tool.dto.ComPerformanceBean">
SELECT tgpr.perf_id,
tgpr.gw_id
FROM tb_gw_perf_rel tgpr
WHERE tgpr.perf_id = #{perfId}
</select>
<select id="selectSubListBySubId" resultType="com.bonus.tool.dto.SubBean">
SELECT tgms.id,
tgms.gw_id
FROM tb_gw_model_sub tgms
WHERE tgms.sub_id = #{subId}
</select>
<select id="selectSubPerfListByPerfId" resultType="com.bonus.tool.dto.SubPerformanceBean">
SELECT tbsr.id,
tbsr.gw_id,
tbsr.sub_id,
tbsr.perf_id
FROM tb_gw_sub_rel tbsr
WHERE tbsr.perf_id = #{perfId}
</select>
<select id="selectSubOtherListByPeopleId" resultType="com.bonus.tool.dto.SubOtherPeopleBean">
SELECT tgsu.id,
tgsu.position AS post_name,
tgsu.pro_perf
FROM tb_gw_sub_user tgsu
WHERE tgsu.people_id = #{peopleId}
</select>
</mapper>