PurchaseMapper.xml
14 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
<?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.chinagas.modules.zjwjsb.mapper.PurchaseMapper">
<resultMap id="purchaseResult" type="Purchase">
<id property="bizId" column="biz_id"/>
<result property="headId" column="head_id"/>
<result property="id" column="id"/>
<result property="payNo" column="pay_no"/>
<result property="title" column="title"/>
<result property="classFullName" column="class_full_name"/>
<result property="chargeDeptName" column="charge_dept_name"/>
<result property="apply" column="apply"/>
<result property="approval" column="approval"/>
<result property="hasPay" column="has_pay"/>
<result property="waitForPay" column="wait_for_pay"/>
<result property="status" column="status"/>
<result property="statusName" column="status_name"/>
<result property="itemClass" column="item_class"/>
<result property="itemClassName" column="item_class_name" />
<result property="deptId" column="dept_id"/>
<result property="deptName" column="dept_name"/>
<result property="areaName" column="area_name"/>
<result property="applyDate" column="apply_date"/>
<result property="applyBy" column="apply_by"/>
<result property="approvalDate" column="approval_date"/>
<result property="isFromOld" column="is_from_old"/>
<result property="explain" column="explain"/>
<result property="detail" column="detail"/>
<result property="remark" column="remark"/>
<collection property="fundMainList" column="biz_id" javaType="java.util.List" ofType="FundMain" select="selectFundMain" />
<collection property="fundDetailList" column="biz_id" javaType="java.util.List" ofType="FundDetail" select="selectFundDetail" />
<collection property="attachmentList" column="biz_id" javaType="java.util.List" ofType="Attachment" select="selectAttachmentByBizId" />
</resultMap>
<resultMap id="fundMainResult" type="FundMain">
<id property="mainId" column="main_id"/>
<id property="headId" column="head_id"/>
<id property="title" column="title"/>
<id property="status" column="status"/>
<id property="statusName" column="status_name"/>
<id property="bizId" column="biz_id"/>
<id property="paySum" column="pay_sum"/>
<id property="deptId" column="dept_id"/>
<id property="deptName" column="dept_name"/>
<id property="applyDate" column="apply_date"/>
<id property="applyBy" column="apply_by"/>
<id property="approvalDate" column="approval_date"/>
<id property="remark" column="remark"/>
</resultMap>
<resultMap id="fundDetailResult" type="FundDetail">
<id property="id" column="id"/>
<id property="mainId" column="main_id"/>
<id property="bizId" column="biz_id"/>
<id property="payNo" column="pay_no"/>
<id property="title" column="title"/>
<id property="approval" column="approval"/>
<id property="hasPay" column="has_pay"/>
<id property="waitForPay" column="wait_for_pay"/>
<id property="approvalForPay" column="approval_for_pay"/>
<id property="itemClass" column="item_class"/>
<id property="itemClassName" column="item_class_name"/>
<id property="applyDate" column="apply_date"/>
<id property="delFlag" column="del_flag"/>
<id property="status" column="status"/>
<id property="statusName" column="status_name"/>
<result property="createTime" column="create_time"/>
<result property="createBy" column="create_by"/>
<result property="updateTime" column="update_time"/>
<result property="updateBy" column="update_by"/>
</resultMap>
<sql id="selectPurchaseVo" >
select
p.biz_id,
p.head_id,
p.id,
p.pay_no,
p.title,
p.class_full_name,
p.charge_dept_name,
p.apply,
p.approval,
p.has_pay,
p.wait_for_pay,
p.status,
p.status_name,
p.item_class,
p.item_class_name,
p.dept_id,
p.dept_name,
p.area_name,
p.apply_date,
p.apply_by,
p.approval_date,
p.is_from_old,
p.explain,
p.detail,
p.remark
from ta_purchase_pay p
</sql>
<!-- <sql id="selectNodeVo">-->
<!-- select n. from node n-->
<!-- </sql>-->
<select id="selectFundMain" resultMap="fundMainResult">
select m.main_id,m.head_id,m.title,m.status,m.status_name,m.biz_id,m.pay_sum,m.dept_id,m.dept_name,m.apply_date,m.apply_by,m.approval_date,m.remark
from ta_purchase_pay p join ta_fund_main m on p.biz_id = m.biz_id where p.biz_id = #{bizId}
</select>
<select id="selectFundDetail" resultMap="fundDetailResult">
select d.id,d.main_id,d.biz_id,d.pay_no,d.title,d.approval,d.has_pay,d.wait_for_pay,d.approval_for_pay,d.item_class,d.item_class_name,
d.apply_date,d.status,d.status_name,d.del_flag,d.create_time,d.create_by,d.update_time,d.update_by
from ta_purchase_pay p join ta_fund_detail d on p.biz_id = d.biz_id left join ta_fund_main m on d.main_id = m.main_id where p.biz_id = #{bizId} and d.del_flag = '0'
</select>
<select id="selectAttachmentByBizId" resultType="Attachment">
select attachment_id,attachment_name,url,create_by,create_time,update_by,update_time,process_id,path,final_path,attachment_type from zjwjsb_attachment where process_id = #{bizId}
</select>
<select id="ifPurchaseExist" resultType="int" parameterType="String">
select count(1) from ta_purchase_pay where biz_id = #{bizId}
</select>
<update id="updatePurchase" parameterType="Purchase">
update ta_purchase_pay
<set>
<if test="headId != null and headId != ''">head_id = #{headId},</if>
<if test="id != null and id!= ''">id = #{id},</if>
<if test="payNo != null and payNo != ''">pay_no = #{payNo}, </if>
<if test="title != null and title != ''">title = #{title}, </if>
<if test="classFullName != null and classFullName != ''">class_full_name = #{classFullName}, </if>
<if test="chargeDeptName != null and chargeDeptName != ''">charge_dept_name = #{chargeDeptName}, </if>
<if test="apply != null">apply = #{apply}, </if>
<if test="approval != null">approval = #{approval}, </if>
<if test="hasPay != null">has_pay = #{hasPay}, </if>
<if test="waitForPay != null">wait_for_pay = #{waitForPay},</if>
<if test="status != null">`status` = #{status},</if>
<if test="statusName != null and statusName != ''">status_name = #{statusName},</if>
<if test="itemClass != null">item_class = #{itemClass}, </if>
<if test="itemClassName != null and itemClassName != ''">item_class_name = #{itemClassName}, </if>
<if test="deptId != null and deptId != ''">dept_id = #{deptId}, </if>
<if test="deptName != null and deptName != ''">dept_name = #{deptName}, </if>
<if test="areaName != null and areaName != ''">area_name = #{areaName}, </if>
<if test="applyDate != null">apply_date = #{applyDate, jdbcType=TIMESTAMP}, </if>
<if test="applyBy != null and applyBy != ''">apply_by = #{applyBy}, </if>
<if test="approvalDate != null">approval_date = #{approvalDate, jdbcType=TIMESTAMP}, </if>
<if test="isFromOld != null and isFromOld != ''">is_from_old = #{isFromOld}, </if>
<if test="explain != null and explain != ''">`explain` = #{explain}, </if>
<if test="detail != null and detail != ''">detail = #{detail}, </if>
<if test="remark != null and remark != ''">remark = #{remark}, </if>
</set>
where biz_id = #{bizId}
</update>
<insert id="insertPurchase" parameterType="Purchase">
insert into ta_purchase_pay(
<trim suffix="" suffixOverrides=",">
<if test="bizId != null and bizId != ''">biz_id,</if>
<if test="headId != null and headId != ''">head_id,</if>
<if test="id != null and id!= ''">id,</if>
<if test="payNo != null and payNo != ''">pay_no, </if>
<if test="title != null and title != ''">title, </if>
<if test="classFullName != null and classFullName != ''">class_full_name, </if>
<if test="chargeDeptName != null and chargeDeptName != ''">charge_dept_name, </if>
<if test="apply != null">apply, </if>
<if test="approval != null">approval, </if>
<if test="hasPay != null">has_pay, </if>
<if test="waitForPay != null">wait_for_pay,</if>
<if test="status != null">`status`,</if>
<if test="statusName != null and statusName != ''">status_name,</if>
<if test="itemClass != null">item_class, </if>
<if test="itemClassName != null and itemClassName != ''">item_class_name, </if>
<if test="deptId != null and deptId != ''">dept_id, </if>
<if test="deptName != null and deptName != ''">dept_name, </if>
<if test="areaName != null and areaName != ''">area_name, </if>
<if test="applyDate != null">apply_date, </if>
<if test="applyBy != null and applyBy != ''">apply_by, </if>
<if test="approvalDate != null">approval_date, </if>
<if test="isFromOld != null">is_from_old, </if>
<if test="explain != null and explain != ''">`explain`, </if>
<if test="detail != null and detail != ''">detail, </if>
<if test="remark != null and remark != ''">remark, </if>
</trim>
) values(
<trim suffix="" suffixOverrides=",">
<if test="bizId != null and bizId != ''">#{bizId},</if>
<if test="headId != null and headId != ''">#{headId},</if>
<if test="id != null and id!= ''">#{id},</if>
<if test="payNo != null and payNo != ''">#{payNo}, </if>
<if test="title != null and title != ''">#{title}, </if>
<if test="classFullName != null and classFullName != ''">#{classFullName}, </if>
<if test="chargeDeptName != null and chargeDeptName != ''">#{chargeDeptName}, </if>
<if test="apply != null">#{apply}, </if>
<if test="approval != null">#{approval}, </if>
<if test="hasPay != null">#{hasPay}, </if>
<if test="waitForPay != null">#{waitForPay},</if>
<if test="status != null">#{status},</if>
<if test="statusName != null and statusName != ''">#{statusName},</if>
<if test="itemClass != null">#{itemClass}, </if>
<if test="itemClassName != null and itemClassName != ''">#{itemClassName}, </if>
<if test="deptId != null and deptId != ''">#{deptId}, </if>
<if test="deptName != null and deptName != ''">#{deptName}, </if>
<if test="areaName != null and areaName != ''">#{areaName}, </if>
<if test="applyDate != null">#{applyDate, jdbcType=TIMESTAMP}, </if>
<if test="applyBy != null and applyBy != ''">#{applyBy}, </if>
<if test="approvalDate != null"> #{approvalDate, jdbcType=TIMESTAMP}, </if>
<if test="isFromOld != null">#{isFromOld}, </if>
<if test="explain != null and explain != ''">#{explain}, </if>
<if test="detail != null and detail != ''">#{detail}, </if>
<if test="remark != null and remark != ''">#{remark}, </if>
</trim>
)
</insert>
<select id="selectPurchaseList" parameterType="Purchase" resultMap="purchaseResult">
<include refid="selectPurchaseVo"/>
where p.del_flag = '0'
<if test="itemClass != null">
and p.item_class = #{itemClass}
</if>
<if test="bizId != null and bizId != ''">
and p.biz_id = #{bizId}
</if>
<if test="headId != null and headId != ''">
and p.head_id like concat('%',#{headId},'%')
</if>
<if test="title != null and title != ''">
and p.title like concat('%',#{title},'%')
</if>
<if test="deptName != null and deptName != ''">
and p.dept_name like concat('%',#{deptName},'%')
</if>
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
AND date_format(p.apply_date,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
</if>
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
AND date_format(p.apply_date,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
</if>
${params.dataScope}
order by p.apply_date desc
</select>
<update id="changePurchaseStatusByHeadId" parameterType="Purchase">
update ta_purchase_pay set status = #{status} where head_id = #{headId}
</update>
<update id="deletePurchaseById" parameterType="String">
update ta_purchase_pay set del_flag = '1' where biz_id = #{bizId}
</update>
<select id="selectPurchaseByHeadId" parameterType="String" resultMap="purchaseResult">
<include refid="selectPurchaseVo"/> where head_id = #{headId}
</select>
<select id="selectPurchaseByBizId" parameterType="String" resultMap="purchaseResult">
<include refid="selectPurchaseVo"/> where biz_id = #{bizId}
</select>
</mapper>