RtnReq.xml 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  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. <mapper namespace="com.oqpo.api.mapper.rtnmng.RtnReqMapper">
  4. <insert id="insertRtnReqBaseInfo" >
  5. INSERT INTO rtn_req_base_info /* RtnReqMapper.insertRtnReqBaseInfo */
  6. (rtn_req_unq_no, store_id, brand_id, rtn_req_dt, rtn_req_tm
  7. , rtn_req_st_cd, rtn_req_mgr_id, rtn_req_mgr_nm, rtn_req_mgr_tel_no
  8. , whs_dvsn, col_req_dt, note, rtn_rjct_dt, rtn_rjct_nm
  9. , rtn_rjct_id, rtn_rjct_rsn, rtn_req_amt, rtn_req_item_qty, rtn_whs_id, rtn_location
  10. , sys_reg_dttm, sys_reg_id, sys_chg_dttm, sys_chg_id)
  11. VALUES
  12. (#{entity.rtnReqUnqNo}, #{entity.storeId}, #{entity.brandId}, case when #{entity.rtnReqStCd} = 'RR20' then date_format(now(),'%Y%m%d') else null end , #{entity.rtnReqTm}
  13. , #{entity.rtnReqStCd}, #{userId}, #{entity.rtnReqMgrNm}, #{entity.rtnReqMgrTelNo}
  14. , #{entity.whsDvsn}, #{entity.colReqDt}, #{entity.note}, #{entity.rtnRjctDt}, #{entity.rtnRjctNm}
  15. , #{entity.rtnRjctId}, #{entity.rtnRjctRsn}, #{entity.rtnReqAmt}, #{entity.rtnReqItemQty}, #{entity.rtnWhsId}, #{entity.rtnLocation}
  16. , NOW(), #{userId}, NOW(), #{userId})
  17. </insert>
  18. <update id="updateRtnReqBaseInfo">
  19. UPDATE rtn_req_base_info SET /* RtnReqMapper.updateRtnReqBaseInfo */
  20. rtn_req_dt = case when #{entity.rtnReqStCd} = 'RR20' then date_format(now(),'%Y%m%d') else null end,
  21. rtn_req_tm = #{entity.rtnReqTm},
  22. rtn_req_st_cd = #{entity.rtnReqStCd},
  23. whs_dvsn = #{entity.whsDvsn},
  24. col_req_dt = #{entity.colReqDt},
  25. note = #{entity.note},
  26. rtn_req_amt = #{entity.rtnReqAmt},
  27. rtn_req_item_qty = #{entity.rtnReqItemQty},
  28. rtn_whs_id = #{entity.rtnWhsId},
  29. rtn_location = #{entity.rtnLocation},
  30. sys_chg_dttm = NOW(),
  31. sys_chg_id = #{userId}
  32. WHERE rtn_req_unq_no = #{entity.rtnReqUnqNo}
  33. AND brand_id = #{entity.brandId}
  34. </update>
  35. <insert id="insertRtnReqDtlPtcl" >
  36. INSERT INTO rtn_req_dtl_ptcl /* RtnReqMapper.insertRtnReqDtlPtcl */
  37. (rtn_req_unq_no, rtn_req_dtl_no, item_id, item_nm, unit
  38. , rtn_qty, rtn_amt, rtn_dvsn, rtn_rsn
  39. , spply_id, unit_amt, store_unit_unq_no, brand_unit_unq_no, rtn_rsn_dvsn, unit_gubun
  40. , sys_reg_dttm, sys_reg_id, sys_chg_dttm, sys_chg_id)
  41. VALUES
  42. <foreach collection="gridInsertData" item="item" separator=",">
  43. (#{item.rtnReqUnqNo}, #{item.rtnReqDtlNo}, #{item.itemId}, #{item.itemNm}, #{item.unit}
  44. , #{item.rtnQty}, #{item.rtnAmt}, #{item.rtnDvsn}, #{item.rtnRsn}
  45. , #{item.spplyId}, #{item.unitAmt}, #{item.storeUnitUnqNo}, #{item.brandUnitUnqNo}, #{item.rtnRsnDvsn}, #{unitGubun}
  46. , NOW(), #{userId}, NOW(), #{userId})
  47. </foreach>
  48. </insert>
  49. <update id="updateRtnReqDtlPtcl">
  50. <foreach collection="gridUpdateData" item="item" separator=";">
  51. UPDATE rtn_req_dtl_ptcl SET /* RtnReqMapper.updateRtnReqDtlPtcl */
  52. rtn_qty = #{item.rtnQty},
  53. rtn_amt = #{item.rtnAmt},
  54. rtn_dvsn = #{item.rtnDvsn},
  55. rtn_rsn = #{item.rtnRsn},
  56. rtn_rsn_dvsn = #{item.rtnRsnDvsn},
  57. sys_chg_dttm = NOW(),
  58. sys_chg_id = #{userId}
  59. WHERE rtn_req_unq_no = #{item.rtnReqUnqNo}
  60. AND rtn_req_dtl_no = #{item.rtnReqDtlNo}
  61. </foreach>
  62. </update>
  63. <delete id="deleteRtnReqDtlPtcl">
  64. DELETE FROM rtn_req_dtl_ptcl /* RtnReqMapper.deleteRtnReqDtlPtcl */
  65. WHERE rtn_req_unq_no = #{rtnReqUnqNo}
  66. AND rtn_req_dtl_no in
  67. <foreach collection="gridDeleteData" item="item" separator="," open="(" close=")">
  68. #{item.rtnReqDtlNo}
  69. </foreach>
  70. </delete>
  71. <select id="selectMaxRtnReqDtlNo" resultType="int">
  72. SELECT nvl(Max(convert(rtn_req_dtl_no,int)),0)
  73. FROM rtn_req_dtl_ptcl
  74. WHERE rtn_req_unq_no = #{rtnReqUnqNo}
  75. </select>
  76. <select id="selectSumRtnAmt" resultType="com.oqpo.api.entity.rtnmng.RtnReqBaseInfoEntity">
  77. select count(*) as rtn_req_item_qty, nvl(sum(rtn_amt),0) as rtn_req_amt
  78. from rtn_req_dtl_ptcl
  79. where rtn_req_unq_no = #{rtnReqUnqNo}
  80. </select>
  81. <select id="selectRtnReqGridList" resultType="com.oqpo.api.entity.rtnmng.RtnReqBaseInfoEntity">
  82. select base.brand_id, fn_brand_nm(base.brand_id) as brand_nm
  83. ,base.store_id , fn_store_nm(base.brand_id, base.store_id) as store_nm
  84. , base.rtn_req_unq_no
  85. , base.rtn_req_st_cd, fn_code_nm(upper('rtn_req_st_cd'), base.rtn_req_st_cd) as rtn_req_st_nm
  86. , base.rtn_whs_id, base.rtn_location, fn_whs_nm(base.brand_id, base.rtn_whs_id) as rtn_whs_nm
  87. , fn_whs_location_nm(base.brand_id, base.rtn_whs_id, base.rtn_location) as rtn_location_nm
  88. , date_format(base.rtn_req_dt, '%Y.%m.%d') as rtn_req_dt, base.rtn_req_item_qty, base.rtn_req_amt
  89. , date_format(base.col_req_dt, '%Y.%m.%d') as col_req_dt, base.rtn_req_mgr_nm, base.rtn_req_mgr_id
  90. , date_format(base.rtn_rjct_dt, '%Y.%m.%d') as rtn_rjct_dt, base.rtn_rjct_nm
  91. from rtn_req_base_info base
  92. where 1 = 1
  93. and base.brand_id = #{sBrandId}
  94. and base.col_req_dt between #{fromDt} and #{toDt}
  95. <if test="sStoreId != null and sStoreId != ''">
  96. and base.store_id = #{sStoreId}
  97. </if>
  98. <if test="sWhsId != null and sWhsId != ''">
  99. and base.rtn_whs_id = #{sWhsId}
  100. </if>
  101. <if test="sRtnReqStCd != null and sRtnReqStCd != ''">
  102. and base.rtn_req_st_cd = #{sRtnReqStCd}
  103. </if>
  104. <if test="sItemNm != null and sItemNm != ''">
  105. and base.rtn_req_unq_no in (select ptcl.rtn_req_unq_no
  106. from rtn_req_base_info sbase,
  107. rtn_req_dtl_ptcl ptcl
  108. where sbase.rtn_req_unq_no = ptcl.rtn_req_unq_no
  109. and sbase.brand_id = #{sBrandId}
  110. and sbase.col_req_dt between #{fromDt} and #{toDt}
  111. <if test="sStoreId != null and sStoreId != ''">
  112. and sbase.store_id = #{sStoreId}
  113. </if>
  114. <if test="sWhsId != null and sWhsId != ''">
  115. and sbase.rtn_whs_id = #{sWhsId}
  116. </if>
  117. <if test="sRtnReqStCd != null and sRtnReqStCd != ''">
  118. and sbase.rtn_req_st_cd = #{sRtnReqStCd}
  119. </if>
  120. and (ptcl.item_id like concat('%', #{sItemNm}, '%') or ptcl.item_nm like concat('%', #{sItemNm}, '%')) )
  121. </if>
  122. <choose>
  123. <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
  124. <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
  125. <if test="gridRequest.sord == 'asc'.toString()">
  126. order by base.rtn_req_unq_no asc
  127. </if>
  128. <if test="gridRequest.sord == 'desc'.toString()">
  129. order by base.rtn_req_unq_no desc
  130. </if>
  131. </if>
  132. </when>
  133. <otherwise>
  134. order by base.rtn_req_unq_no desc
  135. </otherwise>
  136. </choose>
  137. <if test="gridRequest.pagingYn == true">
  138. limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
  139. </if>
  140. </select>
  141. <select id="selectRtnReqGridCnt" resultType="int">
  142. select count(*)
  143. from rtn_req_base_info base
  144. where 1 = 1
  145. and base.brand_id = #{sBrandId}
  146. and base.col_req_dt between #{fromDt} and #{toDt}
  147. <if test="sStoreId != null and sStoreId != ''">
  148. and base.store_id = #{sStoreId}
  149. </if>
  150. <if test="sWhsId != null and sWhsId != ''">
  151. and base.rtn_whs_id = #{sWhsId}
  152. </if>
  153. <if test="sRtnReqStCd != null and sRtnReqStCd != ''">
  154. and base.rtn_req_st_cd = #{sRtnReqStCd}
  155. </if>
  156. <if test="sItemNm != null and sItemNm != ''">
  157. and base.rtn_req_unq_no in (select ptcl.rtn_req_unq_no
  158. from rtn_req_base_info sbase,
  159. rtn_req_dtl_ptcl ptcl
  160. where sbase.rtn_req_unq_no = ptcl.rtn_req_unq_no
  161. and sbase.brand_id = #{sBrandId}
  162. and sbase.col_req_dt between #{fromDt} and #{toDt}
  163. <if test="sStoreId != null and sStoreId != ''">
  164. and sbase.store_id = #{sStoreId}
  165. </if>
  166. <if test="sWhsId != null and sWhsId != ''">
  167. and sbase.rtn_whs_id = #{sWhsId}
  168. </if>
  169. <if test="sRtnReqStCd != null and sRtnReqStCd != ''">
  170. and sbase.rtn_req_st_cd = #{sRtnReqStCd}
  171. </if>
  172. and (ptcl.item_id like concat('%', #{sItemNm}, '%') or ptcl.item_nm like concat('%', #{sItemNm}, '%')) )
  173. </if>
  174. </select>
  175. <select id="selectRtnReqInfo" resultType="com.oqpo.api.entity.rtnmng.RtnReqBaseInfoEntity">
  176. SELECT rtn_req_unq_no, brand_id, fn_brand_nm(brand_id) as brand_nm
  177. , store_id, fn_store_nm(brand_id, store_id) as store_nm
  178. , date_format(rtn_req_dt,'%Y.%m.%d') as rtn_req_dt, rtn_req_st_cd, fn_code_nm('RTN_REQ_ST_Cd',rtn_req_st_cd) as rtn_req_st_nm
  179. , rtn_req_mgr_id, rtn_req_mgr_nm, whs_dvsn, fn_code_nm('WHS_DVSN',whs_dvsn) as whs_dvsn_nm
  180. , date_format(col_req_dt,'%Y.%m.%d') as col_req_dt, note, date_format(rtn_rjct_dt,'%Y.%m.%d') as rtn_rjct_dt, rtn_rjct_nm, rtn_rjct_id
  181. , rtn_rjct_rsn, rtn_req_amt, rtn_req_item_qty
  182. , rtn_whs_id, fn_whs_nm(brand_id, rtn_whs_id) as rtn_whs_nm
  183. , rtn_location, fn_whs_location_nm(brand_id, rtn_whs_id, rtn_location) as rtn_location_nm
  184. , date_format(sys_reg_dttm,'%Y.%m.%d') AS sys_reg_dttm, sys_reg_id, date_format(sys_chg_dttm,'%Y.%m.%d') AS sys_chg_dttm, sys_chg_id
  185. FROM rtn_req_base_info
  186. WHERE 1=1
  187. AND brand_id = #{brandId}
  188. <if test="storeId != null and storeId != ''">
  189. and store_id = #{storeId}
  190. </if>
  191. AND rtn_req_unq_no = #{rtnReqUnqNo}
  192. </select>
  193. <select id="selectRtnReqDtlList" resultType="com.oqpo.api.entity.rtnmng.RtnReqDtlPtclEntity">
  194. SELECT rtn_req_unq_no, rtn_req_dtl_no, item_id, item_nm, unit
  195. , rtn_qty, rtn_amt, rtn_dvsn, fn_code_nm('RTN_DVSN',rtn_dvsn) as rtn_dvsn_nm
  196. , rtn_rsn, spply_id
  197. , unit_amt, store_unit_unq_no, brand_unit_unq_no, rtn_rsn_dvsn, fn_code_nm('RTN_RSN_DVSN',rtn_rsn_dvsn) as rtn_rsn_dvsn_nm
  198. , unit_gubun, fn_code_nm('UNIT_GUBUN',unit_gubun) as unit_gubun_nm
  199. FROM rtn_req_dtl_ptcl
  200. WHERE rtn_req_unq_no = #{rtnReqUnqNo}
  201. </select>
  202. <!--
  203. <select id="selectPchReqGridCnt" resultType="int">
  204. select count(*) as cnt
  205. from pch_req_base_info
  206. where brand_id = #{sBrandId}
  207. <if test="sStoreId != null and sStoreId != ''">
  208. and store_id = #{sStoreId}
  209. </if>
  210. and date_format(sys_reg_dttm,'%Y%m%d') between #{fromDt} and #{toDt}
  211. <if test="sWhsId != null and sWhsId != ''">
  212. and whs_id = #{sWhsId}
  213. </if>
  214. <if test="sPchReqStCd != null and sPchReqStCd != ''">
  215. and pch_req_st_cd = #{sPchReqStCd}
  216. </if>
  217. <if test="sItemNm != null and sItemNm != ''">
  218. and pch_req_unq_no in ( select pch_req_unq_no from pch_req_dtl_ptcl
  219. where date_format(sys_reg_dttm,'%Y%m%d') between #{fromDt} and #{toDt})
  220. and item_id like concat('%',#{sItemNm},'%') or item_nm like concat('%',#{sItemNm},'%')
  221. </if>
  222. </select>
  223. <select id="selectPchReqInfo" resultType="com.oqpo.api.entity.pomng.PchReqBaseInfoEntity">
  224. SELECT pch_req_unq_no, brand_id, fn_brand_nm(brand_id) as brand_nm, store_id, pch_req_nm, pch_req_dept
  225. , 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
  226. , 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
  227. , pch_req_rjct_rsn, pch_req_mgr_id, pch_req_rjct_id
  228. ,whs_id, fn_whs_nm(brand_id, whs_id) as whs_nm
  229. ,location, fn_whs_location_nm(brand_id, whs_id, location) as location_nm
  230. , DATE_FORMAT(dlv_req_dt ,'%Y.%m.%d') as dlv_req_dt
  231. , 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
  232. , nvl(pch_appr_amt,0) as pch_appr_amt, case when pch_req_total_amt = pch_appr_amt then 'Y' else 'N' end pch_appr_yn
  233. FROM pch_req_base_info
  234. WHERE brand_id = #{brandId}
  235. and pch_req_unq_no = #{pchReqUnqNo}
  236. </select>
  237. <select id="selectPchReqDtlPtcl" resultType="com.oqpo.api.entity.pomng.PchReqDtlPtclEntity">
  238. SELECT ptcl.pch_req_unq_no, ptcl.pch_req_dtl_no, ptcl.item_id, ptcl.item_nm, ptcl.unit, fn_code_nm('DSTRBT_COST_UNIT',ptcl.unit) AS unit_nm
  239. , ptcl.pch_req_qty, ptcl.pch_req_amt, ptcl.unit_amt, ptcl.brand_unit_unq_no, ptcl.store_unit_unq_no, ptcl.unit_gubun
  240. , odr.podr_dtl_st_cd, fn_code_nm(upper('podr_dtl_st_cd'), odr.podr_dtl_st_cd) as podr_dtl_st_nm
  241. FROM pch_req_dtl_ptcl ptcl
  242. left outer join pch_odr_dtl_ptcl odr on odr.pch_req_unq_no = ptcl.pch_req_unq_no and odr.pch_req_dtl_no = ptcl.pch_req_dtl_no
  243. WHERE ptcl.pch_req_unq_no = #{pchReqUnqNo}
  244. </select>
  245. <insert id="insertPchReqBaseInfo" >
  246. INSERT INTO /* PchReq.insertPchReqBaseInfo */ pch_req_base_info
  247. (pch_req_unq_no, brand_id, store_id, pch_req_nm, pch_req_dept
  248. , pch_req_mgr_nm, pch_req_dt, pch_req_tm, pch_req_st_cd, pch_req_dvsn
  249. , note, pch_req_item_qty, pch_req_total_amt, pch_req_rjct_dt, pch_req_rjct_nm
  250. , pch_req_rjct_rsn, pch_req_mgr_id, pch_req_rjct_id
  251. , whs_id, location,dlv_req_dt
  252. , sys_reg_dttm, sys_reg_id, sys_chg_dttm, sys_chg_id)
  253. VALUES
  254. (#{entity.pchReqUnqNo}, #{entity.brandId}, #{entity.storeId}, #{entity.pchReqNm}, #{entity.pchReqDept}
  255. , #{entity.pchReqMgrNm}, case when #{entity.pchReqStCd} = 'PR20' then date_format(now(),'%Y%m%d') else null end, null, #{entity.pchReqStCd}, #{entity.pchReqDvsn}
  256. , #{entity.note}, #{entity.pchReqItemQty}, #{entity.pchReqTotalAmt}, null, null
  257. , null, #{userId}, null
  258. , #{entity.whsId}, #{entity.location}, #{entity.dlvReqDt}
  259. , NOW(), #{userId}, NOW(), #{userId})
  260. </insert>
  261. <update id="updateOrdPchReqBaseInfo">
  262. UPDATE /* PchReq.updateOrdPchReqBaseInfo */
  263. pch_req_base_info SET
  264. pch_req_dt = case when #{entity.pchReqStCd} = 'PR20' then date_format(now(),'%Y%m%d') else null end ,
  265. pch_req_st_cd = #{entity.pchReqStCd},
  266. note = #{entity.note},
  267. pch_req_item_qty = #{entity.pchReqItemQty},
  268. pch_req_total_amt = #{entity.pchReqTotalAmt},
  269. whs_id = #{entity.whsId},
  270. location = #{entity.location},
  271. dlv_req_dt = #{entity.dlvReqDt},
  272. sys_chg_dttm = NOW(),
  273. sys_chg_id = #{userId}
  274. WHERE brand_id = #{entity.brandId}
  275. and pch_req_unq_no = #{entity.pchReqUnqNo}
  276. </update>
  277. <update id="updateRejPchReqBaseInfo">
  278. UPDATE /* PchReq.updateRejPchReqBaseInfo */
  279. pch_req_base_info SET
  280. pch_req_rjct_nm = #{pchReqRjctNm},
  281. pch_req_rjct_dt = date_format(now(),'%Y%m%d'),
  282. pch_req_rjct_rsn = #{pchReqRjctRsn},
  283. pch_req_rjct_id = #{userId},
  284. sys_chg_dttm = NOW(),
  285. sys_chg_id = #{userId}
  286. WHERE pch_req_unq_no = #{pchReqUnqNo}
  287. </update>
  288. <insert id="insertPchReqDtlPtcl" >
  289. INSERT INTO /* PchReq.insertPchReqDtlPtcl */ pch_req_dtl_ptcl
  290. (pch_req_unq_no, pch_req_dtl_no, item_nm, unit, pch_req_qty
  291. , pch_req_amt, unit_amt, unit_gubun, brand_unit_unq_no, store_unit_unq_no
  292. , item_id, sys_reg_dttm, sys_reg_id, sys_chg_dttm, sys_chg_id)
  293. VALUES
  294. <foreach collection="gridInsertData" item="item" separator=",">
  295. (#{item.pchReqUnqNo}, #{item.pchReqDtlNo}, #{item.itemNm}, #{item.unit}, #{item.pchReqQty}
  296. , #{item.pchReqAmt}, #{item.unitAmt}, #{item.unitGubun} , #{item.brandUnitUnqNo} , #{item.storeUnitUnqNo}
  297. , #{item.itemId} , NOW(), #{userId}, NOW(), #{userId})
  298. </foreach>
  299. </insert>
  300. <update id="updatePchReqDtlPtcl">
  301. <foreach collection="gridUpdateData" item="item" separator=";">
  302. UPDATE /* PchReq.updatePchReqDtlPtcl */
  303. pch_req_dtl_ptcl SET
  304. unit = #{item.unit},
  305. pch_req_qty = #{item.pchReqQty},
  306. pch_req_amt = #{item.pchReqAmt},
  307. unit_amt = #{item.unitAmt},
  308. sys_chg_dttm = NOW(),
  309. sys_chg_id = #{userId}
  310. WHERE pch_req_unq_no = #{pchReqUnqNo}
  311. AND pch_req_dtl_no = #{item.pchReqDtlNo}
  312. </foreach>
  313. </update>
  314. <delete id="deletePchReqDtlPtcl">
  315. DELETE /* PchReq.deletePchReqDtlPtcl */
  316. FROM pch_req_dtl_ptcl
  317. WHERE pch_req_unq_no = #{pchReqUnqNo}
  318. and pch_req_dtl_no in
  319. <foreach collection="gridDeleteData" item="item" separator="," open="(" close=")">
  320. #{item.pchReqDtlNo}
  321. </foreach>
  322. </delete>
  323. <select id="selectMaxPchReqDtlNo" resultType="int">
  324. SELECT nvl(Max(convert(pch_req_dtl_no,int)),0)
  325. FROM pch_req_dtl_ptcl
  326. WHERE pch_req_unq_no = #{pchReqUnqNo}
  327. </select>
  328. <select id="selectSumReqAmt" resultType="com.oqpo.api.entity.pomng.PchReqBaseInfoEntity">
  329. select count(*) as pch_req_item_qty, nvl(sum(pch_req_amt),0) as pch_req_total_amt
  330. from pch_req_dtl_ptcl
  331. where pch_req_unq_no = #{pchReqUnqNo}
  332. </select>
  333. <select id="selectPchReqPoTargetGridList" resultType="com.oqpo.api.entity.pomng.PchReqBaseInfoEntity">
  334. select base.pch_req_unq_no, ptcl.pch_req_dtl_no as 'pchReqDtlInfo.pch_req_dtl_no', base.brand_id, fn_brand_nm(base.brand_id) as brand_nm
  335. , base.store_id, store.store_nm
  336. , bitem.spply_nm as 'itemUnitInfo.spply_nm'
  337. , fn_whs_nm(base.brand_id, base.whs_id) as whs_nm, fn_whs_location_nm(base.brand_id, base.whs_id, base.location) as location_nm
  338. , ptcl.item_id as 'pchReqDtlInfo.item_id', ptcl.item_nm as 'pchReqDtlInfo.item_nm', ptcl.unit_amt as 'pchReqDtlInfo.unit_amt'
  339. , bitem.unit_amt as 'itemUnitInfo.unit_amt' , ptcl.pch_req_qty as 'pchReqDtlInfo.pch_req_qty', date_format(base.dlv_req_dt, '%Y.%m.%d') as dlv_req_dt
  340. , ptcl.pch_req_amt as 'pchReqDtlInfo.pch_req_amt', bitem.unit_amt * ptcl.pch_req_qty as 'pchReqDtlInfo.pch_ord_amt'
  341. , bitem.lead_time as 'itemUnitInfo.lead_time', bitem.spply_id as 'itemUnitInfo.spply_id', base.whs_id, base.location
  342. from pch_req_base_info base
  343. join pch_req_dtl_ptcl ptcl on base.pch_req_unq_no = ptcl.pch_req_unq_no
  344. join brand_item_unit_info bitem on ptcl.brand_unit_unq_no = bitem.brand_unit_unq_no
  345. left outer join store_base_info store on base.brand_id = store.brand_id and base.store_id = store.store_id
  346. where 1 = 1
  347. and base.brand_id = #{sBrandId}
  348. and base.pch_req_st_cd = 'PR20'
  349. and base.dlv_req_dt between #{fromDt} and #{toDt}
  350. <if test="sSpplyId != null and sSpplyId != ''">
  351. and bitem.spply_id = #{sSpplyId}
  352. </if>
  353. <if test="sWhsId != null and sWhsId != ''">
  354. and base.whs_id = #{sWhsId}
  355. </if>
  356. <if test="sItemNm != null and sItemNm != ''">
  357. and (ptcl.item_id like concat('%', #{sItemNm}, '%') or ptcl.item_nm like concat('%', #{sItemNm}, '%'))
  358. </if>
  359. <choose>
  360. <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
  361. <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
  362. <if test="gridRequest.sord == 'asc'.toString()">
  363. order by base.dlv_req_dt asc, base.whs_id, base.location, bitem.spply_id, base.pch_req_unq_no, ptcl.pch_req_dtl_no
  364. </if>
  365. <if test="gridRequest.sord == 'desc'.toString()">
  366. order by base.dlv_req_dt desc, base.whs_id, base.location, bitem.spply_id, base.pch_req_unq_no, ptcl.pch_req_dtl_no
  367. </if>
  368. </if>
  369. </when>
  370. <otherwise>
  371. order by base.dlv_req_dt asc, base.whs_id, base.location, bitem.spply_id, base.pch_req_unq_no, ptcl.pch_req_dtl_no
  372. </otherwise>
  373. </choose>
  374. <if test="gridRequest.pagingYn == true">
  375. limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
  376. </if>
  377. </select>
  378. <select id="selectPchReqPoTargetGridCnt" resultType="int">
  379. select count(*)
  380. from pch_req_base_info base
  381. join pch_req_dtl_ptcl ptcl on base.pch_req_unq_no = ptcl.pch_req_unq_no
  382. join brand_item_unit_info bitem on ptcl.brand_unit_unq_no = bitem.brand_unit_unq_no
  383. left outer join store_base_info store on base.brand_id = store.brand_id and base.store_id = store.store_id
  384. where 1 = 1
  385. and base.brand_id = #{sBrandId}
  386. and base.pch_req_st_cd = 'PR20'
  387. and base.dlv_req_dt between #{fromDt} and #{toDt}
  388. <if test="sSpplyId != null and sSpplyId != ''">
  389. and bitem.spply_id = #{sSpplyId}
  390. </if>
  391. <if test="sWhsId != null and sWhsId != ''">
  392. and base.whs_id = #{sWhsId}
  393. </if>
  394. <if test="sItemNm != null and sItemNm != ''">
  395. and (ptcl.item_id like concat('%', #{sItemNm}, '%') or ptcl.item_nm like concat('%', #{sItemNm}, '%'))
  396. </if>
  397. </select>
  398. <select id="selectPchRejectPrTargetList" resultType="com.oqpo.api.entity.pomng.PchReqDtlPtclEntity">
  399. select /* PchReq.selectPchRejectPrTargetList */
  400. base.pch_req_unq_no, ptcl.pch_req_dtl_no
  401. , ptcl.item_id, ptcl.item_nm
  402. , ptcl.pch_req_qty, ptcl.pch_req_amt
  403. from pch_req_base_info base
  404. , pch_req_dtl_ptcl ptcl
  405. where 1 = 1
  406. and base.pch_req_unq_no = ptcl.pch_req_unq_no
  407. and base.pch_req_st_cd = 'PR20'
  408. and base.pch_req_unq_no = #{pchReqUnqNo}
  409. </select>
  410. <update id="updatePchReqStCd">
  411. <foreach collection="gridUpdateData" item="item" separator=";">
  412. UPDATE /* PchReq.updatePchReqDtlPtcl */
  413. pch_req_base_info SET
  414. pch_req_st_cd = #{item.pchReqStCd},
  415. sys_chg_dttm = NOW(),
  416. sys_chg_id = #{userId}
  417. WHERE pch_req_unq_no = #{item.pchReqUnqNo}
  418. </foreach>
  419. </update>
  420. -->
  421. </mapper>