|
@@ -0,0 +1,188 @@
|
|
1
|
+<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
3
|
+
|
|
4
|
+<mapper namespace="com.oqpo.api.mapper.pomng.PchReqMapper">
|
|
5
|
+
|
|
6
|
+ <select id="selectPchReqGridList" resultType="com.oqpo.api.entity.pomng.PchReqBaseInfoEntity">
|
|
7
|
+ select /* PchReq.selectPchReqGridList */
|
|
8
|
+ pch_req_unq_no, brand_id, fn_brand_nm(brand_id) as brand_nm, pch_req_nm
|
|
9
|
+ ,pch_req_st_cd, fn_code_nm('PCH_REQ_ST_Cd',pch_req_st_cd) as pch_req_st_nm
|
|
10
|
+ , pch_req_mgr_nm, date_format(dlv_req_dt,'%Y.%m.%d') as dlv_req_dt, pch_req_total_amt
|
|
11
|
+ ,pch_req_item_qty, date_format(pch_req_rjct_dt,'%Y.%m.%d') as pch_req_rjct_dt, pch_req_rjct_nm
|
|
12
|
+ ,whs_id, fn_whs_nm(brand_id, whs_id) as whs_nm
|
|
13
|
+ ,location, fn_whs_location_nm(brand_id, whs_id, location) as location_nm
|
|
14
|
+ from pch_req_base_info
|
|
15
|
+ where brand_id = #{sBrandId}
|
|
16
|
+ and date_format(sys_reg_dttm,'%Y%m%d') between #{fromDt} and #{toDt}
|
|
17
|
+ <if test="sWhsId != null and sWhsId != ''">
|
|
18
|
+ and whs_id = #{sWhsId}
|
|
19
|
+ </if>
|
|
20
|
+ <if test="sPchReqStCd != null and sPchReqStCd != ''">
|
|
21
|
+ and pch_req_st_cd = #{sPchReqStCd}
|
|
22
|
+ </if>
|
|
23
|
+ <if test="sItemNm != null and sItemNm != ''">
|
|
24
|
+ and pch_req_unq_no in ( select pch_req_unq_no from pch_req_dtl_ptcl
|
|
25
|
+ where date_format(sys_reg_dttm,'%Y%m%d') between #{fromDt} and #{toDt})
|
|
26
|
+ and item_id like concat('%',#{sItemNm},'%') or item_nm like concat('%',#{sItemNm},'%')
|
|
27
|
+ </if>
|
|
28
|
+ <choose>
|
|
29
|
+ <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
|
|
30
|
+ <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
|
|
31
|
+ <if test="gridRequest.sord == 'asc'.toString()">
|
|
32
|
+ order by pch_req_unq_no asc
|
|
33
|
+ </if>
|
|
34
|
+ <if test="gridRequest.sord == 'desc'.toString()">
|
|
35
|
+ order by pch_req_unq_no desc
|
|
36
|
+ </if>
|
|
37
|
+ </if>
|
|
38
|
+ </when>
|
|
39
|
+ <otherwise>
|
|
40
|
+ order by pch_req_unq_no desc
|
|
41
|
+ </otherwise>
|
|
42
|
+ </choose>
|
|
43
|
+ <if test="gridRequest.pagingYn == true">
|
|
44
|
+ limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
|
|
45
|
+ </if>
|
|
46
|
+ </select>
|
|
47
|
+
|
|
48
|
+ <select id="selectPchReqGridCnt" resultType="int">
|
|
49
|
+ select count(*) as cnt
|
|
50
|
+ from pch_req_base_info
|
|
51
|
+ where brand_id = #{sBrandId}
|
|
52
|
+ and date_format(sys_reg_dttm,'%Y%m%d') between #{fromDt} and #{toDt}
|
|
53
|
+ <if test="sWhsId != null and sWhsId != ''">
|
|
54
|
+ and whs_id = #{sWhsId}
|
|
55
|
+ </if>
|
|
56
|
+ <if test="sPchReqStCd != null and sPchReqStCd != ''">
|
|
57
|
+ and pch_req_st_cd = #{sPchReqStCd}
|
|
58
|
+ </if>
|
|
59
|
+ <if test="sItemNm != null and sItemNm != ''">
|
|
60
|
+ and pch_req_unq_no in ( select pch_req_unq_no from pch_req_dtl_ptcl
|
|
61
|
+ where date_format(sys_reg_dttm,'%Y%m%d') between #{fromDt} and #{toDt})
|
|
62
|
+ and item_id like concat('%',#{sItemNm},'%') or item_nm like concat('%',#{sItemNm},'%')
|
|
63
|
+ </if>
|
|
64
|
+ </select>
|
|
65
|
+
|
|
66
|
+ <select id="selectPchReqInfo" resultType="com.oqpo.api.entity.pomng.PchReqBaseInfoEntity">
|
|
67
|
+ SELECT pch_req_unq_no, brand_id, fn_brand_nm(brand_id) as brand_nm, store_id, pch_req_nm, pch_req_dept
|
|
68
|
+ , pch_req_mgr_nm, DATE_FORMAT(pch_req_dt,'%Y.%m.%d') as pch_req_dt, pch_req_st_cd, fn_code_nm('PCH_REQ_ST_CD', pch_req_st_cd ) AS pch_req_st_nm, pch_req_dvsn
|
|
69
|
+ , note, pch_req_item_qty, pch_req_total_amt, DATE_FORMAT(pch_req_rjct_dt,'%Y.%m.%d') as pch_req_rjct_dt, pch_req_rjct_nm
|
|
70
|
+ , pch_req_rjct_rsn, pch_req_mgr_id, pch_req_rjct_id
|
|
71
|
+ ,whs_id, fn_whs_nm(brand_id, whs_id) as whs_nm
|
|
72
|
+ ,location, fn_whs_location_nm(brand_id, whs_id, location) as location_nm
|
|
73
|
+ , DATE_FORMAT(dlv_req_dt ,'%Y.%m.%d') as dlv_req_dt
|
|
74
|
+ , DATE_FORMAT(sys_reg_dttm,'%Y.%m.%d %H:%i:%s') AS sys_reg_dttm, sys_reg_id, DATE_FORMAT(sys_chg_dttm,'%Y.%m.%d %H:%i:%s') AS sys_chg_dttm, sys_chg_id
|
|
75
|
+ FROM pch_req_base_info
|
|
76
|
+ WHERE brand_id = #{brandId}
|
|
77
|
+ and pch_req_unq_no = #{pchReqUnqNo}
|
|
78
|
+ </select>
|
|
79
|
+
|
|
80
|
+ <select id="selectPchReqDtlPtcl" resultType="com.oqpo.api.entity.pomng.PchReqDtlPtclEntity">
|
|
81
|
+ SELECT pch_req_unq_no, pch_req_dtl_no, item_id, item_nm, unit, fn_code_nm('DSTRBT_COST_UNIT',unit) AS unit_nm
|
|
82
|
+ , pch_req_qty, pch_req_amt, unit_amt
|
|
83
|
+ FROM pch_req_dtl_ptcl
|
|
84
|
+ WHERE pch_req_unq_no = #{pchReqUnqNo}
|
|
85
|
+ </select>
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+ <insert id="insertPchReqBaseInfo" >
|
|
89
|
+ INSERT INTO /* PchReq.insertPchReqBaseInfo */ pch_req_base_info
|
|
90
|
+ (pch_req_unq_no, brand_id, store_id, pch_req_nm, pch_req_dept
|
|
91
|
+ , pch_req_mgr_nm, pch_req_dt, pch_req_tm, pch_req_st_cd, pch_req_dvsn
|
|
92
|
+ , note, pch_req_item_qty, pch_req_total_amt, pch_req_rjct_dt, pch_req_rjct_nm
|
|
93
|
+ , pch_req_rjct_rsn, pch_req_mgr_id, pch_req_rjct_id
|
|
94
|
+ , whs_id, location,dlv_req_dt
|
|
95
|
+ , sys_reg_dttm, sys_reg_id, sys_chg_dttm, sys_chg_id)
|
|
96
|
+ VALUES
|
|
97
|
+ (#{entity.pchReqUnqNo}, #{entity.brandId}, #{entity.storeId}, #{entity.pchReqNm}, null
|
|
98
|
+ , #{userNm}, #{entity.pchReqDt}, null, #{entity.pchReqStCd}, null
|
|
99
|
+ , #{entity.note}, #{entity.pchReqItemQty}, #{entity.pchReqTotalAmt}, null, null
|
|
100
|
+ , null, #{userId}, null
|
|
101
|
+ , #{entity.whsId}, #{entity.location}, #{entity.dlvReqDt}
|
|
102
|
+ , NOW(), #{userId}, NOW(), #{userId})
|
|
103
|
+ </insert>
|
|
104
|
+
|
|
105
|
+ <update id="updateOrdPchReqBaseInfo">
|
|
106
|
+ UPDATE /* PchReq.updateOrdPchReqBaseInfo */
|
|
107
|
+ pch_req_base_info SET
|
|
108
|
+ pch_req_dt = #{entity.pchReqDt},
|
|
109
|
+ pch_req_st_cd = #{entity.pchReqStCd},
|
|
110
|
+ note = #{entity.note},
|
|
111
|
+ pch_req_item_qty = #{entity.pchReqItemQty},
|
|
112
|
+ pch_req_total_amt = #{entity.pchReqTotalAmt},
|
|
113
|
+ whs_id = #{entity.whsId},
|
|
114
|
+ location = #{entity.location},
|
|
115
|
+ dlv_req_dt = #{entity.dlvReqDt},
|
|
116
|
+ sys_chg_dttm = NOW(),
|
|
117
|
+ sys_chg_id = #{userId}
|
|
118
|
+ WHERE brand_id = #{entity.brandId}
|
|
119
|
+ and pch_req_unq_no = #{entity.pchReqUnqNo}
|
|
120
|
+ </update>
|
|
121
|
+
|
|
122
|
+ <update id="updateRejPchReqBaseInfo">
|
|
123
|
+ UPDATE /* PchReq.updateOrdPchReqBaseInfo */
|
|
124
|
+ pch_req_base_info SET
|
|
125
|
+ pch_req_rjct_nm = #{entity.pchReqRjctNm},
|
|
126
|
+ pch_req_rjct_dt = date_format(noew(),'%Y%m%d'),
|
|
127
|
+ pch_req_rjct_rsn = #{entity.pchReqRjctRsn},
|
|
128
|
+ pch_req_rjct_id = #{userId},
|
|
129
|
+ sys_chg_dttm = NOW(),
|
|
130
|
+ sys_chg_id = #{userId}
|
|
131
|
+ WHERE pch_req_unq_no = #{entity.pchReqUnqNo}
|
|
132
|
+ </update>
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+ <insert id="insertPchReqDtlPtcl" >
|
|
136
|
+ INSERT INTO /* PchReq.insertPchReqDtlPtcl */ pch_req_dtl_ptcl
|
|
137
|
+ (pch_req_unq_no, pch_req_dtl_no, item_nm, unit, pch_req_qty
|
|
138
|
+ , pch_req_amt, unit_amt
|
|
139
|
+ , item_id, sys_reg_dttm, sys_reg_id, sys_chg_dttm, sys_chg_id)
|
|
140
|
+ VALUES
|
|
141
|
+ <foreach collection="gridInsertData" item="item" separator=",">
|
|
142
|
+ (#{item.pchReqUnqNo}, #{item.pchReqDtlNo}, #{item.itemNm}, #{item.unit}, #{item.pchReqQty}
|
|
143
|
+ , #{item.pchReqAmt}, #{item.unitAmt}
|
|
144
|
+ , #{item.itemId} , NOW(), #{userId}, NOW(), #{userId})
|
|
145
|
+ </foreach>
|
|
146
|
+
|
|
147
|
+ </insert>
|
|
148
|
+
|
|
149
|
+ <update id="updatePchReqDtlPtcl">
|
|
150
|
+ <foreach collection="gridUpdateData" item="item" separator=";">
|
|
151
|
+ UPDATE /* PchReq.updatePchReqDtlPtcl */
|
|
152
|
+ pch_req_dtl_ptcl SET
|
|
153
|
+ unit = #{item.unit},
|
|
154
|
+ pch_req_qty = #{item.pchReqQty},
|
|
155
|
+ pch_req_amt = #{item.pchReqAmt},
|
|
156
|
+ unit_amt = #{item.unitAmt},
|
|
157
|
+ sys_chg_dttm = NOW(),
|
|
158
|
+ sys_chg_id = #{userId}
|
|
159
|
+ WHERE pch_req_unq_no = #{pchReqUnqNo}
|
|
160
|
+ AND pch_req_dtl_no = #{item.pchReqDtlNo}
|
|
161
|
+ </foreach>
|
|
162
|
+ </update>
|
|
163
|
+
|
|
164
|
+ <delete id="deletePchReqDtlPtcl">
|
|
165
|
+ DELETE /* PchReq.deletePchReqDtlPtcl */
|
|
166
|
+ FROM pch_req_dtl_ptcl
|
|
167
|
+ WHERE pch_req_unq_no = #{pchReqUnqNo}
|
|
168
|
+ and pch_req_dtl_no in
|
|
169
|
+ <foreach collection="gridDeleteData" item="item" separator="," open="(" close=")">
|
|
170
|
+ #{item.pchReqDtlNo}
|
|
171
|
+ </foreach>
|
|
172
|
+
|
|
173
|
+ </delete>
|
|
174
|
+
|
|
175
|
+ <select id="selectMaxPchReqDtlNo" resultType="int">
|
|
176
|
+ SELECT nvl(Max(convert(conpch_req_dtl_no,int)),10)
|
|
177
|
+ FROM pch_req_dtl_ptcl
|
|
178
|
+ WHERE pch_req_unq_no = #{pchReqUnqNo}
|
|
179
|
+ </select>
|
|
180
|
+
|
|
181
|
+ <select id="selectSumReqAmt" resultType="int">
|
|
182
|
+ select nvl(sum(pch_req_amt),0) as pch_req_amt
|
|
183
|
+ from pch_req_dtl_ptcl
|
|
184
|
+ where pch_req_unq_no = #{pchReqUnqNo}
|
|
185
|
+ </select>
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+</mapper>
|