118 lines
6.2 KiB
XML
118 lines
6.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.digitalSignage.basic.dao.TbProjectMapper">
|
|
<insert id="addTbProject">
|
|
insert into tb_project
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<if test="departId != null ">depart_id,</if>
|
|
<if test="proName != null ">pro_name,</if>
|
|
<if test="voltageLevel != null ">voltage_level,</if>
|
|
<if test="lineLength != null ">line_length,</if>
|
|
<if test="planStartTime != null">plan_start_time,</if>
|
|
<if test="planEndTime != null ">plan_end_time,</if>
|
|
<if test="lon != null ">lon,</if>
|
|
<if test="lat != null ">lat,</if>
|
|
<if test="address != null ">address,</if>
|
|
<if test="proStatus != null ">pro_status,</if>
|
|
<if test="createTime != null">create_time,</if>
|
|
<if test="createUserId != null ">create_user_id,</if>
|
|
is_active
|
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
<if test="departId != null ">#{departId},</if>
|
|
<if test="proName != null ">#{proName},</if>
|
|
<if test="voltageLevel != null ">#{voltageLevel},</if>
|
|
<if test="lineLength != null ">#{lineLength},</if>
|
|
<if test="planStartTime != null ">#{planStartTime},</if>
|
|
<if test="planEndTime != null ">#{planEndTime},</if>
|
|
<if test="lon != null ">#{lon},</if>
|
|
<if test="lat != null ">#{lat},</if>
|
|
<if test="address != null ">#{address},</if>
|
|
<if test="proStatus != null ">#{proStatus},</if>
|
|
<if test="createTime != null ">#{createTime},</if>
|
|
<if test="createUserId != null ">#{createUserId},</if>
|
|
1
|
|
</trim>
|
|
</insert>
|
|
<update id="updateTbProject">
|
|
update tb_project set depart_id = #{departId},pro_name = #{proName},voltage_level = #{voltageLevel},
|
|
line_length = #{lineLength},plan_start_time = #{planStartTime},plan_end_time = #{planEndTime},lon = #{lon},
|
|
lat = #{lat},address = #{address},pro_status = #{proStatus},update_user_id = #{updateUserId},update_time = now()
|
|
where id = #{id}
|
|
</update>
|
|
<delete id="delTbProject">
|
|
update tb_project set is_active = '0' where id = #{id}
|
|
</delete>
|
|
|
|
<select id="getTbProjectList" resultType="com.bonus.digitalSignage.basic.vo.TbProjectVo">
|
|
select tp.id as id,tp.depart_id as departId,td.depart_name as departName,tp.pro_name as proName,
|
|
A.dict_name as voltageLevel,tp.line_length as lineLength,
|
|
tp.plan_start_time as planStartTime,tp.plan_end_time as planEndTime,tp.lon as lon,tp.lat as lat,
|
|
tp.address as address,B.dict_name as pro_status
|
|
from tb_project tp
|
|
left join tb_depart td on tp.depart_id = td.id
|
|
LEFT JOIN (
|
|
SELECT sd.dict_value,sd.dict_name
|
|
FROM sys_distinct sd
|
|
LEFT JOIN sys_distinct sd2 ON sd.p_id = sd2.id
|
|
WHERE sd2.dict_code = 'voltage_level' AND sd.del_flag = 0
|
|
) A ON A.dict_value = tp.voltage_level
|
|
LEFT JOIN (
|
|
SELECT sd.dict_value,sd.dict_name
|
|
FROM sys_distinct sd
|
|
LEFT JOIN sys_distinct sd2 ON sd.p_id = sd2.id
|
|
WHERE sd2.dict_code = 'pro_status' AND sd.del_flag = 0
|
|
) B ON B.dict_value = tp.pro_status
|
|
where tp.is_active = '1'
|
|
<if test="departName != '' and departName != null">and td.depart_name like concat('%', #{departName}, '%')</if>
|
|
<if test="proName != '' and proName != null"> and tp.pro_name like concat('%', #{proName}, '%')</if>
|
|
<if test="proStatus != '' and proStatus != null"> and tp.pro_status = #{proStatus}</if>
|
|
<if test="deptIds != '' and deptIds != null">
|
|
and tp.depart_id IN
|
|
<foreach item="item" index="index" collection="deptIds"
|
|
open="(" separator="," close=")">
|
|
#{item}
|
|
</foreach>
|
|
</if>
|
|
ORDER BY tp.update_time desc
|
|
</select>
|
|
<select id="getTbProjectById" resultType="com.bonus.digitalSignage.basic.vo.TbProjectVo">
|
|
select tp.id as id,depart_id as departId,tp.pro_name as proName,tp.voltage_level as voltageLevel,tp.line_length as lineLength,
|
|
tp.plan_start_time as planStartTime,tp.plan_end_time as planEndTime,tp.lon as lon,tp.lat as lat,
|
|
tp.address as address,tp.pro_status as pro_status
|
|
from tb_project tp where id = #{id}
|
|
</select>
|
|
<select id="getTbProjectByProName" resultType="com.bonus.digitalSignage.basic.vo.TbProjectVo">
|
|
select tp.id as id,tp.pro_name as proName,tp.voltage_level as voltageLevel,tp.line_length as lineLength,
|
|
tp.plan_start_time as planStartTime,tp.plan_end_time as planEndTime,tp.lon as lon,tp.lat as lat,
|
|
tp.address as address,tp.pro_status as pro_status
|
|
from tb_project tp where depart_id = #{departId} and pro_name = #{proName} and is_active ='1'
|
|
</select>
|
|
<select id="getDataAuthByDeptId" resultType="java.lang.Long">
|
|
SELECT all_children.id
|
|
FROM (
|
|
SELECT t3.id
|
|
FROM (
|
|
SELECT
|
|
t1.id,
|
|
t1.parent_id,
|
|
IF(
|
|
FIND_IN_SET(t1.parent_id, @pids) > 0,
|
|
@pids := CONCAT(@pids, ',', t1.id),
|
|
-1
|
|
) AS ischild
|
|
FROM
|
|
(SELECT id, parent_id FROM tb_depart WHERE is_active = '1') t1,
|
|
(SELECT @pids :=#{dept}) t2
|
|
ORDER BY t1.parent_id, t1.id -- 确保父节点先处理
|
|
) t3
|
|
WHERE t3.ischild != -1
|
|
) all_children
|
|
LEFT JOIN tb_depart d
|
|
ON all_children.id = d.parent_id
|
|
AND d.is_active = '1'
|
|
WHERE d.parent_id IS NULL;
|
|
</select>
|
|
</mapper>
|