123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- <?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.yunzhi.nanyang.mapper.TaMachineryMapper">
-
- <select id="getSummaryList" resultType="com.yunzhi.nanyang.vo.MachineSummary">
- SELECT
- *
- FROM
- ( SELECT
- t.*,
- fn_distance ( t.location, #{location} ) AS distance
- FROM ta_machinery t
- WHERE
- t.`status` > -1
- <if test="orgId != null and orgId != ''">
- AND t.org_id = #{orgId}
- </if>
- <if test="typeId != null and typeId != ''">
- AND t.type_id = #{typeId}
- </if>
- ) AS a
- ORDER BY
- a.distance DESC
- </select>
- <select id="getSummaryDetail" resultType="com.yunzhi.nanyang.vo.MachineSummary">
- SELECT
- t.*,
- s.`name` as org_name,
- fn_distance(t.location, #{location}) as distance
- FROM
- ta_machinery t
- INNER JOIN ta_org s on t.org_id = s.org_id
- WHERE
- t.machinery_id = #{machineryId}
- AND t.`status` > -1
- </select>
- <select id="getOneOfTypes" resultType="com.yunzhi.nanyang.vo.MachineSummary">
- SELECT
- t.*,
- fn_distance ( concat( m.lng, ',', m.lat ), #{location} ) AS distance,
- count( * ) AS num
- FROM
- ta_machinery t
- INNER JOIN ta_machinery s ON t.org_id = s.org_id
- AND t.type_id = s.type_id
- INNER JOIN ta_org m ON m.org_id = t.org_id
- INNER JOIN td_machinery_type n ON n.type_id = t.type_id
- WHERE
- t.`status` > -1
- AND t.machinery_id <= s.machinery_id
- <if test="typeId != null and typeId != ''">
- AND t.type_id = #{typeId}
- </if>
- <if test="q != null and q != ''">
- AND (
- t.`name` LIKE CONCAT('%', #{q}, '%')
- OR n.`name` LIKE CONCAT('%', #{q}, '%')
- )
- </if>
- GROUP BY
- t.org_id,
- t.type_id
- -- t.machinery_id
- -- HAVING
- -- num <= 1
- ORDER BY
- distance ASC
- </select>
- <select id="getPageBy" resultType="com.yunzhi.nanyang.entity.TaMachinery">
- SELECT
- t.*,
- m.`name` as org_name
- FROM
- ta_machinery t
- INNER JOIN ta_org m ON m.org_id = t.org_id
-
- <if test="isBound != null and isBound">
- INNER JOIN td_device d on t.machinery_id = d.machinery_id
- </if>
- WHERE
- t.`status` > -1
- <if test="name != null and name != ''">
- AND t.`name` LIKE CONCAT('%', #{name}, '%')
- </if>
- <if test="typeId != null and typeId != ''">
- AND t.type_id = #{typeId}
- </if>
- <if test="orgId != null and orgId != ''">
- AND t.org_id = #{orgId}
- </if>
- <if test="status != null">
- AND t.status = #{status}
- </if>
- ORDER BY
- t.create_date DESC
- </select>
- <select id="listByTypeWithLoc" resultType="com.yunzhi.nanyang.entity.TaMachinery">
- SELECT
- t.*,
- m.`name` as org_name
- FROM
- ta_machinery t
- INNER JOIN ta_org m ON m.org_id = t.org_id
- INNER JOIN td_machinery_type n ON n.type_id = t.type_id AND n.screen_statis = 1
- WHERE
- t.`status` > -1
- <if test="typeId != null and typeId != ''">
- AND t.type_id = #{typeId}
- </if>
- -- AND t.online_status = 1
- AND t.location IS NOT NULL
- </select>
- </mapper>
|