ColOdr.xml 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811
  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.inoutmng.ColOdrMapper">
  4. <select id="selectColRtnIngCnt" resultType="int">
  5. select count(*) /* ColOdr.selectColRtnIngCnt */
  6. from col_odr_base_info base
  7. ,col_odr_dtl_ptcl ptcl
  8. where base.col_cmd_unq_no = ptcl.col_cmd_unq_no
  9. and base.brand_id = #{brandId}
  10. and base.col_cmd_st_cd in ('COL1','COL2')
  11. and ptcl.rtn_podr_unq_no = #{rtnPodrUnqNo}
  12. </select>
  13. <select id="selectColTargetRtnGridList" resultType="com.oqpo.api.entity.rtnmng.RtnOdrBaseInfoEntity">
  14. select base.brand_id, fn_brand_nm(base.brand_id) as brand_nm
  15. , base.rtn_podr_unq_no, ptcl.rtn_podr_dtl_no as 'rtnOdrDtlInfo.rtn_podr_dtl_no'
  16. , ptcl.rtn_req_unq_no as 'rtnOdrDtlInfo.rtn_req_unq_no', ptcl.rtn_req_dtl_no as 'rtnOdrDtlInfo.rtn_req_dtl_no'
  17. , ptcl.item_id as 'rtnOdrDtlInfo.item_id', ptcl.item_nm as 'rtnOdrDtlInfo.item_nm'
  18. , base.rtn_whs_id, base.rtn_location, fn_whs_nm(base.brand_id, base.rtn_whs_id) as rtn_whs_nm
  19. , fn_whs_location_nm(base.brand_id, base.rtn_whs_id, base.rtn_location) as rtn_location_nm
  20. , ptcl.unit_amt as 'rtnOdrDtlInfo.unit_amt'
  21. , ptcl.rtn_req_qty as 'rtnOdrDtlInfo.rtn_req_qty', ptcl.rtn_odr_qty as 'rtnOdrDtlInfo.rtn_odr_qty'
  22. , date_format(base.col_req_dt,'%Y.%m.%d') as col_req_dt, ptcl.rtn_amt as 'rtnOdrDtlInfo.rtn_amt'
  23. , base.whs_id, fn_whs_nm(base.brand_id, base.whs_id) as whs_nm
  24. , base.location, fn_whs_location_nm(base.brand_id, base.whs_id, base.location) as location_nm
  25. , base.store_id
  26. from rtn_odr_base_info base
  27. , rtn_odr_dtl_ptcl ptcl
  28. where 1=1
  29. and base.rtn_podr_unq_no = ptcl.rtn_podr_unq_no
  30. and base.brand_id = #{sBrandId}
  31. and base.col_req_dt between #{fromDt} and #{toDt}
  32. and base.rtn_odr_st_cd = 'RO20'
  33. and ptcl.rodr_dtl_st_cd = 'ROD1'
  34. and base.col_dvsn = 'C001'
  35. <if test="sWhsId != null and sWhsId != ''">
  36. and base.whs_id = #{sWhsId}
  37. </if>
  38. <if test="sRtnWhsId != null and sRtnWhsId != ''">
  39. and base.rtn_whs_id = #{sRtnWhsId}
  40. </if>
  41. <if test="sItemNm != null and sItemNm != ''">
  42. and (ptcl.item_id like concat('%', '', '%') or ptcl.item_nm like concat('%', '', '%'))
  43. </if>
  44. <choose>
  45. <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
  46. <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
  47. <if test="gridRequest.sord == 'asc'.toString()">
  48. order by base.rtn_podr_unq_no asc , ptcl.rtn_podr_dtl_no asc
  49. </if>
  50. <if test="gridRequest.sord == 'desc'.toString()">
  51. order by base.rtn_podr_unq_no desc , ptcl.rtn_podr_dtl_no asc
  52. </if>
  53. </if>
  54. </when>
  55. <otherwise>
  56. order by base.rtn_podr_unq_no asc , ptcl.rtn_podr_dtl_no asc
  57. </otherwise>
  58. </choose>
  59. <if test="gridRequest.pagingYn == true">
  60. limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
  61. </if>
  62. </select>
  63. <select id="selectColTargetRtnGridCnt" resultType="int">
  64. select count(*) as cnt
  65. from rtn_odr_base_info base
  66. , rtn_odr_dtl_ptcl ptcl
  67. where 1=1
  68. and base.rtn_podr_unq_no = ptcl.rtn_podr_unq_no
  69. and base.brand_id = #{sBrandId}
  70. and base.col_req_dt between #{fromDt} and #{toDt}
  71. and base.rtn_odr_st_cd = 'RO20'
  72. and ptcl.rodr_dtl_st_cd = 'ROD1'
  73. and base.col_dvsn = 'C001'
  74. <if test="sWhsId != null and sWhsId != ''">
  75. and base.whs_id = #{sWhsId}
  76. </if>
  77. <if test="sRtnWhsId != null and sRtnWhsId != ''">
  78. and base.rtn_whs_id = #{sRtnWhsId}
  79. </if>
  80. <if test="sItemNm != null and sItemNm != ''">
  81. and (ptcl.item_id like concat('%', '', '%') or ptcl.item_nm like concat('%', '', '%'))
  82. </if>
  83. </select>
  84. <select id="selectColInstRtnGridList" resultType="com.oqpo.api.entity.rtnmng.RtnOdrBaseInfoEntity">
  85. select base.brand_id, fn_brand_nm(base.brand_id) as brand_nm
  86. , base.rtn_podr_unq_no, ptcl.rtn_podr_dtl_no as 'rtnOdrDtlInfo.rtn_podr_dtl_no'
  87. , ptcl.rtn_req_unq_no as 'rtnOdrDtlInfo.rtn_req_unq_no', ptcl.rtn_req_dtl_no as 'rtnOdrDtlInfo.rtn_req_dtl_no'
  88. , ptcl.item_id as 'rtnOdrDtlInfo.item_id', ptcl.item_nm as 'rtnOdrDtlInfo.item_nm'
  89. , base.rtn_whs_id, base.rtn_location, fn_whs_nm(base.brand_id, base.rtn_whs_id) as rtn_whs_nm
  90. , fn_whs_location_nm(base.brand_id, base.rtn_whs_id, base.rtn_location) as rtn_location_nm
  91. , ptcl.unit_amt as 'rtnOdrDtlInfo.unit_amt'
  92. , ptcl.rtn_odr_qty as 'rtnOdrDtlInfo.col_qty', ptcl.rtn_odr_qty as 'rtnOdrDtlInfo.rtn_odr_qty'
  93. , date_format(base.col_req_dt,'%Y.%m.%d') as col_req_dt, ptcl.rtn_amt as 'rtnOdrDtlInfo.rtn_amt'
  94. , base.whs_id, fn_whs_nm(base.brand_id, base.whs_id) as whs_nm
  95. , base.location, fn_whs_location_nm(base.brand_id, base.whs_id, base.location) as location_nm
  96. , base.store_id
  97. from rtn_odr_base_info base
  98. , rtn_odr_dtl_ptcl ptcl
  99. where 1=1
  100. and base.rtn_podr_unq_no = ptcl.rtn_podr_unq_no
  101. and base.brand_id = #{brandId}
  102. and concat(base.rtn_podr_unq_no, ptcl.rtn_podr_dtl_no) in
  103. <foreach collection="gridUpdateData" item="item" separator="," open="(" close=")">
  104. concat(#{item.rtnPodrUnqNo},#{item.rtnPodrDtlNo})
  105. </foreach>
  106. </select>
  107. <select id="selectPickJobDataList" resultType="com.oqpo.api.entity.rtnmng.RtnOdrBaseInfoEntity">
  108. select base.brand_id,base.rtn_podr_unq_no, ptcl.rtn_podr_dtl_no as 'rtnOdrDtlInfo.rtn_podr_dtl_no'
  109. ,ptcl.item_id as 'rtnOdrDtlInfo.item_id' , ptcl.item_nm as 'rtnOdrDtlInfo.item_nm', base.whs_id
  110. ,base.location, ptcl.unit_amt as 'rtnOdrDtlInfo.unit_amt', ptcl.rtn_odr_qty as 'rtnOdrDtlInfo.rtn_odr_qty'
  111. ,ptcl.rtn_odr_amt as 'rtnOdrDtlInfo.rtn_odr_amt', date_format(base.col_req_dt,'%Y.%m.%d') as col_req_dt
  112. , base.rtn_whs_id, base.rtn_location, ptcl.rtn_req_unq_no as 'rtnOdrDtlInfo.rtn_req_unq_no' , ptcl.rtn_req_dtl_no as 'rtnOdrDtlInfo.rtn_req_dtl_no'
  113. , base.store_id , base.rtn_mgr_nm , base.rtn_mgr_tel_no, base.rtn_mgr_id
  114. , nvl(fn_get_telno((select mgr_tel_no from whs_mgnt_base_info where brand_id = base.brand_id and whs_id = base.rtn_whs_id)),' ') as pick_tel_no
  115. , date_format(base.rtn_odr_reg_dt,'%Y%m%d') as rtn_odr_req_dt
  116. , base.spply_id, fn_spply_nm(base.spply_id) as spply_nm
  117. , ptcl.rtn_rsn_dvsn as 'rtnOdrDtlInfo.rtn_rsn_dvsn', ptcl.rtn_rsn as 'rtnOdrDtlInfo.rtn_rsn'
  118. , base.col_dvsn, ptcl.unit as 'rtnOdrDtlInfo.unit'
  119. from rtn_odr_base_info base
  120. join rtn_odr_dtl_ptcl ptcl on base.rtn_podr_unq_no = ptcl.rtn_podr_unq_no and ptcl.rodr_dtl_st_cd = 'ROD1'
  121. join item_base_info itm on ptcl.item_id = itm.item_id
  122. and base.brand_id = #{brandId}
  123. and concat(base.rtn_podr_unq_no,ptcl.rtn_podr_dtl_no) in
  124. <foreach collection="gridInsertData" item="item" separator="," open="(" close=")">
  125. concat(#{item.rtnPodrUnqNo},#{item.rtnPodrDtlNo})
  126. </foreach>
  127. order by base.brand_id, base.whs_id, base.location, base.rtn_whs_id,base.rtn_location
  128. </select>
  129. <insert id="insertColOdrBase">
  130. insert into col_odr_base_info /* ColOdr.insertColOdrBase*/
  131. (col_cmd_unq_no, col_reg_dt, brand_id, whs_id, location
  132. , store_id, item_qty, col_total_amt, col_req_dt, col_dvsn
  133. , col_cmd_st_cd, col_req_mgr_nm, col_req_mgr_id, col_dt, col_cnfm_nm
  134. , col_cnfm_id, col_mgr_nm, col_mgr_tel_no, col_mgr_emal, col_mgr_mbl_no
  135. , rtn_whs_id, rtn_location, spply_id, spply_nm, col_pick_unq_no
  136. , sys_reg_dttm, sys_reg_id, sys_chg_dttm, sys_chg_id)
  137. values
  138. (#{entity.colCmdUnqNo}, date_format(now(),'%Y%m%d'), #{entity.brandId}, #{entity.whsId}, #{entity.location}
  139. , #{entity.storeId}, #{entity.itemQty}, #{entity.colTotalAmt}, #{entity.colReqDt}, #{entity.colDvsn}
  140. , #{entity.colCmdStCd}, #{entity.colReqMgrNm}, #{entity.colReqMgrId}, #{entity.colDt}, #{entity.colCnfmNm}
  141. , #{entity.colCnfmId}, #{entity.colMgrNm}, #{entity.colMgrTelNo}, #{entity.colMgrEmal}, #{entity.colMgrMblNo}
  142. , #{entity.rtnWhsId}, #{entity.rtnLocation}, #{entity.spplyId}, #{entity.spplyNm}, #{entity.colPickUnqNo}
  143. , now(), #{userId}, now(), #{userId})
  144. </insert>
  145. <insert id="insertColOdrDtl">
  146. insert into col_odr_dtl_ptcl /* ColOdr.insertColOdrDtl*/
  147. (col_cmd_unq_no, col_cmd_dtl_no, item_id, item_nm, unit_amt
  148. , col_qty, col_amt, rtn_qty, rtn_amt, rtn_rsn_dvsn
  149. , rtn_rsn, rtn_podr_unq_no, rtn_podr_dtl_no, rtn_req_dtl_no, rtn_req_unq_no, col_cmd_dtl_st_cd
  150. , sys_reg_dttm, sys_reg_id, sys_chg_dttm, sys_chg_id)
  151. values
  152. <foreach collection="gridInsertData" item="item" separator=",">
  153. (#{item.colCmdUnqNo}, #{item.colCmdDtlNo}, #{item.itemId}, #{item.itemNm}, #{item.unitAmt}
  154. , #{item.colQty}, #{item.colAmt}, #{item.rtnQty}, #{item.rtnAmt}, #{item.rtnRsnDvsn}
  155. , #{item.rtnRsn}, #{item.rtnPodrUnqNo}, #{item.rtnPodrDtlNo}, #{item.rtnReqDtlNo}, #{item.rtnReqUnqNo}, 'CDLD1'
  156. , now(), #{userId}, now(), #{userId})
  157. </foreach>
  158. </insert>
  159. <insert id="insertPickMgntBase">
  160. insert into pick_info_mgnt /* ColOdr.insertPickMgntBase */
  161. (col_pick_unq_no, spply_id, spply_nm, store_id, col_reg_dt
  162. , col_tot_amt, pick_mgr_nm, pick_mgr_tel_no, pick_mgr_emal, pick_mgr_mbl_no
  163. , pndr_tel_no, pick_st_cd, rodr_reg_dt, col_req_dt, col_sch_dt
  164. , col_cmplt_dt, whs_id, location, whs_dvsn, brand_id, col_desc, col_dvsn
  165. , sys_reg_dttm, sys_reg_id, sys_chg_dttm, sys_chg_id)
  166. values
  167. (#{entity.colPickUnqNo}, #{entity.spplyId}, #{entity.spplyNm}, #{entity.storeId}, date_format(now(),'%Y%m%d')
  168. , #{entity.colTotAmt}, #{entity.pickMgrNm}, #{entity.pickMgrTelNo}, #{entity.pickMgrEmal}, #{entity.pickMgrMblNo}
  169. , #{entity.pndrTelNo}, #{entity.pickStCd}, date_format(now(),'%Y%m%d'), #{entity.colReqDt}, #{entity.colSchDt}
  170. , #{entity.colCmpltDt}, #{entity.whsId}, #{entity.location}, #{entity.whsDvsn}, #{entity.brandId}, #{entity.colDesc}, #{entity.colDvsn}
  171. , now(), #{userId}, now(), #{userId})
  172. </insert>
  173. <insert id="insertPickDtlPtcl">
  174. insert into pick_dtl_ptcl /* ColOdr.insertPickDtlPtcl */
  175. (col_pick_unq_no, col_pick_dtl_no, rtn_podr_unq_no, rtn_podr_dtl_no, rtn_req_unq_no
  176. , rtn_req_dtl_no, col_cmd_unq_no, col_cmd_dtl_no, pick_dtl_st_cd, item_id
  177. , item_nm, unit, unit_amt, price_unit, rodr_qty
  178. , col_req_qty, col_req_amt, delay_yn, delay_rsn
  179. , sys_reg_dttm, sys_reg_id, sys_chg_dttm, sys_chg_id)
  180. values
  181. <foreach collection="gridInsertData" item="item" separator=",">
  182. (#{item.colPickUnqNo}, #{item.colPickDtlNo}, #{item.rtnPodrUnqNo}, #{item.rtnPodrDtlNo}, #{item.rtnReqUnqNo}
  183. , #{item.rtnReqDtlNo}, #{item.colCmdUnqNo}, #{item.colCmdDtlNo}, 'PICKD0', #{item.itemId}
  184. , #{item.itemNm}, #{item.unit}, #{item.unitAmt}, #{item.priceUnit}, #{item.rodrQty}
  185. , #{item.colReqQty}, #{item.colReqAmt}, #{item.delayYn}, #{item.delayRsn}
  186. , now(), #{userId}, now(), #{userId})
  187. </foreach>
  188. </insert>
  189. <select id="selectColGridList" resultType="com.oqpo.api.entity.inoutmng.ColOdrBaseEntity">
  190. select base.brand_id, fn_brand_nm(base.brand_id) as brand_nm, base.col_cmd_unq_no, ptcl.col_cmd_dtl_no as 'colDtlInfo.col_cmd_dtl_no'
  191. , ptcl.rtn_podr_unq_no as 'colDtlInfo.rtn_podr_unq_no', ptcl.rtn_podr_dtl_no as 'colDtlInfo.rtn_podr_dtl_no'
  192. , ptcl.col_cmd_dtl_st_cd as 'colDtlInfo.col_cmd_dtl_st_cd', fn_code_nm('COL_CMD_DTL_ST_CD', ptcl.col_cmd_dtl_st_cd) as 'colDtlInfo.col_cmd_dtl_st_nm'
  193. , ptcl.item_id as 'colDtlInfo.item_id' , ptcl.item_nm as 'colDtlInfo.item_nm', base.rtn_whs_id, base.rtn_location
  194. , concat(fn_whs_nm( base.brand_id, base.rtn_whs_id) , ' - ', fn_whs_location_nm(base.brand_id, base.rtn_whs_id,base.rtn_location) ) as rtn_whs_nm
  195. , base.col_dvsn, fn_code_nm('COL_DVSN',base.col_dvsn) as col_dvsn_nm
  196. , (case when base.whs_id is null or base.whs_id = '' then base.spply_id else base.whs_id end ) as whs_id
  197. , (case when base.whs_id is null or base.whs_id = '' then base.spply_nm else (concat(fn_whs_nm( base.brand_id, base.whs_id) , ' - ', fn_whs_location_nm(base.brand_id, base.whs_id,base.location) )) end ) as whs_nm
  198. , ptcl.rtn_qty as 'colDtlInfo.rtn_qty', ptcl.col_qty as 'colDtlInfo.col_qty', case when ptcl.col_cmd_dtl_st_cd = 'CDLD2' then ptcl.col_amt else 0 end as 'colDtlInfo.col_amt'
  199. , date_format(base.col_dt , '%Y.%m.%d') as col_dt , base.col_cnfm_nm, base.col_pick_unq_no
  200. from col_odr_base_info base,
  201. col_odr_dtl_ptcl ptcl
  202. where 1=1
  203. and base.col_cmd_unq_no = ptcl.col_cmd_unq_no
  204. and base.brand_id = #{sBrandId}
  205. and base.col_req_dt between #{fromDt} and #{toDt}
  206. <if test="sColDvsn != null and sColDvsn != ''">
  207. and base.col_dvsn = #{sColDvsn}
  208. </if>
  209. <if test="sWhsId != null and sWhsId != ''">
  210. and base.whs_id = #{sWhsId}
  211. </if>
  212. <if test="sRtnWhsId != null and sRtnWhsId != ''">
  213. and base.rtn_whs_id = #{sRtnWhsId}
  214. </if>
  215. <if test="sColCmdDtlStCd != null and sColCmdDtlStCd != ''">
  216. and ptcl.col_cmd_dtl_st_cd = #{sColCmdDtlStCd}
  217. </if>
  218. <if test="sItemNm != null and sItemNm != ''">
  219. and ( ptcl.item_id like concat('%',#{sItemNm},'%') or ptcl_item_nm like concat('%',#{sItemNm},'%') )
  220. </if>
  221. <choose>
  222. <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
  223. <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
  224. <if test="gridRequest.sord == 'asc'.toString()">
  225. order by base.col_cmd_unq_no asc , ptcl.col_cmd_dtl_no asc
  226. </if>
  227. <if test="gridRequest.sord == 'desc'.toString()">
  228. order by base.col_cmd_unq_no desc , ptcl.col_cmd_dtl_no asc
  229. </if>
  230. </if>
  231. </when>
  232. <otherwise>
  233. order by base.col_cmd_unq_no desc , ptcl.col_cmd_dtl_no asc
  234. </otherwise>
  235. </choose>
  236. <if test="gridRequest.pagingYn == true">
  237. limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
  238. </if>
  239. </select>
  240. <select id="selectColGridCnt" resultType="int">
  241. select count(*) as cnt
  242. from col_odr_base_info base,
  243. col_odr_dtl_ptcl ptcl
  244. where 1=1
  245. and base.col_cmd_unq_no = ptcl.col_cmd_unq_no
  246. and base.brand_id = #{sBrandId}
  247. and base.col_req_dt between #{fromDt} and #{toDt}
  248. <if test="sColDvsn != null and sColDvsn != ''">
  249. and base.col_dvsn = #{sColDvsn}
  250. </if>
  251. <if test="sWhsId != null and sWhsId != ''">
  252. and base.whs_id = #{sWhsId}
  253. </if>
  254. <if test="sRtnWhsId != null and sRtnWhsId != ''">
  255. and base.rtn_whs_id = #{sRtnWhsId}
  256. </if>
  257. <if test="sColCmdDtlStCd != null and sColCmdDtlStCd != ''">
  258. and ptcl.col_cmd_dtl_st_cd = #{sColCmdDtlStCd}
  259. </if>
  260. <if test="sItemNm != null and sItemNm != ''">
  261. and ( ptcl.item_id like concat('%',#{sItemNm},'%') or ptcl_item_nm like concat('%',#{sItemNm},'%') )
  262. </if>
  263. </select>
  264. <select id="selectPickInfo" resultType="com.oqpo.api.entity.inoutmng.PickInfoMgntEntity">
  265. select col_pick_unq_no, spply_id, spply_nm, store_id
  266. , date_format(col_reg_dt,'%Y.%m.%d') as col_reg_dt
  267. , col_tot_amt, pick_mgr_nm, fn_get_telno(pick_mgr_tel_no) as pick_mgr_tel_no
  268. , fn_get_telno(pndr_tel_no) as pndr_tel_no, pick_st_cd, fn_code_nm('PICK_ST_CD', pick_st_cd ) as pick_st_nm
  269. , date_format(rodr_reg_dt,'%Y.%m.%d') as rodr_reg_dt, date_format(col_req_dt,'%Y.%m.%d') as col_req_dt
  270. , date_format(col_sch_dt,'%Y.%m.%d') as col_sch_dt, date_format(col_cmplt_dt,'%Y.%m.%d') as col_cmplt_dt
  271. , whs_id , fn_whs_nm(brand_id, whs_id) as whs_nm, location, fn_whs_location_nm(brand_id, whs_id, location) as location_nm
  272. , whs_dvsn, fn_code_nm('WHS_DVSN', whs_dvsn) as whs_dvsn_nm, brand_id, fn_brand_nm(brand_id) as brand_nm
  273. , col_desc
  274. from pick_info_mgnt
  275. where col_pick_unq_no = #{colPickUnqNo}
  276. and brand_id = #{brandId}
  277. </select>
  278. <select id="selectPickDtlPtcl" resultType="com.oqpo.api.entity.inoutmng.PickDtlPtclEntity">
  279. select ptcl.col_pick_unq_no, ptcl.col_pick_dtl_no, ptcl.rtn_podr_unq_no, ptcl.rtn_podr_dtl_no, ptcl.rtn_req_unq_no
  280. , ptcl.rtn_req_dtl_no, ptcl.col_cmd_unq_no, ptcl.col_cmd_dtl_no
  281. , ptcl.pick_dtl_st_cd, fn_code_nm('PICK_DTL_ST_CD',ptcl.pick_dtl_st_cd) as pick_dtl_st_nm, ptcl.item_id
  282. , ptcl.item_nm, ptcl.unit, ptcl.unit_amt, ptcl.price_unit, ptcl.rodr_qty
  283. , ptcl.col_req_qty, ptcl.col_req_amt, ptcl.delay_yn, ptcl.delay_rsn
  284. , rptcl.rtn_rsn_dvsn, fn_code_nm('RTN_RSN_DVSN', rptcl.rtn_rsn_dvsn ) as rtn_rsn_dvsn_nm
  285. , rptcl.rtn_rsn
  286. from pick_info_mgnt base, pick_dtl_ptcl ptcl
  287. , rtn_odr_dtl_ptcl rptcl
  288. where base.col_pick_unq_no = ptcl.col_pick_unq_no
  289. and ptcl.rtn_podr_unq_no = rptcl.rtn_podr_unq_no
  290. and ptcl.rtn_podr_dtl_no = rptcl.rtn_podr_dtl_no
  291. and base.brand_id = #{brandId}
  292. and base.col_pick_unq_no = #{colPickUnqNo}
  293. </select>
  294. <select id="selectColSpplyTargetRtnGridList" resultType="com.oqpo.api.entity.rtnmng.RtnOdrBaseInfoEntity">
  295. select base.brand_id, fn_brand_nm(base.brand_id) as brand_nm
  296. , base.rtn_podr_unq_no, ptcl.rtn_podr_dtl_no as 'rtnOdrDtlInfo.rtn_podr_dtl_no'
  297. , ptcl.rtn_req_unq_no as 'rtnOdrDtlInfo.rtn_req_unq_no', ptcl.rtn_req_dtl_no as 'rtnOdrDtlInfo.rtn_req_dtl_no'
  298. , ptcl.item_id as 'rtnOdrDtlInfo.item_id', ptcl.item_nm as 'rtnOdrDtlInfo.item_nm'
  299. , base.rtn_whs_id, fn_whs_nm(base.brand_id, base.rtn_whs_id) as rtn_whs_nm
  300. , base.rtn_location, fn_whs_location_nm(base.brand_id, base.rtn_whs_id, base.rtn_location) as rtn_location_nm
  301. , ptcl.unit_amt as 'rtnOdrDtlInfo.unit_amt'
  302. , ptcl.rtn_odr_qty as 'rtnOdrDtlInfo.rtn_odr_qty'
  303. , date_format(base.col_req_dt,'%Y.%m.%d') as col_req_dt, ptcl.rtn_amt as 'rtnOdrDtlInfo.rtn_amt'
  304. , base.whs_id, fn_whs_nm(base.brand_id, base.whs_id) as whs_nm
  305. , base.location, fn_whs_location_nm(base.brand_id, base.whs_id, base.location) as location_nm
  306. , base.store_id, ptcl.rtn_odr_amt as 'rtnOdrDtlInfo.rtn_odr_amt'
  307. from rtn_odr_base_info base
  308. , rtn_odr_dtl_ptcl ptcl
  309. where 1=1
  310. and base.rtn_podr_unq_no = ptcl.rtn_podr_unq_no
  311. and base.brand_id = #{sBrandId}
  312. and base.spply_id = #{sSpplyId}
  313. and base.col_req_dt between #{fromDt} and #{toDt}
  314. and base.rtn_odr_st_cd = 'RO20'
  315. and ptcl.rodr_dtl_st_cd = 'ROD1'
  316. and base.col_dvsn = 'C002'
  317. <if test="sRtnWhsId != null and sRtnWhsId != ''">
  318. and base.rtn_whs_id = #{sRtnWhsId}
  319. </if>
  320. <if test="sItemNm != null and sItemNm != ''">
  321. and (ptcl.item_id like concat('%', #{sItemNm}, '%') or ptcl.item_nm like concat('%', #{sItemNm}, '%'))
  322. </if>
  323. <choose>
  324. <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
  325. <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
  326. <if test="gridRequest.sord == 'asc'.toString()">
  327. order by base.rtn_podr_unq_no asc , ptcl.rtn_podr_dtl_no asc
  328. </if>
  329. <if test="gridRequest.sord == 'desc'.toString()">
  330. order by base.rtn_podr_unq_no desc , ptcl.rtn_podr_dtl_no asc
  331. </if>
  332. </if>
  333. </when>
  334. <otherwise>
  335. order by base.rtn_podr_unq_no asc , ptcl.rtn_podr_dtl_no asc
  336. </otherwise>
  337. </choose>
  338. <if test="gridRequest.pagingYn == true">
  339. limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
  340. </if>
  341. </select>
  342. <select id="selectColSpplyTargetRtnGridCnt" resultType="int">
  343. select count(*) as cnt
  344. from rtn_odr_base_info base
  345. , rtn_odr_dtl_ptcl ptcl
  346. where 1=1
  347. and base.rtn_podr_unq_no = ptcl.rtn_podr_unq_no
  348. and base.brand_id = #{sBrandId}
  349. and base.spply_id = #{sSpplyId}
  350. and base.col_req_dt between #{fromDt} and #{toDt}
  351. and base.rtn_odr_st_cd = 'RO20'
  352. and ptcl.rodr_dtl_st_cd = 'ROD1'
  353. and base.col_dvsn = 'C002'
  354. <if test="sRtnWhsId != null and sRtnWhsId != ''">
  355. and base.rtn_whs_id = #{sRtnWhsId}
  356. </if>
  357. <if test="sItemNm != null and sItemNm != ''">
  358. and (ptcl.item_id like concat('%', #{sItemNm}, '%') or ptcl.item_nm like concat('%', #{sItemNm}, '%'))
  359. </if>
  360. </select>
  361. <select id="selectSpplyColOdrInfo" resultType="com.oqpo.api.entity.rtnmng.RtnOdrBaseInfoEntity">
  362. select base.rtn_podr_unq_no, base.brand_id, fn_brand_nm(base.brand_id) as brand_nm, base.rtn_podr_unq_no, date_format(col_req_dt, '%Y.%m.%d') as col_req_dt
  363. , (select sum(rtn_amt) from rtn_odr_dtl_ptcl where rtn_podr_unq_no = #{rtnPodrUnqNo} and rodr_dtl_st_cd = 'ROD1' ) as rtn_dodr_total_amt
  364. , base.rtn_whs_id, fn_whs_nm(base.brand_id, base.rtn_whs_id) as rtn_whs_nm
  365. , base.rtn_location, fn_whs_location_nm(brand_id, base.rtn_whs_id, base.rtn_location) as rtn_location_nm
  366. , fn_get_telno((select tel_no from store_base_info where store_id = base.store_id )) as pick_tel_no
  367. from rtn_odr_base_info base
  368. where 1=1
  369. and base.brand_id = #{brandId}
  370. and base.spply_id = #{spplyId}
  371. and base.col_dvsn = 'C002'
  372. and base.rtn_podr_unq_no = #{rtnPodrUnqNo}
  373. </select>
  374. <select id="selectSpplyColRtnList" resultType="com.oqpo.api.entity.rtnmng.RtnOdrDtlPtclEntity">
  375. select ptcl.rtn_podr_unq_no, ptcl.rtn_podr_dtl_no, ptcl.item_id, ptcl.item_nm, ptcl.unit, ptcl.rtn_odr_qty, ptcl.rtn_odr_qty as col_qty
  376. , ptcl.unit_amt
  377. , ptcl.rtn_rsn_dvsn, rtn_rsn
  378. from rtn_odr_dtl_ptcl ptcl
  379. where ptcl.rtn_podr_unq_no = #{rtnPodrUnqNo}
  380. and ptcl.rodr_dtl_st_cd = 'ROD1'
  381. </select>
  382. <!-- 어디에 쓰는 쿼리인지 찿을 필요 있음
  383. <select id="selectColSpplyTargetRtnGridList" resultType="com.oqpo.api.entity.rtnmng.RtnOdrBaseInfoEntity">
  384. select base.brand_id, fn_brand_nm(base.brand_id) as brand_nm
  385. , base.rtn_podr_unq_no, ptcl.rtn_podr_dtl_no as 'rtnOdrDtlInfo.rtn_podr_dtl_no'
  386. , ptcl.rtn_req_unq_no as 'rtnOdrDtlInfo.rtn_req_unq_no', ptcl.rtn_req_dtl_no as 'rtnOdrDtlInfo.rtn_req_dtl_no'
  387. , ptcl.item_id as 'rtnOdrDtlInfo.item_id', ptcl.item_nm as 'rtnOdrDtlInfo.item_nm'
  388. , base.rtn_whs_id, fn_whs_nm(base.brand_id, base.rtn_whs_id) as rtn_whs_nm, ptcl.unit_amt as 'rtnOdrDtlInfo.unit_amt'
  389. , ptcl.rtn_qty as 'rtnOdrDtlInfo.rtn_qty', ptcl.rtn_odr_qty as 'rtnOdrDtlInfo.rtn_odr_qty'
  390. , date_format(base.col_req_dt,'%Y.%m.%d') as col_req_dt, ptcl.rtn_amt as 'rtnOdrDtlInfo.rtn_amt'
  391. , base.whs_id, fn_whs_nm(base.brand_id, base.whs_id) as whs_nm
  392. , base.location, fn_whs_location_nm(base.brand_id, base.whs_id, base.location) as location_nm
  393. , base.store_id, ptcl.rtn_odr_amt as 'rtnOdrDtlInfo.rtn_odr_amt'
  394. from rtn_odr_base_info base
  395. , rtn_odr_dtl_ptcl ptcl
  396. where 1=1
  397. and base.rtn_podr_unq_no = ptcl.rtn_podr_unq_no
  398. and base.brand_id = #{sBrandId}
  399. and base.spply_id = #{sSpplyId}
  400. and base.col_req_dt between #{fromDt} and #{toDt}
  401. and base.rtn_odr_st_cd = 'RO20'
  402. and ptcl.rodr_dtl_st_cd = 'ROD1'
  403. and base.col_dvsn = 'C002'
  404. <if test="sRtnWhsId != null and sRtnWhsId != ''">
  405. and base.rtn_whs_id = #{sRtnWhsId}
  406. </if>
  407. <if test="sItemNm != null and sItemNm != ''">
  408. and (ptcl.item_id like concat('%', '', '%') or ptcl.item_nm like concat('%', '', '%'))
  409. </if>
  410. <choose>
  411. <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
  412. <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
  413. <if test="gridRequest.sord == 'asc'.toString()">
  414. order by base.rtn_podr_unq_no asc , ptcl.rtn_podr_dtl_no asc
  415. </if>
  416. <if test="gridRequest.sord == 'desc'.toString()">
  417. order by base.rtn_podr_unq_no desc , ptcl.rtn_podr_dtl_no asc
  418. </if>
  419. </if>
  420. </when>
  421. <otherwise>
  422. order by base.rtn_podr_unq_no asc , ptcl.rtn_podr_dtl_no asc
  423. </otherwise>
  424. </choose>
  425. <if test="gridRequest.pagingYn == true">
  426. limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
  427. </if>
  428. </select>
  429. <select id="selectColTargetRtnGridCnt" resultType="int">
  430. select count(*) as cnt
  431. from rtn_odr_base_info base
  432. , rtn_odr_dtl_ptcl ptcl
  433. where 1=1
  434. and base.rtn_podr_unq_no = ptcl.rtn_podr_unq_no
  435. and base.brand_id = #{sBrandId}
  436. and base.spply_id = #{sSpplyId}
  437. and base.col_req_dt between #{fromDt} and #{toDt}
  438. and base.rtn_odr_st_cd = 'RO20'
  439. and ptcl.rodr_dtl_st_cd = 'ROD1'
  440. and base.col_dvsn = 'C001'
  441. <if test="sRtnWhsId != null and sRtnWhsId != ''">
  442. and base.rtn_whs_id = #{sRtnWhsId}
  443. </if>
  444. <if test="sItemNm != null and sItemNm != ''">
  445. and (ptcl.item_id like concat('%', '', '%') or ptcl.item_nm like concat('%', '', '%'))
  446. </if>
  447. </select>
  448. -->
  449. <select id="selectColSpplyPickGridList" resultType="com.oqpo.api.entity.inoutmng.PickInfoMgntEntity">
  450. select pmgnt.brand_id, fn_brand_nm(pmgnt.brand_id) as brand_nm
  451. , pmgnt.col_pick_unq_no , pmgnt.pick_st_cd, fn_code_nm('PICK_ST_CD',pmgnt.pick_st_cd) as pick_st_nm
  452. , date_format(pmgnt.col_reg_dt, '%Y.%m.%d') as col_reg_dt , date_format(pmgnt.col_req_dt, '%Y.%m.%d') as col_req_dt
  453. , date_format(pmgnt.col_sch_dt, '%Y.%m.%d') as col_sch_dt , date_format(pmgnt.col_cmplt_dt, '%Y.%m.%d') as col_cmplt_dt
  454. , pptcl.item_id as 'pickDtlInfo.item_id' , pptcl.item_nm as 'pickDtlInfo.item_nm', pptcl.col_req_qty as 'pickDtlInfo.col_req_qty'
  455. , pptcl.col_req_amt as 'pickDtlInfo.col_req_amt' , pptcl.unit_amt as 'pickDtlInfo.unit_amt', ptcl.rtn_rsn_dvsn as 'pickDtlInfo.rtn_rsn_dvsn'
  456. , fn_code_nm('RTN_RSN_DVSN', ptcl.rtn_rsn_dvsn) as 'pickDtlInfo.rtn_rsn_dvsn_nm', pmgnt.whs_id, pmgnt.location
  457. , fn_whs_nm(pmgnt.brand_id, pmgnt.whs_id) as whs_nm, fn_whs_location_nm(pmgnt.brand_id, pmgnt.whs_id, pmgnt.location) as location_nm
  458. , pmgnt.pick_mgr_nm, fn_get_telno(pmgnt.pick_mgr_tel_no) as pick_mgr_tel_no
  459. from rtn_odr_dtl_ptcl ptcl
  460. , pick_info_mgnt pmgnt
  461. , pick_dtl_ptcl pptcl
  462. where 1 = 1
  463. and ptcl.rtn_podr_unq_no = pptcl.rtn_podr_unq_no
  464. and ptcl.rtn_podr_dtl_no = pptcl.rtn_podr_dtl_no
  465. and pptcl.col_pick_unq_no = pmgnt.col_pick_unq_no
  466. and pmgnt.brand_id = #{sBrandId} -- 반품주체 공급사
  467. and pmgnt.spply_id = #{sSpplyId} -- 반품주체 공급사
  468. and pmgnt.col_dvsn = 'C002' -- c001 : 본사 수거, c002 : 공급사수거
  469. and pmgnt.col_req_dt between #{fromDt} and #{toDt}
  470. <if test="sWhsId != null and sWhsId != ''">
  471. and pmgnt.whs_id = #{sWhsId} -- 반품창고
  472. </if>
  473. <if test="sItemNm != null and sItemNm != ''">
  474. and (pmgnt.col_pick_unq_no like concat('%', #{sItemNm}, '%') or pptcl.item_id like concat('%', #{sItemNm}, '%') or pptcl.item_nm like concat('%', #{sItemNm}, '%'))
  475. </if>
  476. <choose>
  477. <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
  478. <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
  479. <if test="gridRequest.sord == 'asc'.toString()">
  480. order by pmgnt.col_pick_unq_no asc
  481. </if>
  482. <if test="gridRequest.sord == 'desc'.toString()">
  483. order by pmgnt.col_pick_unq_no desc
  484. </if>
  485. </if>
  486. </when>
  487. <otherwise>
  488. order by pmgnt.col_pick_unq_no desc
  489. </otherwise>
  490. </choose>
  491. <if test="gridRequest.pagingYn == true">
  492. limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
  493. </if>
  494. </select>
  495. <select id="selectColSpplyPickGridCnt" resultType="int">
  496. select count(*)
  497. from rtn_odr_dtl_ptcl ptcl
  498. , pick_info_mgnt pmgnt
  499. , pick_dtl_ptcl pptcl
  500. where 1 = 1
  501. and ptcl.rtn_podr_unq_no = pptcl.rtn_podr_unq_no
  502. and ptcl.rtn_podr_dtl_no = pptcl.rtn_podr_dtl_no
  503. and pptcl.col_pick_unq_no = pmgnt.col_pick_unq_no
  504. and pmgnt.brand_id = #{sBrandId} -- 반품주체 공급사
  505. and pmgnt.spply_id = #{sSpplyId} -- 반품주체 공급사
  506. and pmgnt.col_dvsn = 'C002' -- c001 : 본사 수거, c002 : 공급사수거
  507. and pmgnt.col_req_dt between #{fromDt} and #{toDt}
  508. <if test="sWhsId != null and sWhsId != ''">
  509. and pmgnt.whs_id = #{sWhsId} -- 반품창고
  510. </if>
  511. <if test="sItemNm != null and sItemNm != ''">
  512. and (pmgnt.col_pick_unq_no like concat('%', #{sItemNm}, '%') or pptcl.item_id like concat('%', #{sItemNm}, '%') or pptcl.item_nm like concat('%', #{sItemNm}, '%'))
  513. </if>
  514. </select>
  515. <select id="selectColRtnInstGridList" resultType="com.oqpo.api.entity.inoutmng.PickInfoMgntEntity">
  516. select mgnt.brand_id, fn_brand_nm(mgnt.brand_id) as brand_nm
  517. ,mgnt.col_pick_unq_no, dtl.col_pick_dtl_no as 'pickDtlInfo.col_pick_dtl_no'
  518. , dtl.rtn_podr_unq_no as 'pickDtlInfo.rtn_podr_unq_no' , dtl.rtn_podr_dtl_no as 'pickDtlInfo.rtn_podr_dtl_no'
  519. ,dtl.item_id as 'pickDtlInfo.item_id', dtl.item_nm as 'pickDtlInfo.item_nm'
  520. , dtl.rodr_qty as 'pickDtlInfo.rodr_qty' , dtl.col_req_qty as 'pickDtlInfo.col_req_qty'
  521. , dtl.col_req_qty as 'pickDtlInfo.col_qty', dtl.col_amt as 'pickDtlInfo.col_amt'
  522. , date_format(mgnt.col_sch_dt,'%Y.%m.%d') as col_sch_dt, mgnt.pick_mgr_nm, fn_get_telno(mgnt.pick_mgr_tel_no) as pick_mgr_tel_no
  523. , mgnt.whs_id as rtn_whs_id , mgnt.location as rtn_location
  524. , fn_whs_nm(mgnt.brand_id, mgnt.whs_id) as rtn_whs_nm, fn_whs_location_nm(mgnt.brand_id, mgnt.whs_id, mgnt.location) as rtn_location_nm
  525. , base.whs_id, base.location
  526. , 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
  527. , mgnt.spply_id, fn_spply_nm(mgnt.spply_id) as spply_nm
  528. from pick_info_mgnt mgnt
  529. ,pick_dtl_ptcl dtl
  530. ,rtn_odr_dtl_ptcl ptcl
  531. ,rtn_odr_base_info base
  532. where mgnt.col_pick_unq_no = dtl.col_pick_unq_no
  533. and dtl.rtn_podr_unq_no = ptcl.rtn_podr_unq_no
  534. and dtl.rtn_podr_dtl_no = ptcl.rtn_podr_dtl_no
  535. and ptcl.rtn_podr_unq_no = base.rtn_podr_unq_no
  536. and mgnt.brand_id = #{sBrandId}
  537. and mgnt.col_sch_dt between #{fromDt} and #{toDt}
  538. and mgnt.pick_st_cd = 'PICK0'
  539. <if test="sStoreId != null and sStoreId != ''">
  540. and mgnt.store_id = #{sStoreId}
  541. </if>
  542. <if test="sRtnWhsId != null and sRtnWhsId != ''">
  543. and base.whs_id = #{sRtnWhsId}
  544. </if>
  545. <if test="sSpplyId != null and sSpplyId != ''">
  546. and mgnt.spply_id = #{sSpplyId}
  547. </if>
  548. <if test="sWhsId != null and sWhsId != ''">
  549. and dtl.whs_id = #{sWhsId}
  550. </if>
  551. <if test="sItemNm != null and sItemNm != ''">
  552. and (mgnt.col_pick_unq_no like concat('%',#{sItemNm},'%') or dtl.item_id like concat('%',#{sItemNm},'%') or dtl.item_nm like concat('%',#{sItemNm},'%') )
  553. </if>
  554. <choose>
  555. <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
  556. <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
  557. <if test="gridRequest.sord == 'asc'.toString()">
  558. order by mgnt.col_pick_unq_no asc
  559. </if>
  560. <if test="gridRequest.sord == 'desc'.toString()">
  561. order by mgnt.col_pick_unq_no desc
  562. </if>
  563. </if>
  564. </when>
  565. <otherwise>
  566. order by mgnt.col_pick_unq_no desc
  567. </otherwise>
  568. </choose>
  569. <if test="gridRequest.pagingYn == true">
  570. limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
  571. </if>
  572. </select>
  573. <select id="selectColRtnInstGridCnt" resultType="int">
  574. select count(*) as cnt
  575. from pick_info_mgnt mgnt
  576. ,pick_dtl_ptcl dtl
  577. ,rtn_odr_dtl_ptcl ptcl
  578. ,rtn_odr_base_info base
  579. where mgnt.col_pick_unq_no = dtl.col_pick_unq_no
  580. and dtl.rtn_podr_unq_no = ptcl.rtn_podr_unq_no
  581. and dtl.rtn_podr_dtl_no = ptcl.rtn_podr_dtl_no
  582. and ptcl.rtn_podr_unq_no = base.rtn_podr_unq_no
  583. and mgnt.brand_id = #{sBrandId}
  584. and mgnt.col_sch_dt between #{fromDt} and #{toDt}
  585. and mgnt.pick_st_cd = 'PICK0'
  586. <if test="sStoreId != null and sStoreId != ''">
  587. and mgnt.store_id = #{sStoreId}
  588. </if>
  589. <if test="sRtnWhsId != null and sRtnWhsId != ''">
  590. and base.whs_id = #{sRtnWhsId}
  591. </if>
  592. <if test="sSpplyId != null and sSpplyId != ''">
  593. and mgnt.spply_id = #{sSpplyId}
  594. </if>
  595. <if test="sWhsId != null and sWhsId != ''">
  596. and mgnt.whs_id = #{sWhsId}
  597. </if>
  598. <if test="sItemNm != null and sItemNm != ''">
  599. and (mgnt.col_pick_unq_no like concat('%',#{sItemNm},'%') or dtl.item_id like concat('%',#{sItemNm},'%') or dtl.item_nm like concat('%',#{sItemNm},'%') )
  600. </if>
  601. </select>
  602. <insert id="insertRtnProcInfoPtcl">
  603. insert into rtn_proc_info_ptcl
  604. (rtn_mgnt_unq_no, brand_id, store_id, item_id, item_nm
  605. , whs_id, location, unit, unit_amt, rtn_qty
  606. , rtn_odr_qty, col_qty, col_req_dt, col_sch_dt, col_dt
  607. , col_cnfm_nm, col_mgr_nm, col_mgr_tel_no, col_mgr_emal, col_mgr_mbl_no
  608. , col_amt, col_agr_yn, col_cnfm_doc_file_no, sttl_yn, spply_id
  609. , spply_nm, col_pick_unq_no, col_pick_dtl_no, col_cmd_unq_no, col_cmd_dtl_no
  610. , rtn_podr_unq_no, rtn_podr_dtl_no, rtn_req_unq_no, rtn_req_dtl_no, sttl_mgnt_unq_no, sttl_mgnt_dtl_no
  611. , sys_reg_dttm, sys_reg_id, sys_chg_dttm, sys_chg_id)
  612. values
  613. <foreach collection="gridInsertData" item="item" separator=",">
  614. (#{item.rtnMgntUnqNo}, #{item.brandId}, #{item.storeId}, #{item.itemId}, #{item.itemNm}
  615. , #{item.whsId}, #{item.location}, #{item.unit}, #{item.unitAmt}, #{item.rtnQty}
  616. , #{item.rtnOdrQty}, #{item.colQty}, #{item.colReqDt}, #{item.colSchDt}, #{item.colDt}
  617. , #{item.colCnfmNm}, #{item.colMgrNm}, #{item.colMgrTelNo}, #{item.colMgrEmal}, #{item.colMgrMblNo}
  618. , #{item.colAmt}, #{item.colAgrYn}, #{item.colCnfmDocFileNo}, #{item.sttlYn}, #{item.spplyId}
  619. , #{item.spplyNm}, #{item.colPickUnqNo}, #{item.colPickDtlNo}, #{item.colCmdUnqNo}, #{item.colCmdDtlNo}
  620. , #{item.rtnPodrUnqNo}, #{item.rtnPodrDtlNo}, #{item.rtnReqUnqNo}, #{item.rtnReqDtlNo}, #{item.sttlMgntUnqNo}, #{item.sttlMgntDtlNo}
  621. , now(), #{userId}, now(), #{userId})
  622. </foreach>
  623. </insert>
  624. <select id="selectColRtnInstResultGridList" resultType="com.oqpo.api.entity.inoutmng.PickInfoMgntEntity">
  625. select mgnt.brand_id, fn_brand_nm(mgnt.brand_id) as brand_nm
  626. ,mgnt.col_pick_unq_no, dtl.col_pick_dtl_no as 'pickDtlInfo.col_pick_dtl_no'
  627. , dtl.rtn_podr_unq_no as 'pickDtlInfo.rtn_podr_unq_no' , dtl.rtn_podr_dtl_no as 'pickDtlInfo.rtn_podr_dtl_no'
  628. ,dtl.item_id as 'pickDtlInfo.item_id', dtl.item_nm as 'pickDtlInfo.item_nm'
  629. , dtl.rodr_qty as 'pickDtlInfo.rodr_qty' , dtl.col_req_qty as 'pickDtlInfo.col_req_qty'
  630. , dtl.col_qty as 'pickDtlInfo.col_qty', dtl.col_amt as 'pickDtlInfo.col_amt'
  631. , date_format(mgnt.col_sch_dt,'%Y.%m.%d') as col_sch_dt, date_format(mgnt.col_cmplt_dt,'%Y.%m.%d') as col_cmplt_dt
  632. , mgnt.pick_mgr_nm, fn_get_telno(mgnt.pick_mgr_tel_no) as pick_mgr_tel_no
  633. , mgnt.whs_id as rtn_whs_id , mgnt.location as rtn_location
  634. , fn_whs_nm(mgnt.brand_id, mgnt.whs_id) as rtn_whs_nm, fn_whs_location_nm(mgnt.brand_id, mgnt.whs_id, mgnt.location) as rtn_location_nm
  635. , base.whs_id, base.location
  636. , 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
  637. , mgnt.spply_id, fn_spply_nm(mgnt.spply_id) as spply_nm
  638. , dtl.pick_dtl_st_cd as 'pickDtlInfo.pick_dtl_st_cd'
  639. , fn_code_nm('PICK_DTL_ST_CD', dtl.pick_dtl_st_cd) as 'pickDtlInfo.pick_dtl_st_nm'
  640. from pick_info_mgnt mgnt
  641. ,pick_dtl_ptcl dtl
  642. ,rtn_odr_dtl_ptcl ptcl
  643. ,rtn_odr_base_info base
  644. where mgnt.col_pick_unq_no = dtl.col_pick_unq_no
  645. and dtl.rtn_podr_unq_no = ptcl.rtn_podr_unq_no
  646. and dtl.rtn_podr_dtl_no = ptcl.rtn_podr_dtl_no
  647. and ptcl.rtn_podr_unq_no = base.rtn_podr_unq_no
  648. and mgnt.brand_id = #{sBrandId}
  649. and mgnt.col_cmplt_dt between #{fromDt} and #{toDt}
  650. <if test="sStoreId != null and sStoreId != ''">
  651. and mgnt.store_id = #{sStoreId}
  652. </if>
  653. <if test="sRtnWhsId != null and sRtnWhsId != ''">
  654. and base.whs_id = #{sRtnWhsId}
  655. </if>
  656. <if test="sSpplyId != null and sSpplyId != ''">
  657. and mgnt.spply_id = #{sSpplyId}
  658. </if>
  659. <if test="sWhsId != null and sWhsId != ''">
  660. and dtl.whs_id = #{sWhsId}
  661. </if>
  662. <if test="sItemNm != null and sItemNm != ''">
  663. and (mgnt.col_pick_unq_no like concat('%',#{sItemNm},'%') or dtl.item_id like concat('%',#{sItemNm},'%') or dtl.item_nm like concat('%',#{sItemNm},'%') )
  664. </if>
  665. <choose>
  666. <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
  667. <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
  668. <if test="gridRequest.sord == 'asc'.toString()">
  669. order by mgnt.col_pick_unq_no asc
  670. </if>
  671. <if test="gridRequest.sord == 'desc'.toString()">
  672. order by mgnt.col_pick_unq_no desc
  673. </if>
  674. </if>
  675. </when>
  676. <otherwise>
  677. order by mgnt.col_pick_unq_no desc
  678. </otherwise>
  679. </choose>
  680. <if test="gridRequest.pagingYn == true">
  681. limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
  682. </if>
  683. </select>
  684. <select id="selectColRtnInstResultGridCnt" resultType="int">
  685. select count(*) as cnt
  686. from pick_info_mgnt mgnt
  687. ,pick_dtl_ptcl dtl
  688. ,rtn_odr_dtl_ptcl ptcl
  689. ,rtn_odr_base_info base
  690. where mgnt.col_pick_unq_no = dtl.col_pick_unq_no
  691. and dtl.rtn_podr_unq_no = ptcl.rtn_podr_unq_no
  692. and dtl.rtn_podr_dtl_no = ptcl.rtn_podr_dtl_no
  693. and ptcl.rtn_podr_unq_no = base.rtn_podr_unq_no
  694. and mgnt.brand_id = #{sBrandId}
  695. and mgnt.col_cmplt_dt between #{fromDt} and #{toDt}
  696. <if test="sStoreId != null and sStoreId != ''">
  697. and mgnt.store_id = #{sStoreId}
  698. </if>
  699. <if test="sRtnWhsId != null and sRtnWhsId != ''">
  700. and base.whs_id = #{sRtnWhsId}
  701. </if>
  702. <if test="sSpplyId != null and sSpplyId != ''">
  703. and mgnt.spply_id = #{sSpplyId}
  704. </if>
  705. <if test="sWhsId != null and sWhsId != ''">
  706. and dtl.whs_id = #{sWhsId}
  707. </if>
  708. <if test="sItemNm != null and sItemNm != ''">
  709. and (mgnt.col_pick_unq_no like concat('%',#{sItemNm},'%') or dtl.item_id like concat('%',#{sItemNm},'%') or dtl.item_nm like concat('%',#{sItemNm},'%') )
  710. </if>
  711. </select>
  712. <select id="selectColRtnInstProcList" resultType="com.oqpo.api.entity.inoutmng.PickInfoMgntEntity">
  713. select mgnt.brand_id, fn_brand_nm(mgnt.brand_id) as brand_nm
  714. , mgnt.store_id,dtl.item_id as 'pickDtlInfo.item_id', dtl.item_nm as 'pickDtlInfo.item_nm'
  715. , base.whs_id, base.location
  716. , 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
  717. , dtl.unit as 'pickDtlInfo.unit' , dtl.unit_amt as 'pickDtlInfo.unit_amt'
  718. , ptcl.rtn_req_qty as 'pickDtlInfo.rtn_req_qty' , dtl.rodr_qty as 'pickDtlInfo.rodr_qty'
  719. , dtl.col_req_qty as 'pickDtlInfo.col_req_qty'
  720. , date_format(mgnt.col_req_dt,'%Y.%m.%d') as col_req_dt
  721. , date_format(mgnt.col_sch_dt,'%Y.%m.%d') as col_sch_dt
  722. , date_format(mgnt.col_cmplt_dt,'%Y.%m.%d') as col_cmplt_dt
  723. , mgnt.pick_mgr_nm, fn_get_telno(mgnt.pick_mgr_tel_no) as pick_mgr_tel_no
  724. , dtl.col_req_amt as 'pickDtlInfo.col_req_amt'
  725. , mgnt.spply_id, fn_spply_nm(mgnt.spply_id) as spply_nm
  726. , mgnt.col_pick_unq_no, dtl.col_pick_dtl_no as 'pickDtlInfo.col_pick_dtl_no'
  727. , dtl.col_cmd_unq_no as 'pickDtlInfo.col_cmd_unq_no', dtl.col_cmd_dtl_no as 'pickDtlInfo.col_cmd_dtl_no'
  728. , dtl.rtn_podr_unq_no as 'pickDtlInfo.rtn_podr_unq_no', dtl.rtn_podr_dtl_no as 'pickDtlInfo.rtn_podr_dtl_no'
  729. , ptcl.rtn_req_unq_no as 'pickDtlInfo.rtn_req_unq_no', ptcl.rtn_req_dtl_no as 'pickDtlInfo.rtn_req_dtl_no'
  730. , mgnt.whs_dvsn, mgnt.col_dvsn
  731. from pick_info_mgnt mgnt
  732. ,pick_dtl_ptcl dtl
  733. ,rtn_odr_dtl_ptcl ptcl
  734. ,rtn_odr_base_info base
  735. where mgnt.col_pick_unq_no = dtl.col_pick_unq_no
  736. and dtl.rtn_podr_unq_no = ptcl.rtn_podr_unq_no
  737. and dtl.rtn_podr_dtl_no = ptcl.rtn_podr_dtl_no
  738. and ptcl.rtn_podr_unq_no = base.rtn_podr_unq_no
  739. and mgnt.brand_id = #{brandId}
  740. and base.whs_id = #{whsId}
  741. and concat(base.col_pick_unq_no, ptcl.col_pick_dtl_no) in
  742. <foreach collection="gridUpdateData" item="item" separator="," open="(" close=")">
  743. #{item.colPickUnqNo}
  744. </foreach>
  745. </select>
  746. <insert id="insertRtnProcInfoPtcl">
  747. insert into rtn_proc_info_ptcl
  748. (rtn_mgnt_unq_no, brand_id, store_id, item_id, item_nm
  749. , whs_id, location, unit, unit_amt, rtn_req_qty
  750. , rtn_odr_qty, col_req_qty, col_qty, col_req_dt, col_sch_dt
  751. , col_dt, col_cnfm_nm, col_mgr_nm, col_mgr_tel_no, col_mgr_emal
  752. , col_mgr_mbl_no, col_amt, col_agr_yn, col_cnfm_doc_file_no, sttl_yn
  753. , spply_id, spply_nm, col_pick_unq_no, col_pick_dtl_no, col_cmd_unq_no
  754. , col_cmd_dtl_no, rtn_podr_unq_no, rtn_podr_dtl_no, rtn_req_unq_no, rtn_req_dtl_no
  755. , sttl_mgnt_unq_no, sttl_mgnt_dtl_no
  756. , sys_reg_dttm, sys_reg_id, sys_chg_dttm, sys_chg_id)
  757. values
  758. (#{entity.rtnMgntUnqNo}, #{entity.brandId}, #{entity.storeId}, #{entity.itemId}, #{entity.itemNm}
  759. , #{entity.whsId}, #{entity.location}, #{entity.unit}, #{entity.unitAmt}, #{entity.rtnReqQty}
  760. , #{entity.rtnOdrQty}, #{entity.colReqQty}, #{entity.colQty}, #{entity.colReqDt}, #{entity.colSchDt}
  761. , date_fromat(now(),'%Y%m%d'), #{entity.colCnfmNm}, #{entity.colMgrNm}, #{entity.colMgrTelNo}, #{entity.colMgrEmal}
  762. , #{entity.colMgrMblNo}, #{entity.colAmt}, #{entity.colAgrYn}, #{entity.colCnfmDocFileNo}, #{entity.sttlYn}
  763. , #{entity.spplyId}, #{entity.spplyNm}, #{entity.colPickUnqNo}, #{entity.colPickDtlNo}, #{entity.colCmdUnqNo}
  764. , #{entity.colCmdDtlNo}, #{entity.rtnPodrUnqNo}, #{entity.rtnPodrDtlNo}, #{entity.rtnReqUnqNo}, #{entity.rtnReqDtlNo}
  765. , #{entity.sttlMgntUnqNo}, #{entity.sttlMgntDtlNo}
  766. , now(), #{userId}, now(), #{userId})
  767. </insert>
  768. </mapper>