141 lines
5.5 KiB
XML
141 lines
5.5 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.ruoyi.project.oil.mapper.ThDeviceMapper">
|
|
<parameterMap id="BaseParameterMap" type="com.ruoyi.project.oil.domain.monitor.ThDevice">
|
|
<parameter property="sn" jdbcType="VARCHAR"/>
|
|
<parameter property="name" jdbcType="VARCHAR"/>
|
|
<parameter property="deptId" jdbcType="BIGINT"/>
|
|
</parameterMap>
|
|
|
|
<resultMap id="BaseResultMap" type="com.ruoyi.project.oil.domain.monitor.ThDevice">
|
|
<id property="id" column="id" jdbcType="BIGINT"/>
|
|
<result property="sn" column="sn" jdbcType="VARCHAR"/>
|
|
<result property="name" column="name" jdbcType="VARCHAR"/>
|
|
<result property="createBy" column="create_by" jdbcType="VARCHAR"/>
|
|
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
|
|
<result property="status" column="status" jdbcType="VARCHAR"/>
|
|
<result property="note" column="note" jdbcType="VARCHAR"/>
|
|
<result property="fileUrl" column="file_url" jdbcType="VARCHAR"/>
|
|
<result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
|
|
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
|
|
<result property="address" column="address" jdbcType="VARCHAR"/>
|
|
<result property="deptId" column="dept_id" jdbcType="BIGINT"/>
|
|
<result property="longitude" column="longitude" jdbcType="VARCHAR"/>
|
|
<result property="latitude" column="latitude" jdbcType="VARCHAR"/>
|
|
<result property="deptName" column="dept_name" jdbcType="VARCHAR"/>
|
|
<result property="bjyz" column="bjyz" jdbcType="VARCHAR"/>
|
|
<result property="gangqu" column="gangqu" jdbcType="VARCHAR"/>
|
|
<result property="p" column="p" jdbcType="VARCHAR"/>
|
|
<result property="pp" column="pp" jdbcType="VARCHAR"/>
|
|
<result property="ppp" column="ppp" jdbcType="VARCHAR"/>
|
|
</resultMap>
|
|
|
|
<sql id="Base_Column_List">
|
|
select d.id,
|
|
d.sn,
|
|
d.name,
|
|
d.create_by,
|
|
d.create_time,
|
|
d.status,
|
|
d.note,
|
|
d.file_url,
|
|
d.update_by,
|
|
d.update_time,
|
|
d.address,
|
|
d.dept_id,
|
|
d.longitude,
|
|
d.latitude,
|
|
p.dept_name,
|
|
pp.dept_name as "gangqu"
|
|
from th_device d
|
|
left join sys_dept p on d.dept_id = p.dept_id
|
|
left join sys_dept pp on p.parent_id = pp.dept_id
|
|
</sql>
|
|
|
|
<select id="selectDeviceList" resultMap="BaseResultMap" parameterType="com.ruoyi.project.oil.domain.monitor.ThDevice">
|
|
select d.id,
|
|
d.sn,
|
|
d.name,
|
|
d.create_by,
|
|
d.create_time,
|
|
d.status,
|
|
d.note,
|
|
d.file_url,
|
|
d.update_by,
|
|
d.update_time,
|
|
d.address,
|
|
d.dept_id,
|
|
d.longitude,
|
|
d.latitude,
|
|
d.bjyz,
|
|
p.dept_name as "p",
|
|
pp.dept_name as "pp",
|
|
ppp.dept_name as "ppp"
|
|
from th_device d
|
|
LEFT JOIN sys_dept p ON d.dept_id = p.dept_id
|
|
LEFT JOIN sys_dept pp ON p.parent_id = pp.dept_id
|
|
LEFT JOIN sys_dept ppp ON pp.parent_id = ppp.dept_id
|
|
<where>
|
|
<if test="deptId != null and deptId != ''">
|
|
AND d.dept_id IN (SELECT dept_id
|
|
FROM sys_dept START WITH dept_id = #{deptId}
|
|
CONNECT BY PRIOR dept_id = parent_id)
|
|
</if>
|
|
<if test="sn != null and sn != ''">
|
|
AND d.sn like concat(concat('%',#{sn}),'%')
|
|
</if>
|
|
<if test="name != null and name != ''">
|
|
AND d.name like concat(concat('%',#{name}),'%')
|
|
</if>
|
|
</where>
|
|
order by d.id desc
|
|
</select>
|
|
|
|
<select id="selectDeviceListByDeptId" parameterType="long" resultMap="BaseResultMap">
|
|
<include refid="Base_Column_List"/>
|
|
where d.dept_id = #{deptId}
|
|
</select>
|
|
|
|
<select id="selectAllDeviceListByDeptId" parameterType="long" resultMap="BaseResultMap">
|
|
WITH dept_hierarchy (dept_id) AS (
|
|
SELECT dept_id
|
|
FROM sys_dept
|
|
WHERE dept_id = #{deptId}
|
|
UNION ALL
|
|
SELECT d.dept_id
|
|
FROM sys_dept d
|
|
INNER JOIN dept_hierarchy dh ON d.parent_id = dh.dept_id
|
|
)
|
|
<include refid="Base_Column_List"/>
|
|
INNER JOIN dept_hierarchy dh ON d.dept_id = dh.dept_id
|
|
ORDER BY d.dept_id DESC
|
|
</select>
|
|
|
|
<select id="selectDeviceListByDeptIdList" parameterType="java.util.List" resultMap="BaseResultMap">
|
|
<include refid="Base_Column_List"/>
|
|
where d.dept_id in
|
|
<foreach collection="deptIdList" item="deptId" open="(" separator="," close=")">
|
|
#{deptId}
|
|
</foreach>
|
|
</select>
|
|
|
|
<select id="countDevice" parameterType="map" resultType="int">
|
|
select count(1) from th_device d
|
|
<where>
|
|
<if test="deptId != null and deptId != ''">
|
|
AND d.dept_id IN (SELECT dept_id
|
|
FROM sys_dept START WITH dept_id = #{deptId}
|
|
CONNECT BY PRIOR dept_id = parent_id)
|
|
</if>
|
|
<if test="year != null and year != ''">
|
|
AND to_char(d.create_time, 'yyyy') = #{year}
|
|
</if>
|
|
<if test="status != null">
|
|
AND d.status = #{status}
|
|
</if>
|
|
</where>
|
|
</select>
|
|
</mapper>
|