ShmtOdr.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  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. from pch_odr_base_info base
  114. join pch_odr_dtl_ptcl ptcl on base.pch_podr_unq_no = ptcl.pch_podr_unq_no and ptcl.podr_dtl_st_cd = 'POD0'
  115. join item_base_info itm on ptcl.item_id = itm.item_id
  116. 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
  117. and ptcl.item_id = stck.item_id
  118. where 1=1
  119. and base.brand_id = #{brandId}
  120. and concat(base.pch_podr_unq_no,ptcl.pch_podr_dtl_no) in
  121. <foreach collection="gridInsertData" item="item" separator="," open="(" close=")">
  122. concat(#{item.pchPodrUnqNo},#{item.pchPodrDtlNo})
  123. </foreach>
  124. order by base.brand_id, base.shmt_whs_id, base.shmt_location, base.whs_id,base.location
  125. </select>
  126. <insert id="insertDeliInfoMngt">
  127. INSERT INTO deli_info_mgnt
  128. (dlv_sttmt_unq_no, spply_id, spply_nm, dlv_reg_dt, dlv_amt
  129. , dlv_mgr_nm, dlv_mgr_tel_no, dlv_mgr_emal, dlv_mgr_mbl_no, vndr_tel_no
  130. , dlv_st_cd, podr_reg_dt, dlv_req_dt, dlv_sch_dt, dlv_cmplt_dt
  131. , whs_id, location, whs_dvsn, brand_id,store_id
  132. , sys_reg_dttm, sys_reg_id, sys_chg_dttm, sys_chg_id)
  133. VALUES
  134. (#{entity.dlvSttmtUnqNo}, #{entity.spplyId}, #{entity.spplyNm}, date_format(now(),'%Y%m%d'), #{entity.dlvAmt}
  135. , #{entity.dlvMgrNm}, #{entity.dlvMgrTelNo}, #{entity.dlvMgrEmal}, #{entity.dlvMgrMblNo}, #{entity.vndrTelNo}
  136. , #{entity.dlvStCd}, #{entity.podrRegDt}, #{entity.dlvReqDt}, #{entity.dlvSchDt}, #{entity.dlvCmpltDt}
  137. , #{entity.whsId}, #{entity.location}, #{entity.whsDvsn}, #{entity.brandId}, #{entity.storeId}
  138. , NOW(), #{userId}, NOW(), #{userId})
  139. </insert>
  140. <insert id="insertDeliDtlPtcl" >
  141. INSERT INTO deli_dtl_ptcl
  142. (dlv_sttmt_unq_no, dlv_sttmt_dtl_no, pch_podr_unq_no, pch_podr_dtl_no, pch_req_unq_no
  143. , pch_req_dtl_no, item_id, item_nm, unit, unit_amt
  144. , price_unit, podr_qty, dlv_qty, podr_amt, dlv_amt
  145. , expry_date, delay_yn, delay_rsn
  146. , sys_reg_dttm, sys_reg_id, sys_chg_dttm, sys_chg_id)
  147. VALUES
  148. <foreach collection="gridInsertData" item="item" separator=",">
  149. (#{item.dlvSttmtUnqNo}, #{item.dlvSttmtDtlNo}, #{item.pchPodrUnqNo}, #{item.pchPodrDtlNo}, #{item.pchReqUnqNo}
  150. , #{item.pchReqDtlNo}, #{item.itemId}, #{item.itemNm}, #{item.unit}, #{item.unitAmt}
  151. , #{item.priceUnit}, #{item.podrQty}, #{item.dlvQty}, #{item.podrAmt}, #{item.dlvAmt}
  152. , #{item.expryDate}, #{item.delayYn}, #{item.delayRsn}
  153. , NOW(), #{userId}, NOW(), #{userId})
  154. </foreach>
  155. </insert>
  156. <select id="selectShmtSearchGridList" resultType="com.oqpo.api.entity.inoutmng.ShmtOdrBaseEntity">
  157. /* shmtOdr.selectShmtSearchGridList */
  158. 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
  159. ,ptcl.pch_podr_unq_no as 'shmtOdrDtlInfo.pch_podr_unq_no' , ptcl.pch_podr_dtl_no as 'shmtOdrDtlInfo.pch_podr_dtl_no'
  160. ,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'
  161. ,ptcl.item_nm as 'shmtOdrDtlInfo.item_nm' , base.whs_id, fn_whs_nm(base.brand_id, base.whs_id) as whs_nm
  162. ,base.location, fn_whs_location_nm(base.brand_id, base.whs_id, base.location) as location_nm , ptcl.shmt_qty as 'shmtOdrDtlInfo.shmt_qty'
  163. ,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'
  164. ,date_format(proc.whs_dt,'%Y.%m.%d') as 'whsProcInfo.whs_dt', proc.whs_cnfm_nm as 'whsProcInfo.whs_cnfm_nm'
  165. ,deli.dlv_sttmt_unq_no
  166. from shmt_odr_base_info base
  167. join shmt_odr_dtl_ptcl ptcl on base.shmt_req_unq_no = ptcl.shmt_req_unq_no
  168. 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
  169. 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
  170. where 1=1
  171. and base.brand_id = #{sBrandId}
  172. <if test="fromDt != null and fromDt != '' and toDt != null and toDt != ''">
  173. and base.shmt_reg_dt between #{fromDt} and #{toDt}
  174. </if>
  175. <if test="sShmtWhsId != null and sShmtWhsId != ''">
  176. and base.shmt_whs_id = #{sShmtWhsId}
  177. </if>
  178. <if test="sShmtReqStCd != null and sShmtReqStCd != ''">
  179. and base.shmt_req_st_cd = #{sShmtReqStCd}
  180. </if>
  181. <if test="swhsId != null and swhsId != ''">
  182. and base.whs_id = #{swhsId}
  183. </if>
  184. <if test="sItemNm != null and sItemNm != ''">
  185. and (ptcl.item_id like concat('%', #{sItemNm},'%') or ptcl.item_nm like concat('%',#{sItemNm},'%'))
  186. </if>
  187. <choose>
  188. <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
  189. <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
  190. <if test="gridRequest.sord == 'asc'.toString()">
  191. order by pch_req_unq_no asc
  192. </if>
  193. <if test="gridRequest.sord == 'desc'.toString()">
  194. order by pch_req_unq_no desc
  195. </if>
  196. </if>
  197. </when>
  198. <otherwise>
  199. order by pch_req_unq_no desc
  200. </otherwise>
  201. </choose>
  202. <if test="gridRequest.pagingYn == true">
  203. limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
  204. </if>
  205. </select>
  206. <select id="selectShmtSearchGridCnt" resultType="int">
  207. /* shmtOdr.selectShmtSearchGridCnt */
  208. select count(*)
  209. from shmt_odr_base_info base
  210. join shmt_odr_dtl_ptcl ptcl on base.shmt_req_unq_no = ptcl.shmt_req_unq_no
  211. 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
  212. 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
  213. where 1=1
  214. and base.brand_id = #{sBrandId}
  215. <if test="fromDt != null and fromDt != '' and toDt != null and toDt != ''">
  216. and base.shmt_reg_dt between #{fromDt} and #{toDt}
  217. </if>
  218. <if test="sShmtWhsId != null and sShmtWhsId != ''">
  219. and base.shmt_whs_id = #{sShmtWhsId}
  220. </if>
  221. <if test="sShmtReqStCd != null and sShmtReqStCd != ''">
  222. and base.shmt_req_st_cd = #{sShmtReqStCd}
  223. </if>
  224. <if test="swhsId != null and swhsId != ''">
  225. and base.whs_id = #{swhsId}
  226. </if>
  227. <if test="sItemNm != null and sItemNm != ''">
  228. and (ptcl.item_id like concat('%', #{sItemNm},'%') or ptcl.item_nm like concat('%',#{sItemNm},'%'))
  229. </if>
  230. </select>
  231. <select id="selectInvInfo" resultType="com.oqpo.api.entity.inoutmng.DeliInfoMgntEntity">
  232. 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
  233. , deli.dlv_mgr_nm, fn_get_telno( deli.dlv_mgr_tel_no) as dlv_mgr_tel_no
  234. , 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
  235. , whs.mgr_tel_no
  236. , case when deli.spply_id is null or deli.spply_id = '' then 'DL01' else 'DL02' end as deli_dvsn -- 배송주체
  237. , deli.whs_dvsn -- 납품정보
  238. , concat(whs.addr1 ,' ',whs.addr2) as whs_addr
  239. , fn_get_telno(whs.mgr_tel_no) as whs_mgr_tel_no
  240. from deli_info_mgnt deli
  241. join whs_mgnt_base_info whs on whs.brand_id = deli.brand_id and whs.whs_id = deli.whs_id
  242. where deli.brand_id = #{brandId}
  243. and deli.dlv_sttmt_unq_no = #{dlvSttmtUnqNo}
  244. </select>
  245. <select id="selectInvDtlList" resultType="com.oqpo.api.entity.inoutmng.DeliDtlMgntEntity">
  246. 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
  247. from deli_info_mgnt info
  248. , deli_dtl_ptcl ptcl
  249. where 1 = 1
  250. and info.dlv_sttmt_unq_no = ptcl.dlv_sttmt_unq_no
  251. and info.brand_id = #{brandId}
  252. and info.dlv_sttmt_unq_no = #{dlvSttmtUnqNo}
  253. </select>
  254. </mapper>