complexMapper.xml
7.5 KB
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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
<?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.eport.rest.dao.ComplexDao">
<sql id="ComplexEntityColumns">
a1.CODE_T AS "codeT"
,a1.CODE_S AS "codeS"
,a1.G_NAME AS "gName"
,a1.LOW_RATE AS "lowRate"
,a1.HIGH_RATE AS "highRate"
,a1.OUT_RATE AS "outRate"
,a1.REG_MARK AS "regMark"
,a1.REG_RATE AS "regRate"
,a1.TAX_TYPE AS "taxType"
,a1.TAX_RATE AS "taxRate"
,a1.COMM_RATE AS "commRate"
,a1.TAIWAN_RATE AS "taiwanRate"
,a1.OTHER_TYPE AS "otherType"
,a1.OTHER_RATE AS "otherRate"
,a1.UNIT_1 AS "unit1"
,a1.UNIT_2 AS "unit2"
,a1.ILOW_PRICE AS "ilowPrice"
,a1.IHIGH_PRICE AS "ihighPrice"
,a1.ELOW_PRICE AS "elowPrice"
,a1.EHIGH_PRICE AS "ehighPrice"
,a1.MAX_IN AS "maxIn"
,a1.MAX_OUT AS "maxOut"
,a1.CONTROL_MA AS "controlMa"
,a1.CHK_PRICE AS "chkPrice"
,a1.TARIFF_MARK AS "tariffMark"
,a1.NOTE_S AS "noteS"
,a1.PK_SEQ AS "pkSeq"
</sql>
<sql id="ComplexEntityListColumns">
a1.PK_SEQ AS "pkSeq"
</sql>
<!--查询表中所有资料(所有字段) -->
<select id="listAll"
parameterType="HashMap"
resultType="com.eport.rest.entity.ComplexEntity"
>
select
<include refid="ComplexEntityColumns"/>
,(select UNIT_NAME from unit c1 where c1.UNIT_CODE = a1.UNIT_1) as unit1Name
,(select UNIT_NAME from unit c1 where c1.UNIT_CODE = a1.UNIT_2) as unit2Name
FROM complex a1
WHERE 1=1
</select>
<!--分页查询资料(所有字段) -->
<select id="pageAll"
parameterType="HashMap"
resultType="com.eport.rest.entity.ComplexEntity"
>
select
<include refid="ComplexEntityColumns"/>
,(select UNIT_NAME from unit c1 where c1.UNIT_CODE = a1.UNIT_1) as unit1Name
,(select UNIT_NAME from unit c1 where c1.UNIT_CODE = a1.UNIT_2) as unit2Name
FROM complex a1
WHERE 1=1
</select>
<!--查询表中所有资料(仅列表显示字段) -->
<select id="list"
parameterType="HashMap"
resultType="com.eport.rest.entity.ComplexEntity"
>
select
<include refid="ComplexEntityListColumns"/>
FROM complex a1
WHERE 1=1
</select>
<!--分页查询资料(仅列表显示字段) -->
<select id="page"
parameterType="HashMap"
resultType="com.eport.rest.entity.ComplexEntity"
>
select
<include refid="ComplexEntityListColumns"/>
FROM complex a1
WHERE 1=1
</select>
<!--根据主键查询数据 -->
<select id="findByPK"
parameterType="Integer"
resultType="com.eport.rest.entity.ComplexEntity"
>
select
<include refid="ComplexEntityColumns"/>
,(select UNIT_NAME from unit c1 where c1.UNIT_CODE = a1.UNIT_1) as unit1Name
,(select UNIT_NAME from unit c1 where c1.UNIT_CODE = a1.UNIT_2) as unit2Name
FROM complex a1
WHERE a1.PK_SEQ=#{par}
</select>
<!--新增数据 -->
<insert id="insert"
parameterType="com.eport.rest.entity.ComplexEntity"
>
<selectKey resultType="Integer" order="AFTER" keyProperty="pkSeq">
<if test="pkSeq != null ">
select #{pkSeq} from dual
</if>
<if test="pkSeq == null ">
SELECT LAST_INSERT_ID() AS pkSeq
</if>
</selectKey>
insert
INTO complex (
CODE_T
,CODE_S
,G_NAME
,LOW_RATE
,HIGH_RATE
,OUT_RATE
,REG_MARK
,REG_RATE
,TAX_TYPE
,TAX_RATE
,COMM_RATE
,TAIWAN_RATE
,OTHER_TYPE
,OTHER_RATE
,UNIT_1
,UNIT_2
,ILOW_PRICE
,IHIGH_PRICE
,ELOW_PRICE
,EHIGH_PRICE
,MAX_IN
,MAX_OUT
,CONTROL_MA
,CHK_PRICE
,TARIFF_MARK
,NOTE_S
<if test="pkSeq != null ">
,PK_SEQ
</if>
) VALUES (
#{codeT,jdbcType=VARCHAR}
,#{codeS,jdbcType=VARCHAR}
,#{gName,jdbcType=VARCHAR}
,#{lowRate,jdbcType=VARCHAR}
,#{highRate,jdbcType=VARCHAR}
,#{outRate,jdbcType=VARCHAR}
,#{regMark,jdbcType=VARCHAR}
,#{regRate,jdbcType=VARCHAR}
,#{taxType,jdbcType=VARCHAR}
,#{taxRate,jdbcType=VARCHAR}
,#{commRate,jdbcType=VARCHAR}
,#{taiwanRate,jdbcType=VARCHAR}
,#{otherType,jdbcType=VARCHAR}
,#{otherRate,jdbcType=VARCHAR}
,#{unit1,jdbcType=VARCHAR}
,#{unit2,jdbcType=VARCHAR}
,#{ilowPrice,jdbcType=VARCHAR}
,#{ihighPrice,jdbcType=VARCHAR}
,#{elowPrice,jdbcType=VARCHAR}
,#{ehighPrice,jdbcType=VARCHAR}
,#{maxIn,jdbcType=VARCHAR}
,#{maxOut,jdbcType=VARCHAR}
,#{controlMa,jdbcType=VARCHAR}
,#{chkPrice,jdbcType=VARCHAR}
,#{tariffMark,jdbcType=VARCHAR}
,#{noteS,jdbcType=VARCHAR}
<if test="pkSeq != null ">
,#{pkSeq,jdbcType=decimal}
</if>
)
</insert>
<!--更新数据 -->
<update id="update"
parameterType="com.eport.rest.entity.ComplexEntity"
>
update
complex
<set>
<if test="codeT != null ">
CODE_T = #{codeT},
</if>
<if test="codeS != null ">
CODE_S = #{codeS},
</if>
<if test="gName != null ">
G_NAME = #{gName},
</if>
<if test="lowRate != null ">
LOW_RATE = #{lowRate},
</if>
<if test="highRate != null ">
HIGH_RATE = #{highRate},
</if>
<if test="outRate != null ">
OUT_RATE = #{outRate},
</if>
<if test="regMark != null ">
REG_MARK = #{regMark},
</if>
<if test="regRate != null ">
REG_RATE = #{regRate},
</if>
<if test="taxType != null ">
TAX_TYPE = #{taxType},
</if>
<if test="taxRate != null ">
TAX_RATE = #{taxRate},
</if>
<if test="commRate != null ">
COMM_RATE = #{commRate},
</if>
<if test="taiwanRate != null ">
TAIWAN_RATE = #{taiwanRate},
</if>
<if test="otherType != null ">
OTHER_TYPE = #{otherType},
</if>
<if test="otherRate != null ">
OTHER_RATE = #{otherRate},
</if>
<if test="unit1 != null ">
UNIT_1 = #{unit1},
</if>
<if test="unit2 != null ">
UNIT_2 = #{unit2},
</if>
<if test="ilowPrice != null ">
ILOW_PRICE = #{ilowPrice},
</if>
<if test="ihighPrice != null ">
IHIGH_PRICE = #{ihighPrice},
</if>
<if test="elowPrice != null ">
ELOW_PRICE = #{elowPrice},
</if>
<if test="ehighPrice != null ">
EHIGH_PRICE = #{ehighPrice},
</if>
<if test="maxIn != null ">
MAX_IN = #{maxIn},
</if>
<if test="maxOut != null ">
MAX_OUT = #{maxOut},
</if>
<if test="controlMa != null ">
CONTROL_MA = #{controlMa},
</if>
<if test="chkPrice != null ">
CHK_PRICE = #{chkPrice},
</if>
<if test="tariffMark != null ">
TARIFF_MARK = #{tariffMark},
</if>
<if test="noteS != null ">
NOTE_S = #{noteS},
</if>
</set>
WHERE PK_SEQ = #{pkSeq}
</update>
<!--根据主键删除数据 -->
<delete id="delete"
parameterType="HashMap"
>
delete
from complex
WHERE PK_SEQ in (${par})
</delete>
<!--根据商品编码查询数据 -->
<select id="findByCodeTS"
parameterType="HashMap"
resultType="HashMap"
>
SELECT
a1.CODE_T AS "codeT",
a1.CODE_S AS "codeS",
a1.G_NAME AS "gName",
a1.LOW_RATE AS "lowRate",
a1.HIGH_RATE AS "highRate",
a1.OUT_RATE AS "outRate",
a1.REG_MARK AS "regMark",
a1.REG_RATE AS "regRate",
a1.TAX_TYPE AS "taxType",
a1.TAX_RATE AS "taxRate",
a1.COMM_RATE AS "commRate",
a1.TAIWAN_RATE AS "taiwanRate",
a1.OTHER_TYPE AS "otherType",
a1.OTHER_RATE AS "otherRate",
a1.UNIT_1 AS "unit1",
a1.UNIT_2 AS "unit2",
a1.ILOW_PRICE AS "ilowPrice",
a1.IHIGH_PRICE AS "ihighPrice",
a1.ELOW_PRICE AS "elowPrice",
a1.EHIGH_PRICE AS "ehighPrice",
a1.MAX_IN AS "maxIn",
a1.MAX_OUT AS "maxOut",
a1.CONTROL_MA AS "controlMa",
a1.CHK_PRICE AS "chkPrice",
a1.TARIFF_MARK AS "tariffMark",
a1.NOTE_S AS "noteS",
a1.PK_SEQ AS "pkSeq",
(
SELECT
UNIT_NAME
FROM
unit c1
WHERE
c1.UNIT_CODE = a1.UNIT_1
) AS "unit1Name",
(
SELECT
UNIT_NAME
FROM
unit c1
WHERE
c1.UNIT_CODE = a1.UNIT_2
) AS "unit2Name"
FROM
complex a1
WHERE
CONCAT(a1.CODE_T,a1.CODE_S) =#{code}
</select>
</mapper>