Helius
2021-06-16 4e51778362c2130598a4c73ec4cebe6629dbc53f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<?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.xzx.gc.order.mapper.FenceMapper">
  <resultMap id="BaseResultMap" type="com.xzx.gc.entity.Fence">
    <!--
      WARNING - @mbg.generated
    -->
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="fence_name" jdbcType="VARCHAR" property="fenceName" />
    <result column="fence_type" jdbcType="VARCHAR" property="fenceType" />
    <result column="keyword" jdbcType="VARCHAR" property="keyword" />
    <result column="radius" jdbcType="TINYINT" property="radius" />
    <result column="longitude" jdbcType="VARCHAR" property="longitude" />
    <result column="latitude" jdbcType="VARCHAR" property="latitude" />
    <result column="longlatiarr" jdbcType="VARCHAR" property="longlatiarr" />
    <result column="create_time" jdbcType="VARCHAR" property="createTime" />
    <result column="update_time" jdbcType="VARCHAR" property="updateTime" />
    <result column="del_flag" jdbcType="TINYINT" property="delFlag" />
    <result column="prohibit" jdbcType="BIT" property="prohibit" />
    <result column="town_code" jdbcType="VARCHAR" property="townCode" />
    <result column="partner_id" jdbcType="VARCHAR" property="partnerId" />
  </resultMap>
 
 
  <select id="findByUserId" resultMap="BaseResultMap">
    SELECT
    c.*,b.partner_id "partnerId"
FROM
    xzx_user_other_info a
    INNER JOIN xzx_partner_fence b ON a.partner_id = b.partner_id
    AND b.del_flag = 0
    INNER JOIN xzx_electronic_fence c ON b.fence_id = c.id
    AND c.del_flag = 0
    AND c.prohibit = 0
    WHERE a.user_id=#{userId}
  </select>
 
 
    <select id="findByPartnerId" resultMap="BaseResultMap">
        SELECT
            b.*
        FROM
            xzx_partner_fence a
            INNER JOIN xzx_electronic_fence b ON a.fence_id = b.id
        WHERE
            a.del_flag = 0
            AND b.del_flag = 0
            AND b.prohibit = 0
            and a.partner_id=#{partnerId}
            order  by b.create_time desc
    </select>
 
 
    <select id="queryElectronic" resultType="com.xzx.gc.entity.XzxElectronicFence">
        select * from xzx_electronic_fence
        where fence_name=#{fenceName} and del_flag=0
        <if test="id != null">
            AND id !=#{id}
        </if>
    </select>
    <select id="queryFenceList" resultType="com.xzx.gc.model.admin.XzxElectronicFenceModel">
        select a.* from xzx_electronic_fence a
        left join xzx_partner_fence b on a.id=b.fence_id
        where a.del_flag=0 and b.del_flag=0
 
        <if test="fenceType != null and fenceType != ''">
            AND a.fence_type=#{fenceType}
        </if>
 
        <if test="partnerId != null and partnerId != ''">
            AND b.partner_id=#{partnerId}
        </if>
 
        <if test="partnerIdList != null  and partnerIdList.size() != 0">
            AND b.partner_id in
            <foreach collection="partnerIdList" index="index" item="id" open="(" separator="," close=")">
                #{id}
            </foreach>
        </if>
    </select>
    <select id="queryPartnerAreaIds" resultType="int">
 
        select count(id) from xzx_partner_gaode where del_flag=0 and partner_id=#{partnerId}
        <if test="townId != null and townId != ''">
            AND town_id=#{townId}
        </if>
    </select>
    <select id="queryAreaTownId" resultType="java.lang.String">
        select level_3_id
        from xzx_sys_address_level_info
        where level_3_name = #{keyword}
    </select>
    <select id="queryOrderTownListByArea" resultType="java.lang.String">
        select id from xzx_electronic_fence where town_code=#{townCode} and del_flag=0
        <if test="eleId != null and eleId != ''">
            AND id!=#{eleId}
        </if>
    </select>
    <select id="queryTownListByArea" resultType="java.lang.String">
        select id from xzx_electronic_fence where town_code=#{townCode} and del_flag=0 and fence_type=2
        <if test="eleId != null and eleId != ''">
            AND id!=#{eleId}
        </if>
    </select>
    <select id="queryODByArea" resultType="java.lang.String">
        select id
        from xzx_electronic_fence
        where town_code = #{townCode} and del_flag = 0
    </select>
    <select id="queryPartnerIdByTownId" resultType="java.lang.String">
        select partner_id
        from xzx_partner_fence
        where fence_id = #{townId} and del_flag = 0
    </select>
 
    <select id="queryPartnerFenceList" resultType="com.xzx.gc.model.admin.XzxElectronicFenceModel">
        select a.* from xzx_electronic_fence a
        where a.del_flag=0 and
        a.id not in (select b.fence_id from xzx_partner_fence b
        where b.fence_id=a.id and b.del_flag=0
        <if test="id != null and id != ''">
            and b.partner_id<![CDATA[<> ]]>#{id}
        </if>
        )
        group by a.id order by a.create_time desc
    </select>
    <select id="queryPartnerFenceListByUser" resultType="com.xzx.gc.model.admin.XzxElectronicFenceModel">
        select a.* from xzx_electronic_fence a
        left join xzx_partner_fence b on a.id=b.fence_id
        where a.del_flag=0 and b.del_flag=0
        <if test="partnerIds != null and partnerIds != ''">
            and b.partner_id=#{partnerIds}
        </if>
        group by a.id order by a.create_time desc
    </select>
 
 
 
</mapper>