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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
| <?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.by4cloud.platformx.business.mapper.ProductMapper">
|
| <resultMap id="productMap" type="com.by4cloud.platformx.business.entity.Product">
| <id property="id" column="id"/>
| <result property="productName" column="product_name"/>
| <result property="erpCode" column="erp_code"/>
| <result property="mainCode" column="main_code"/>
| <result property="taxRate" column="tax_rate"/>
| <result property="compId" column="comp_id"/>
| <result property="createBy" column="create_by"/>
| <result property="createTime" column="create_time"/>
| <result property="updateBy" column="update_by"/>
| <result property="updateTime" column="update_time"/>
| <result property="delFlag" column="del_flag"/>
| </resultMap>
| <select id="getProductListByScope" resultType="com.by4cloud.platformx.business.vo.ProductSelectVo">
| SELECT
| t.id,
| t.product_name,
| t.main_code,
| t.erp_code,
| t.product_type,
| t.tax_rate,
| t.tax_class,
| t.tax_code,
| t.parent_id,
| t.create_by,
| t.update_by,
| t.create_time,
| t.update_time,
| t.del_flag,
| t.comp_id
| FROM
| product t
| WHERE
| del_flag = '0'
| <if test="product.productName !=null and product.productName !=''">
| and t.product_name LIKE CONCAT('%', #{product.productName}, '%')
| </if>
| AND (
| NOT EXISTS ( SELECT 1 FROM product t1 WHERE t1.parent_id = t.id ))
| </select>
| <select id="getProductListByParentId" resultType="com.by4cloud.platformx.business.vo.ProductSelectVo">
| SELECT
| t.id,
| CONCAT(t.product_name,IFNULL(t.product_type,'')) product_name,
| t.main_code,
| t.erp_code,
| t.product_type,
| t.tax_rate,
| t.tax_class,
| t.tax_code,
| t.parent_id,
| t.create_by,
| t.update_by,
| t.create_time,
| t.update_time,
| t.del_flag,
| t.comp_id ,
| ( SELECT count( 1 ) FROM product t1 WHERE t1.parent_id = t.id ) AS childNum
| FROM
| product t
| WHERE
| del_flag = '0'
| <if test="queryDTO.productName !=null and queryDTO.productName !=''">
| and ( t.product_name LIKE CONCAT('%', #{queryDTO.productName}, '%') or
| t.erp_code LIKE CONCAT('%', #{queryDTO.productName}, '%')
|
| <if test="queryDTO.productId != null and queryDTO.productId.size() > 0">
| or t.id IN
| <foreach collection="queryDTO.productId" item="id" open="(" separator="," close=")">
| #{id}
| </foreach>
| </if>
| )
| </if>
| <if test="queryDTO.parentId !=null ">
| and (t.parent_id = #{queryDTO.parentId}
| <if test="queryDTO.productId != null and queryDTO.productId.size() > 0">
| or t.id IN
| <foreach collection="queryDTO.productId" item="id" open="(" separator="," close=")">
| #{id}
| </foreach>
| </if>
| )
| </if>
|
| <choose>
| <when test="queryDTO.contractCategory !=null and queryDTO.contractCategory !='' and queryDTO.contractCategory=='water_house'">
| and t.erp_code in
| <foreach collection="erpCodes" item="erp" open="(" separator="," close=")">
| #{erp}
| </foreach>
| </when>
| <otherwise>
| and t.erp_code not in
| <foreach collection="erpCodes" item="erp" open="(" separator="," close=")">
| #{erp}
| </foreach>
| </otherwise>
| </choose>
|
| </select>
| <select id="getProductSMJListByParentId" resultType="com.by4cloud.platformx.business.vo.ProductSelectVo">
| SELECT
| t.id,
| CONCAT(t.product_name,IFNULL(t.product_type,'')) product_name,
| t.main_code,
| t.erp_code,
| t.product_type,
| t.tax_rate,
| t.tax_class,
| t.tax_code,
| t.parent_id,
| t.create_by,
| t.update_by,
| t.create_time,
| t.update_time,
| t.del_flag,
| t.comp_id ,
| ( SELECT count( 1 ) FROM product t1 WHERE t1.parent_id = t.id ) AS childNum
| FROM
| product t
| WHERE
| del_flag = '0'
| <if test="queryDTO.productName !=null and queryDTO.productName !=''">
| and ( t.product_name LIKE CONCAT('%', #{queryDTO.productName}, '%') or
| t.erp_code LIKE CONCAT('%', #{queryDTO.productName}, '%')
|
| <if test="queryDTO.productId != null and queryDTO.productId.size() > 0">
| or t.id IN
| <foreach collection="queryDTO.productId" item="id" open="(" separator="," close=")">
| #{id}
| </foreach>
| </if>
| )
| </if>
| <if test="queryDTO.parentId !=null ">
| and (t.parent_id = #{queryDTO.parentId}
| <if test="queryDTO.productId != null and queryDTO.productId.size() > 0">
| or t.id IN
| <foreach collection="queryDTO.productId" item="id" open="(" separator="," close=")">
| #{id}
| </foreach>
| </if>
| )
| </if>
|
| <choose>
| <when test="queryDTO.contractCategory !=null and queryDTO.contractCategory !='' and queryDTO.contractCategory=='water_house'">
| and t.erp_code in
| <foreach collection="erpCodes" item="erp" open="(" separator="," close=")">
| #{erp}
| </foreach>
| </when>
| <otherwise>
| and t.erp_code not in
| <foreach collection="erpCodes" item="erp" open="(" separator="," close=")">
| #{erp}
| </foreach>
| </otherwise>
| </choose>
| and ( t.comp_id = 2089995177814495234 or t.comp_id = 2089996921978040321 or t.comp_id = 2089997578009128962)
| </select>
| <select id="pageScope" resultType="com.by4cloud.platformx.business.entity.Product">
| SELECT
| t.id,
| t.product_name,
| t.main_code,
| t.erp_code,
| t.product_type,
| t.tax_rate,
| t.tax_class,
| t.tax_code,
| t.parent_id,
| t.create_by,
| t.update_by,
| t.create_time,
| t.update_time,
| t.del_flag,
| t.comp_id,
| ifnull((select product_name from product t1 where t1.id = t.parent_id),'根级产品') AS parentName
| FROM
| product t
| WHERE
| del_flag = '0'
| <if test="queryDTO.productName !=null and queryDTO.productName !=''">
| AND t.product_name LIKE CONCAT('%', #{queryDTO.productName}, '%')
| </if>
| <if test="queryDTO.mainCode !=null and queryDTO.mainCode !=''">
| AND t.main_code LIKE CONCAT('%', #{queryDTO.mainCode}, '%')
| </if>
| <if test="queryDTO.erpCode !=null and queryDTO.erpCode !=''">
| AND t.erp_code LIKE CONCAT('%', #{queryDTO.erpCode}, '%')
| </if>
| order by t.create_time desc
| </select>
| <select id="page" resultType="com.by4cloud.platformx.business.entity.Product">
| SELECT
| t.id,
| t.product_name,
| t.main_code,
| t.erp_code,
| t.product_type,
| t.tax_rate,
| t.tax_class,
| t.tax_code,
| t.parent_id,
| t.create_by,
| t.update_by,
| t.create_time,
| t.update_time,
| t.del_flag,
| t.comp_id,
| ifnull((select product_name from product t1 where t1.id = t.parent_id),'根级产品') AS parentName
| FROM
| product t
| WHERE
| del_flag = '0'
| <if test="queryDTO.productName !=null and queryDTO.productName !=''">
| AND t.product_name LIKE CONCAT('%', #{queryDTO.productName}, '%')
| </if>
| <if test="queryDTO.mainCode !=null and queryDTO.mainCode !=''">
| AND t.main_code LIKE CONCAT('%', #{queryDTO.mainCode}, '%')
| </if>
| <if test="queryDTO.erpCode !=null and queryDTO.erpCode !=''">
| AND t.erp_code LIKE CONCAT('%', #{queryDTO.erpCode}, '%')
| </if>
| <if test="smjList != null and smjList.size() > 0">
| AND t.comp_id IN
| <foreach collection="smjList" item="id" open="(" separator="," close=")">
| #{id}
| </foreach>
| </if>
| order by t.create_time desc
| </select>
| </mapper>
|
|