12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- <?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="cn.iocoder.yudao.module.pms.dal.mysql.inspect.IotInspectRouteMapper">
- <!--
- 一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
- 无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
- 代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
- 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
- -->
- <select id="getRoute"
- resultType="cn.iocoder.yudao.module.pms.dal.dataobject.inspect.IotInspectRouteDO">
- select * from (SELECT
- r.route_name,
- d.device_name,
- d.id as device_id,
- r.id,
- r.item_json,
- r.create_time,
- d.dept_id,d.device_code,
- d.brand_name
- FROM
- rq_iot_inspect_route r
- LEFT JOIN rq_iot_device d
- ON d.asset_class IN (
- SELECT id FROM rq_iot_product_classify
- WHERE id = r.device_classify OR parent_id = r.device_classify
- )
- LEFT JOIN rq_iot_product_classify p
- ON d.asset_class = p.id
- WHERE
- NOT EXISTS (
- SELECT 1 FROM rq_iot_inspect_route i
- WHERE i.device_id = d.id
- )
- AND d.id IS NOT NULL and r.deleted=0 and d.deleted=0 and p.deleted=0 and r.brand is null
- union all
- select route_name, device_name, device_id,id,item_json,create_time,dept_id,device_code,brand_name from rqiot.rq_iot_inspect_route
- where device_id is not null and deleted=0
- union all
- select li.route_name,de.device_name,de.id device_id, li.id, li.item_json, li.create_time, de.dept_id, de.device_code,li.brand_name from rq_iot_inspect_route li left join rq_iot_device de on li.brand=de.brand where li.brand is not null and li.deleted=0 and de.deleted=0
- )fin
- <where>
- <if test="reqVO.deviceName!=null and reqVO.deviceName!=''">
- and fin.device_name LIKE CONCAT('%',#{reqVO.deviceName},'%')
- </if>
- <if test="reqVO.deviceCode!=null and reqVO.deviceCode!=''">
- and fin.device_code LIKE CONCAT('%',#{reqVO.deviceCode},'%')
- </if>
- <if test="reqVO.routeName!=null and reqVO.routeName!=''">
- and fin.route_name LIKE CONCAT('%',#{reqVO.routeName},'%')
- </if>
- <if test="reqVO.brandName!=null and reqVO.brandName!=''">
- and fin.brand_name LIKE CONCAT('%',#{reqVO.brandName},'%')
- </if>
- <if test="reqVO.deptId!=null and reqVO.deptId!=''">
- and fin.dept_id LIKE CONCAT('%',#{reqVO.deptId},'%')
- </if>
- </where>
- </select>
- </mapper>
|