ShmtOdr.xml 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  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.ShmtOdrMapper">
  4. <select id="selectShmtTargetOdrGridList" resultType="com.oqpo.api.entity.pomng.PchOdrBaseInfoEntity">
  5. select base.brand_id, fn_brand_nm(base.brand_id) as brand_nm, base.pch_podr_unq_no
  6. , ptcl.pch_podr_dtl_no as 'pchOdrDtlInfo.pch_podr_dtl_no'
  7. ,ptcl.item_id as 'pchOdrDtlInfo.item_id' , ptcl.item_nm as 'pchOdrDtlInfo.item_nm', base.whs_id, fn_whs_nm(base.brand_id, base.whs_id) as whs_nm
  8. ,base.location, fn_whs_location_nm(base.brand_id, base.whs_id, base.location) as location_nm
  9. ,ptcl.unit_amt as 'pchOdrDtlInfo.unit_amt', ptcl.podr_qty as 'pchOdrDtlInfo.podr_qty'
  10. , ptcl.podr_qty as 'pchOdrDtlInfo.shmt_qty', nvl(stck.stck_qty,0) as 'pchOdrDtlInfo.stck_qty'
  11. ,itm.expry_yn as 'pchOdrDtlInfo.expry_yn', itm.expry_period as 'pchOdrDtlInfo.expry_period'
  12. , date_format(adddate(now(), interval itm.expry_period day),'%Y.%m.%d') as 'pchOdrDtlInfo.expry_date'
  13. ,ptcl.podr_amt as 'pchOdrDtlInfo.podr_amt', date_format(base.dlv_req_dt,'%Y.%m.%d') as dlv_req_dt, base.shmt_whs_id, base.shmt_location
  14. ,fn_whs_nm(base.brand_id, base.shmt_whs_id) as shmt_whs_nm
  15. ,fn_whs_location_nm(base.brand_id, base.shmt_whs_id, base.shmt_location) as shmt_location_nm
  16. from pch_odr_base_info base
  17. join pch_odr_dtl_ptcl ptcl on base.pch_podr_unq_no = ptcl.pch_podr_unq_no and ptcl.podr_dtl_st_cd = 'POD0'
  18. <if test="sItemNm != null and sItemNm != ''">
  19. and (ptcl.item_id like concat('%',#{sItemNm},'%') or ptcl.item_nm like concat('%',#{sItemNm},'%'))
  20. </if>
  21. join item_base_info itm on ptcl.item_id = itm.item_id
  22. left outer join stck_mgnt_base_info stck on base.brand_id = stck.brand_id and base.shmt_whs_id = stck.whs_id and base.shmt_location = stck.location
  23. and ptcl.item_id = stck.item_id
  24. where 1=1
  25. and base.brand_id = #{sBrandId}
  26. and base.dlv_req_dt between #{fromDt} and #{toDt}
  27. and base.dlv_dvsn = 'DL01' -- 본사배송구분
  28. and base.whs_dvsn = 'W02' -- 납품매장창고구분
  29. <if test="sShmtWhsId != null and sShmtWhsId != ''">
  30. and base.shmt_whs_id = #{sShmtWhsId}
  31. </if>
  32. <if test="sWhsId != null and sWhsId != ''">
  33. and base.whs_id = #{sWhsId}
  34. </if>
  35. <choose>
  36. <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
  37. <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
  38. <if test="gridRequest.sord == 'asc'.toString()">
  39. order by pch_req_unq_no asc
  40. </if>
  41. <if test="gridRequest.sord == 'desc'.toString()">
  42. order by pch_req_unq_no desc
  43. </if>
  44. </if>
  45. </when>
  46. <otherwise>
  47. order by pch_req_unq_no desc
  48. </otherwise>
  49. </choose>
  50. <if test="gridRequest.pagingYn == true">
  51. limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
  52. </if>
  53. </select>
  54. <select id="selectShmtTargetOdrGridCnt" resultType="int">
  55. select count(*) as cnt
  56. from pch_odr_base_info base
  57. join pch_odr_dtl_ptcl ptcl on base.pch_podr_unq_no = ptcl.pch_podr_unq_no and ptcl.podr_dtl_st_cd = 'POD0'
  58. <if test="sItemNm != null and sItemNm != ''">
  59. and (ptcl.item_id like concat('%',#{sItemNm},'%') or ptcl.item_nm like concat('%',#{sItemNm},'%'))
  60. </if>
  61. join item_base_info itm on ptcl.item_id = itm.item_id
  62. left outer join stck_mgnt_base_info stck on base.brand_id = stck.brand_id and base.shmt_whs_id = stck.whs_id and base.shmt_location = stck.location
  63. and ptcl.item_id = stck.item_id
  64. where 1=1
  65. and base.brand_id = #{sBrandId}
  66. and base.dlv_req_dt between #{fromDt} and #{toDt}
  67. and base.dlv_dvsn = 'DL01' -- 본사배송구분
  68. and base.whs_dvsn = 'W02' -- 납품매장창고구분
  69. <if test="sShmtWhsId != null and sShmtWhsId != ''">
  70. and base.shmt_whs_id = #{sShmtWhsId}
  71. </if>
  72. <if test="sWhsId != null and sWhsId != ''">
  73. and base.whs_id = #{sWhsId}
  74. </if>
  75. </select>
  76. <insert id="insertShmtOdrBase">
  77. insert into shmt_odr_base_info
  78. (shmt_req_unq_no, shmt_req_st_cd, shmt_reg_dt, shmt_whs_id, shmt_location
  79. , whs_dvsn, brand_id, store_id, podr_dvsn, item_qty
  80. , shmt_total_amt, podr_mgr_nm, dlv_req_dt, whs_id, location
  81. , sys_reg_dttm, sys_reg_id, sys_chg_dttm, sys_chg_id)
  82. values
  83. (#{entity.shmtReqUnqNo}, #{entity.shmtReqStCd}, date_format(now(),'%Y%m%d'), #{entity.shmtWhsId}, #{entity.shmtLocation}
  84. , #{entity.whsDvsn}, #{entity.brandId}, #{entity.storeId}, #{entity.podrDvsn}, #{entity.itemQty}
  85. , #{entity.shmtTotalAmt}, #{entity.podrMgrNm}, #{entity.dlvReqDt}, #{entity.whsId}
  86. , #{entity.location}, NOW(), #{userId}, NOW(), #{userId})
  87. </insert>
  88. <insert id="insertShmtOdrDtl">
  89. insert into shmt_odr_dtl_ptcl
  90. (shmt_req_unq_no, shmt_req_dtl_no, item_id, item_nm, unit_amt
  91. , unit, podr_qty, podr_amt, shmt_qty, shmt_amt, expry_date
  92. , pch_podr_unq_no, pch_podr_dtl_no, pch_req_unq_no, pch_req_dtl_no
  93. , sys_reg_dttm, sys_reg_id, sys_chg_dttm, sys_chg_id)
  94. values
  95. <foreach collection="gridInsertData" item="item" separator=",">
  96. (#{item.shmtReqUnqNo}, #{item.shmtReqDtlNo}, #{item.itemId}, #{item.itemNm}, #{item.unitAmt}
  97. , #{item.unit}, #{item.podrQty}, #{item.podrAmt}, #{item.shmtQty}, #{item.shmtAmt}, #{item.expryDate}
  98. , #{item.pchPodrUnqNo}, #{item.pchPodrDtlNo}, #{item.pchReqUnqNo}, #{item.pchReqDtlNo}
  99. , NOW(), #{userId}, NOW(), #{userId})
  100. </foreach>
  101. </insert>
  102. <select id="selectShmtJobDataList" resultType="com.oqpo.api.entity.pomng.PchOdrBaseInfoEntity">
  103. select base.brand_id,base.pch_podr_unq_no, ptcl.pch_podr_dtl_no as 'pchOdrDtlInfo.pch_podr_dtl_no'
  104. ,ptcl.item_id as 'pchOdrDtlInfo.item_id' , ptcl.item_nm as 'pchOdrDtlInfo.item_nm', base.whs_id
  105. ,base.location, ptcl.unit_amt as 'pchOdrDtlInfo.unit_amt', ptcl.podr_qty as 'pchOdrDtlInfo.podr_qty'
  106. ,nvl(stck.stck_qty,0) as 'pchOdrDtlInfo.stck_qty'
  107. ,itm.expry_yn as 'pchOdrDtlInfo.expry_yn', nvl(itm.expry_period,0) as 'pchOdrDtlInfo.expry_period'
  108. ,ptcl.podr_amt as 'pchOdrDtlInfo.podr_amt', date_format(base.dlv_req_dt,'%Y.%m.%d') as dlv_req_dt
  109. , base.shmt_whs_id, base.shmt_location, ptcl.pch_req_unq_no as 'pchOdrDtlInfo.pch_req_unq_no' , ptcl.pch_req_dtl_no as 'pchOdrDtlInfo.pch_req_dtl_no'
  110. , base.store_id , base.podr_mgr_nm , base.podr_mgr_tel_no
  111. , fn_get_telno((select tel_no from store_base_info where store_id = base.store_id )) as deli_tel_no
  112. , date_format(base.podr_dt,'%Y%m%d') as podr_dt
  113. , base.spply_id, fn_spply_nm(base.spply_id) as spply_nm
  114. from pch_odr_base_info base
  115. join pch_odr_dtl_ptcl ptcl on base.pch_podr_unq_no = ptcl.pch_podr_unq_no and ptcl.podr_dtl_st_cd = 'POD0'
  116. join item_base_info itm on ptcl.item_id = itm.item_id
  117. left outer join stck_mgnt_base_info stck on base.brand_id = stck.brand_id and base.shmt_whs_id = stck.whs_id and base.shmt_location = stck.location
  118. and ptcl.item_id = stck.item_id
  119. where 1=1
  120. and base.brand_id = #{brandId}
  121. and concat(base.pch_podr_unq_no,ptcl.pch_podr_dtl_no) in
  122. <foreach collection="gridInsertData" item="item" separator="," open="(" close=")">
  123. concat(#{item.pchPodrUnqNo},#{item.pchPodrDtlNo})
  124. </foreach>
  125. order by base.brand_id, base.shmt_whs_id, base.shmt_location, base.whs_id,base.location
  126. </select>
  127. <insert id="insertDeliInfoMngt">
  128. INSERT INTO deli_info_mgnt
  129. (dlv_sttmt_unq_no, spply_id, spply_nm, dlv_reg_dt, dlv_amt
  130. , dlv_mgr_nm, dlv_mgr_tel_no, dlv_mgr_emal, dlv_mgr_mbl_no, vndr_tel_no
  131. , dlv_st_cd, podr_reg_dt, dlv_req_dt, dlv_sch_dt, dlv_cmplt_dt
  132. , whs_id, location, whs_dvsn, brand_id,store_id
  133. , sys_reg_dttm, sys_reg_id, sys_chg_dttm, sys_chg_id)
  134. VALUES
  135. (#{entity.dlvSttmtUnqNo}, #{entity.spplyId}, #{entity.spplyNm}, date_format(now(),'%Y%m%d'), #{entity.dlvAmt}
  136. , #{entity.dlvMgrNm}, #{entity.dlvMgrTelNo}, #{entity.dlvMgrEmal}, #{entity.dlvMgrMblNo}, #{entity.vndrTelNo}
  137. , #{entity.dlvStCd}, #{entity.podrRegDt}, #{entity.dlvReqDt}, #{entity.dlvSchDt}, #{entity.dlvCmpltDt}
  138. , #{entity.whsId}, #{entity.location}, #{entity.whsDvsn}, #{entity.brandId}, #{entity.storeId}
  139. , NOW(), #{userId}, NOW(), #{userId})
  140. </insert>
  141. <insert id="insertDeliDtlPtcl" >
  142. INSERT INTO deli_dtl_ptcl
  143. (dlv_sttmt_unq_no, dlv_sttmt_dtl_no, pch_podr_unq_no, pch_podr_dtl_no, pch_req_unq_no
  144. , pch_req_dtl_no, item_id, item_nm, unit, unit_amt
  145. , price_unit, podr_qty, dlv_qty, podr_amt, dlv_amt
  146. , expry_date, delay_yn, delay_rsn
  147. , sys_reg_dttm, sys_reg_id, sys_chg_dttm, sys_chg_id)
  148. VALUES
  149. <foreach collection="gridInsertData" item="item" separator=",">
  150. (#{item.dlvSttmtUnqNo}, #{item.dlvSttmtDtlNo}, #{item.pchPodrUnqNo}, #{item.pchPodrDtlNo}, #{item.pchReqUnqNo}
  151. , #{item.pchReqDtlNo}, #{item.itemId}, #{item.itemNm}, #{item.unit}, #{item.unitAmt}
  152. , #{item.priceUnit}, #{item.podrQty}, #{item.dlvQty}, #{item.podrAmt}, #{item.dlvAmt}
  153. , #{item.expryDate}, #{item.delayYn}, #{item.delayRsn}
  154. , NOW(), #{userId}, NOW(), #{userId})
  155. </foreach>
  156. </insert>
  157. <select id="selectShmtSearchGridList" resultType="com.oqpo.api.entity.inoutmng.ShmtOdrBaseEntity">
  158. /* shmtOdr.selectShmtSearchGridList */
  159. select base.shmt_req_unq_no , ptcl.shmt_req_dtl_no as 'shmtOdrDtlInfo.shmt_req_dtl_no' , base.brand_id, fn_brand_nm(base.brand_id) as brand_nm
  160. ,ptcl.pch_podr_unq_no as 'shmtOdrDtlInfo.pch_podr_unq_no' , ptcl.pch_podr_dtl_no as 'shmtOdrDtlInfo.pch_podr_dtl_no'
  161. ,base.shmt_req_st_cd, fn_code_nm('SHMT_REQ_ST_CD',base.shmt_req_st_cd) as shmt_req_st_nm , ptcl.item_id as 'shmtOdrDtlInfo.item_id'
  162. ,ptcl.item_nm as 'shmtOdrDtlInfo.item_nm' , base.whs_id, fn_whs_nm(base.brand_id, base.whs_id) as whs_nm
  163. ,base.location, fn_whs_location_nm(base.brand_id, base.whs_id, base.location) as location_nm , ptcl.shmt_qty as 'shmtOdrDtlInfo.shmt_qty'
  164. ,ptcl.shmt_amt as 'shmtOdrDtlInfo.shmt_amt' , nvl(proc.whs_qty,0) as 'whsProcInfo.whs_qty' , nvl(proc.whs_amt,0) as 'whsProcInfo.whs_amt'
  165. ,date_format(proc.whs_dt,'%Y.%m.%d') as 'whsProcInfo.whs_dt', proc.whs_cnfm_nm as 'whsProcInfo.whs_cnfm_nm'
  166. ,deli.dlv_sttmt_unq_no
  167. from shmt_odr_base_info base
  168. join shmt_odr_dtl_ptcl ptcl on base.shmt_req_unq_no = ptcl.shmt_req_unq_no
  169. join deli_dtl_ptcl deli on deli.pch_podr_unq_no = ptcl.pch_podr_unq_no and deli.pch_podr_dtl_no = ptcl.pch_podr_dtl_no
  170. left outer join whs_proc_info_ptcl proc on proc.dlv_sttmt_unq_no = deli.dlv_sttmt_unq_no and proc.dlv_sttmt_dtl_no = deli.dlv_sttmt_dtl_no
  171. where 1=1
  172. and base.brand_id = #{sBrandId}
  173. <if test="fromDt != null and fromDt != '' and toDt != null and toDt != ''">
  174. and base.shmt_reg_dt between #{fromDt} and #{toDt}
  175. </if>
  176. <if test="sShmtWhsId != null and sShmtWhsId != ''">
  177. and base.shmt_whs_id = #{sShmtWhsId}
  178. </if>
  179. <if test="sShmtReqStCd != null and sShmtReqStCd != ''">
  180. and base.shmt_req_st_cd = #{sShmtReqStCd}
  181. </if>
  182. <if test="swhsId != null and swhsId != ''">
  183. and base.whs_id = #{swhsId}
  184. </if>
  185. <if test="sItemNm != null and sItemNm != ''">
  186. and (ptcl.item_id like concat('%', #{sItemNm},'%') or ptcl.item_nm like concat('%',#{sItemNm},'%'))
  187. </if>
  188. <choose>
  189. <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
  190. <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
  191. <if test="gridRequest.sord == 'asc'.toString()">
  192. order by pch_req_unq_no asc
  193. </if>
  194. <if test="gridRequest.sord == 'desc'.toString()">
  195. order by pch_req_unq_no desc
  196. </if>
  197. </if>
  198. </when>
  199. <otherwise>
  200. order by pch_req_unq_no desc
  201. </otherwise>
  202. </choose>
  203. <if test="gridRequest.pagingYn == true">
  204. limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
  205. </if>
  206. </select>
  207. <select id="selectShmtSearchGridCnt" resultType="int">
  208. /* shmtOdr.selectShmtSearchGridCnt */
  209. select count(*)
  210. from shmt_odr_base_info base
  211. join shmt_odr_dtl_ptcl ptcl on base.shmt_req_unq_no = ptcl.shmt_req_unq_no
  212. join deli_dtl_ptcl deli on deli.pch_podr_unq_no = ptcl.pch_podr_unq_no and deli.pch_podr_dtl_no = ptcl.pch_podr_dtl_no
  213. left outer join whs_proc_info_ptcl proc on proc.dlv_sttmt_unq_no = deli.dlv_sttmt_unq_no and proc.dlv_sttmt_dtl_no = deli.dlv_sttmt_dtl_no
  214. where 1=1
  215. and base.brand_id = #{sBrandId}
  216. <if test="fromDt != null and fromDt != '' and toDt != null and toDt != ''">
  217. and base.shmt_reg_dt between #{fromDt} and #{toDt}
  218. </if>
  219. <if test="sShmtWhsId != null and sShmtWhsId != ''">
  220. and base.shmt_whs_id = #{sShmtWhsId}
  221. </if>
  222. <if test="sShmtReqStCd != null and sShmtReqStCd != ''">
  223. and base.shmt_req_st_cd = #{sShmtReqStCd}
  224. </if>
  225. <if test="swhsId != null and swhsId != ''">
  226. and base.whs_id = #{swhsId}
  227. </if>
  228. <if test="sItemNm != null and sItemNm != ''">
  229. and (ptcl.item_id like concat('%', #{sItemNm},'%') or ptcl.item_nm like concat('%',#{sItemNm},'%'))
  230. </if>
  231. </select>
  232. <select id="selectInvInfo" resultType="com.oqpo.api.entity.inoutmng.DeliInfoMgntEntity">
  233. select date_format(deli.dlv_reg_dt,'%Y.%m.%d') as dlv_reg_dt, deli.dlv_sttmt_unq_no, date_format(deli.dlv_sch_dt,'%Y.%m.%d') as dvl_sch_dt
  234. , deli.dlv_mgr_nm, fn_get_telno( deli.dlv_mgr_tel_no) as dlv_mgr_tel_no
  235. , fn_whs_nm(deli.brand_id, deli.whs_id) as whs_nm, fn_whs_location_nm(deli.brand_id, deli.whs_id, deli.location) as location_nm
  236. , whs.mgr_tel_no
  237. , case when deli.spply_id is null or deli.spply_id = '' then 'DL01' else 'DL02' end as deli_dvsn -- 배송주체
  238. , deli.whs_dvsn -- 납품정보
  239. , concat(whs.addr1 ,' ',whs.addr2) as whs_addr
  240. , fn_get_telno(whs.mgr_tel_no) as whs_mgr_tel_no
  241. from deli_info_mgnt deli
  242. join whs_mgnt_base_info whs on whs.brand_id = deli.brand_id and whs.whs_id = deli.whs_id
  243. where deli.brand_id = #{brandId}
  244. and deli.dlv_sttmt_unq_no = #{dlvSttmtUnqNo}
  245. </select>
  246. <select id="selectInvDtlList" resultType="com.oqpo.api.entity.inoutmng.DeliDtlMgntEntity">
  247. select ptcl.pch_podr_unq_no, ptcl.item_id, ptcl.item_nm, ptcl.podr_qty, ptcl.dlv_qty, date_format(ptcl.expry_date,'%Y.%m.%d') as expry_date
  248. from deli_info_mgnt info
  249. , deli_dtl_ptcl ptcl
  250. where 1 = 1
  251. and info.dlv_sttmt_unq_no = ptcl.dlv_sttmt_unq_no
  252. and info.brand_id = #{brandId}
  253. and info.dlv_sttmt_unq_no = #{dlvSttmtUnqNo}
  254. </select>
  255. <select id="selectSpplyTargetOdrGridList" resultType="com.oqpo.api.entity.pomng.PchOdrBaseInfoEntity">
  256. select base.brand_id, fn_brand_nm(base.brand_id) as brand_nm, base.pch_podr_unq_no
  257. , ptcl.pch_podr_dtl_no as 'pchOdrDtlInfo.pch_podr_dtl_no'
  258. ,ptcl.item_id as 'pchOdrDtlInfo.item_id' , ptcl.item_nm as 'pchOdrDtlInfo.item_nm', base.whs_id, fn_whs_nm(base.brand_id, base.whs_id) as whs_nm
  259. ,base.location, fn_whs_location_nm(base.brand_id, base.whs_id, base.location) as location_nm
  260. ,ptcl.unit_amt as 'pchOdrDtlInfo.unit_amt', ptcl.podr_qty as 'pchOdrDtlInfo.podr_qty'
  261. , ptcl.podr_qty as 'pchOdrDtlInfo.shmt_qty'
  262. ,ptcl.podr_amt as 'pchOdrDtlInfo.podr_amt', date_format(base.dlv_req_dt,'%Y.%m.%d') as dlv_req_dt, base.shmt_whs_id, base.shmt_location
  263. from pch_odr_base_info base
  264. join pch_odr_dtl_ptcl ptcl on base.pch_podr_unq_no = ptcl.pch_podr_unq_no and ptcl.podr_dtl_st_cd = 'POD0'
  265. <if test="sItemNm != null and sItemNm != ''">
  266. and (ptcl.item_id like concat('%',#{sItemNm},'%') or ptcl.item_nm like concat('%',#{sItemNm},'%') or ptcl.pch_podr_unq_no like concat('%',#{sItemNm},'%'))
  267. </if>
  268. join item_base_info itm on ptcl.item_id = itm.item_id
  269. left outer join stck_mgnt_base_info stck on base.brand_id = stck.brand_id and base.shmt_whs_id = stck.whs_id and base.shmt_location = stck.location
  270. and ptcl.item_id = stck.item_id
  271. where 1=1
  272. and base.brand_id = #{sBrandId}
  273. and base.dlv_req_dt between #{fromDt} and #{toDt}
  274. and base.dlv_dvsn = 'DL02' -- 본사배송구분
  275. and base.spply_id = #{sSpplyId}
  276. <if test="sWhsId != null and sWhsId != ''">
  277. and base.whs_id = #{sWhsId}
  278. </if>
  279. <choose>
  280. <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
  281. <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
  282. <if test="gridRequest.sord == 'asc'.toString()">
  283. order by base.pch_podr_unq_no asc, ptcl.pch_podr_dtl_no asc
  284. </if>
  285. <if test="gridRequest.sord == 'desc'.toString()">
  286. order by base.pch_podr_unq_no desc, ptcl.pch_podr_dtl_no desc
  287. </if>
  288. </if>
  289. </when>
  290. <otherwise>
  291. order by base.pch_podr_unq_no asc
  292. </otherwise>
  293. </choose>
  294. <if test="gridRequest.pagingYn == true">
  295. limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
  296. </if>
  297. </select>
  298. <select id="selectSpplyTargetOdrGridCnt" resultType="int">
  299. select count(*)
  300. from pch_odr_base_info base
  301. join pch_odr_dtl_ptcl ptcl on base.pch_podr_unq_no = ptcl.pch_podr_unq_no and ptcl.podr_dtl_st_cd = 'POD0'
  302. <if test="sItemNm != null and sItemNm != ''">
  303. and (ptcl.item_id like concat('%',#{sItemNm},'%') or ptcl.item_nm like concat('%',#{sItemNm},'%') or ptcl.pch_podr_unq_no like concat('%',#{sItemNm},'%'))
  304. </if>
  305. join item_base_info itm on ptcl.item_id = itm.item_id
  306. left outer join stck_mgnt_base_info stck on base.brand_id = stck.brand_id and base.shmt_whs_id = stck.whs_id and base.shmt_location = stck.location
  307. and ptcl.item_id = stck.item_id
  308. where 1=1
  309. and base.brand_id = #{sBrandId}
  310. and base.dlv_req_dt between #{fromDt} and #{toDt}
  311. and base.dlv_dvsn = 'DL02' -- 본사배송구분
  312. and base.spply_id = #{sSpplyId}
  313. <if test="sWhsId != null and sWhsId != ''">
  314. and base.whs_id = #{sWhsId}
  315. </if>
  316. </select>
  317. <select id="selectSpplyShmtOdrInfo" resultType="com.oqpo.api.entity.pomng.PchOdrBaseInfoEntity">
  318. select base.brand_id, fn_brand_nm(base.brand_id) as brand_nm, base.pch_podr_unq_no, date_format(now(), '%Y.%m.%d') as dlv_req_dt
  319. , (select sum(podr_amt) from pch_odr_dtl_ptcl where pch_podr_unq_no = '22102500006015' and podr_dtl_st_cd = 'POD0' ) as podr_total_amt
  320. , base.whs_id, fn_whs_nm(base.brand_id, base.whs_id) as whs_nm
  321. , base.location, fn_whs_location_nm(brand_id, base.whs_id, base.location) as location_nm
  322. , fn_get_telno((select tel_no from store_base_info where store_id = base.store_id )) as deli_tel_no
  323. from pch_odr_base_info base
  324. where 1=1
  325. and base.brand_id = #{brandId}
  326. and base.spply_id = #{spplyId}
  327. and base.dlv_dvsn = 'DL02'
  328. and base.pch_podr_unq_no = #{pchPodrUnqNo}
  329. </select>
  330. <select id="selectSpplyShmtOdrList" resultType="com.oqpo.api.entity.pomng.PchOdrDtlPtclEntity">
  331. select ptcl.pch_podr_unq_no, ptcl.pch_podr_dtl_no, ptcl.item_id, ptcl.item_nm, ptcl.unit, ptcl.podr_qty, ptcl.podr_qty as shmt_qty
  332. ,itm.expry_yn as expry_yn, itm.expry_period as expry_period
  333. , date_format(adddate(now(), interval itm.expry_period day),'%Y.%m.%d') as expry_date
  334. from pch_odr_dtl_ptcl ptcl
  335. join item_base_info itm on ptcl.item_id = itm.item_id
  336. where ptcl.pch_podr_unq_no = #{pchPodrUnqNo}
  337. and ptcl.podr_dtl_st_cd = 'POD0'
  338. </select>
  339. <select id="selectDeliGridList" resultType="com.oqpo.api.entity.inoutmng.DeliInfoMgntEntity">
  340. select info.brand_id, fn_brand_nm(info.brand_id) as brand_nm, info.dlv_sttmt_unq_no
  341. , info.spply_id, info.spply_nm, info.dlv_st_cd, fn_code_nm(upper('dlv_st_cd'), info.dlv_st_cd) as dlv_st_nm
  342. , info.whs_id, info.location, fn_whs_nm(info.brand_id, info.whs_id) as whs_nm
  343. , fn_whs_location_nm(info.brand_id, info.whs_id, info.location) as location_nm
  344. , date_format(info.podr_reg_dt, '%Y.%m.%d') as podr_reg_dt, date_format(info.dlv_req_dt, '%y.%m.%d') as dlv_req_dt
  345. , date_format(info.dlv_reg_dt, '%Y.%m.%d') as dlv_req_dt, date_format(info.dlv_sch_dt, '%y.%m.%d') as dlv_sch_dt
  346. , ptcl.item_id as 'deliDtlMgntInfo.item_id', ptcl.item_nm as 'deliDtlMgntInfo.item_nm'
  347. , ptcl.podr_qty as 'deliDtlMgntInfo.podr_qty', ptcl.dlv_qty as 'deliDtlMgntInfo.dlv_qty'
  348. , ptcl.unit as 'deliDtlMgntInfo.unit', ptcl.unit_amt as 'deliDtlMgntInfo.unit_amt'
  349. , info.dlv_mgr_nm , info.dlv_mgr_mbl_no
  350. from deli_info_mgnt info
  351. , deli_dtl_ptcl ptcl
  352. where 1 = 1
  353. and info.dlv_sttmt_unq_no = ptcl.dlv_sttmt_unq_no
  354. and info.brand_id = #{sBrandId}
  355. <if test="dtGubun eq '1'.toString()">
  356. and info.podr_reg_dt between #{fromDt} and #{toDt} -- 1인경우 발주생성일로 조회
  357. </if>
  358. <if test="dtGubun eq '2'.toString()">
  359. and info.dlv_req_dt between #{fromDt} and #{toDt} -- 2인경우 납품요청일로 조회
  360. </if>
  361. <if test="dtGubun eq '3'.toString()">
  362. and info.dlv_reg_dt between #{fromDt} and #{toDt} -- 3인경우 납품생성일로 조회
  363. </if>
  364. <if test="sDlvStCd != null and sDlvStCd != ''">
  365. and info.dlv_st_cd = #{sDlvStCd} -- 납품상태
  366. </if>
  367. <if test="sSpplyId != null and sSpplyId != ''">
  368. and info.spply_id = #{sSpplyId}
  369. </if>
  370. <if test="sWhsId != null and sWhsId != ''">
  371. and info.whs_id = #{sWhsId}
  372. </if>
  373. <if test="sItemNm != null and sItemNm != ''">
  374. and (ptcl.item_id like concat('%', #{sItemNm}, '%') or ptcl.item_nm like concat('%', #{sItemNm}, '%'))
  375. </if>
  376. <choose>
  377. <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
  378. <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
  379. <if test="gridRequest.sord == 'asc'.toString()">
  380. order by pch_req_unq_no asc
  381. </if>
  382. <if test="gridRequest.sord == 'desc'.toString()">
  383. order by pch_req_unq_no desc
  384. </if>
  385. </if>
  386. </when>
  387. <otherwise>
  388. order by pch_req_unq_no desc
  389. </otherwise>
  390. </choose>
  391. <if test="gridRequest.pagingYn == true">
  392. limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
  393. </if>
  394. </select>
  395. <select id="selectDeliGridCnt" resultType="int">
  396. select count(*)
  397. from deli_info_mgnt info
  398. , deli_dtl_ptcl ptcl
  399. where 1 = 1
  400. and info.dlv_sttmt_unq_no = ptcl.dlv_sttmt_unq_no
  401. and info.brand_id = #{sBrandId}
  402. <if test="dtGubun eq '1'.toString()">
  403. and info.podr_reg_dt between #{fromDt} and #{toDt} -- 1인경우 발주생성일로 조회
  404. </if>
  405. <if test="dtGubun eq '2'.toString()">
  406. and info.dlv_req_dt between #{fromDt} and #{toDt} -- 2인경우 납품요청일로 조회
  407. </if>
  408. <if test="dtGubun eq '3'.toString()">
  409. and info.dlv_reg_dt between #{fromDt} and #{toDt} -- 3인경우 납품생성일로 조회
  410. </if>
  411. <if test="sDlvStCd != null and sDlvStCd != ''">
  412. and info.dlv_st_cd = #{sDlvStCd} -- 납품상태
  413. </if>
  414. <if test="sSpplyId != null and sSpplyId != ''">
  415. and info.spply_id = #{sSpplyId}
  416. </if>
  417. <if test="sWhsId != null and sWhsId != ''">
  418. and info.whs_id = #{sWhsId}
  419. </if>
  420. <if test="sItemNm != null and sItemNm != ''">
  421. and (ptcl.item_id like concat('%', #{sItemNm}, '%') or ptcl.item_nm like concat('%', #{sItemNm}, '%'))
  422. </if>
  423. </select>
  424. </mapper>