ShmtOdr.xml 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816
  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, shmt_dtl_st_cd
  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}, 'SHMD1'
  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. , nvl(fn_get_telno((select mgr_tel_no from whs_mgnt_base_info where brand_id = base.brand_id and whs_id = base.whs_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,dlv_dtl_st_cd
  147. , shmt_req_unq_no, shmt_req_dtl_no
  148. , sys_reg_dttm, sys_reg_id, sys_chg_dttm, sys_chg_id)
  149. VALUES
  150. <foreach collection="gridInsertData" item="item" separator=",">
  151. (#{item.dlvSttmtUnqNo}, #{item.dlvSttmtDtlNo}, #{item.pchPodrUnqNo}, #{item.pchPodrDtlNo}, #{item.pchReqUnqNo}
  152. , #{item.pchReqDtlNo}, #{item.itemId}, #{item.itemNm}, #{item.unit}, #{item.unitAmt}
  153. , #{item.priceUnit}, #{item.podrQty}, #{item.dlvQty}, #{item.podrAmt}, #{item.dlvAmt}
  154. , #{item.expryDate}, #{item.delayYn}, #{item.delayRsn}, 'DLD0'
  155. , #{item.shmtReqUnqNo}, #{item.shmtReqDtlNo}
  156. , NOW(), #{userId}, NOW(), #{userId})
  157. </foreach>
  158. </insert>
  159. <select id="selectShmtSearchGridList" resultType="com.oqpo.api.entity.inoutmng.ShmtOdrBaseEntity">
  160. /* shmtOdr.selectShmtSearchGridList */
  161. 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
  162. ,ptcl.pch_podr_unq_no as 'shmtOdrDtlInfo.pch_podr_unq_no' , ptcl.pch_podr_dtl_no as 'shmtOdrDtlInfo.pch_podr_dtl_no'
  163. ,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'
  164. ,ptcl.item_nm as 'shmtOdrDtlInfo.item_nm' , base.whs_id, fn_whs_nm(base.brand_id, base.whs_id) as whs_nm
  165. ,base.location, fn_whs_location_nm(base.brand_id, base.whs_id, base.location) as location_nm , ptcl.shmt_qty as 'shmtOdrDtlInfo.shmt_qty'
  166. ,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'
  167. ,date_format(proc.whs_dt,'%Y.%m.%d') as 'whsProcInfo.whs_dt', proc.whs_cnfm_nm as 'whsProcInfo.whs_cnfm_nm'
  168. ,deli.dlv_sttmt_unq_no
  169. from shmt_odr_base_info base
  170. join shmt_odr_dtl_ptcl ptcl on base.shmt_req_unq_no = ptcl.shmt_req_unq_no
  171. 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
  172. 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
  173. where 1=1
  174. and base.brand_id = #{sBrandId}
  175. <if test="fromDt != null and fromDt != '' and toDt != null and toDt != ''">
  176. and base.shmt_reg_dt between #{fromDt} and #{toDt}
  177. </if>
  178. <if test="sShmtWhsId != null and sShmtWhsId != ''">
  179. and base.shmt_whs_id = #{sShmtWhsId}
  180. </if>
  181. <if test="sShmtReqStCd != null and sShmtReqStCd != ''">
  182. and base.shmt_req_st_cd = #{sShmtReqStCd}
  183. </if>
  184. <if test="swhsId != null and swhsId != ''">
  185. and base.whs_id = #{swhsId}
  186. </if>
  187. <if test="sItemNm != null and sItemNm != ''">
  188. and (ptcl.item_id like concat('%', #{sItemNm},'%') or ptcl.item_nm like concat('%',#{sItemNm},'%'))
  189. </if>
  190. <choose>
  191. <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
  192. <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
  193. <if test="gridRequest.sord == 'asc'.toString()">
  194. order by pch_req_unq_no asc
  195. </if>
  196. <if test="gridRequest.sord == 'desc'.toString()">
  197. order by pch_req_unq_no desc
  198. </if>
  199. </if>
  200. </when>
  201. <otherwise>
  202. order by pch_req_unq_no desc
  203. </otherwise>
  204. </choose>
  205. <if test="gridRequest.pagingYn == true">
  206. limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
  207. </if>
  208. </select>
  209. <select id="selectShmtSearchGridCnt" resultType="int">
  210. /* shmtOdr.selectShmtSearchGridCnt */
  211. select count(*)
  212. from shmt_odr_base_info base
  213. join shmt_odr_dtl_ptcl ptcl on base.shmt_req_unq_no = ptcl.shmt_req_unq_no
  214. 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
  215. 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
  216. where 1=1
  217. and base.brand_id = #{sBrandId}
  218. <if test="fromDt != null and fromDt != '' and toDt != null and toDt != ''">
  219. and base.shmt_reg_dt between #{fromDt} and #{toDt}
  220. </if>
  221. <if test="sShmtWhsId != null and sShmtWhsId != ''">
  222. and base.shmt_whs_id = #{sShmtWhsId}
  223. </if>
  224. <if test="sShmtReqStCd != null and sShmtReqStCd != ''">
  225. and base.shmt_req_st_cd = #{sShmtReqStCd}
  226. </if>
  227. <if test="swhsId != null and swhsId != ''">
  228. and base.whs_id = #{swhsId}
  229. </if>
  230. <if test="sItemNm != null and sItemNm != ''">
  231. and (ptcl.item_id like concat('%', #{sItemNm},'%') or ptcl.item_nm like concat('%',#{sItemNm},'%'))
  232. </if>
  233. </select>
  234. <select id="selectInvInfo" resultType="com.oqpo.api.entity.inoutmng.DeliInfoMgntEntity">
  235. 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
  236. , deli.dlv_mgr_nm, fn_get_telno( deli.dlv_mgr_tel_no) as dlv_mgr_tel_no
  237. , 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
  238. , whs.mgr_tel_no, deli.spply_id
  239. , case when deli.spply_id is null or deli.spply_id = '' then 'DL01' else 'DL02' end as deli_dvsn -- 배송주체
  240. , deli.whs_dvsn -- 납품정보
  241. , concat(whs.addr1 ,' ',whs.addr2) as whs_addr
  242. , fn_get_telno(whs.mgr_tel_no) as whs_mgr_tel_no
  243. from deli_info_mgnt deli
  244. join whs_mgnt_base_info whs on whs.brand_id = deli.brand_id and whs.whs_id = deli.whs_id
  245. where deli.brand_id = #{brandId}
  246. and deli.dlv_sttmt_unq_no = #{dlvSttmtUnqNo}
  247. </select>
  248. <select id="selectInvDtlList" resultType="com.oqpo.api.entity.inoutmng.DeliDtlMgntEntity">
  249. 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
  250. from deli_info_mgnt info
  251. , deli_dtl_ptcl ptcl
  252. where 1 = 1
  253. and info.dlv_sttmt_unq_no = ptcl.dlv_sttmt_unq_no
  254. and info.brand_id = #{brandId}
  255. and info.dlv_sttmt_unq_no = #{dlvSttmtUnqNo}
  256. </select>
  257. <select id="selectSpplyTargetOdrGridList" resultType="com.oqpo.api.entity.pomng.PchOdrBaseInfoEntity">
  258. select base.brand_id, fn_brand_nm(base.brand_id) as brand_nm, base.pch_podr_unq_no
  259. , ptcl.pch_podr_dtl_no as 'pchOdrDtlInfo.pch_podr_dtl_no'
  260. ,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
  261. ,base.location, fn_whs_location_nm(base.brand_id, base.whs_id, base.location) as location_nm
  262. ,ptcl.unit_amt as 'pchOdrDtlInfo.unit_amt', ptcl.podr_qty as 'pchOdrDtlInfo.podr_qty'
  263. , ptcl.podr_qty as 'pchOdrDtlInfo.shmt_qty'
  264. ,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
  265. from pch_odr_base_info base
  266. join pch_odr_dtl_ptcl ptcl on base.pch_podr_unq_no = ptcl.pch_podr_unq_no and ptcl.podr_dtl_st_cd = 'POD0'
  267. <if test="sItemNm != null and sItemNm != ''">
  268. and (ptcl.item_id like concat('%',#{sItemNm},'%') or ptcl.item_nm like concat('%',#{sItemNm},'%') or ptcl.pch_podr_unq_no like concat('%',#{sItemNm},'%'))
  269. </if>
  270. join item_base_info itm on ptcl.item_id = itm.item_id
  271. 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
  272. and ptcl.item_id = stck.item_id
  273. where 1=1
  274. and base.brand_id = #{sBrandId}
  275. and base.dlv_req_dt between #{fromDt} and #{toDt}
  276. and base.dlv_dvsn = 'DL02' -- 본사배송구분
  277. and base.spply_id = #{sSpplyId}
  278. <if test="sWhsId != null and sWhsId != ''">
  279. and base.whs_id = #{sWhsId}
  280. </if>
  281. <choose>
  282. <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
  283. <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
  284. <if test="gridRequest.sord == 'asc'.toString()">
  285. order by base.pch_podr_unq_no asc, ptcl.pch_podr_dtl_no asc
  286. </if>
  287. <if test="gridRequest.sord == 'desc'.toString()">
  288. order by base.pch_podr_unq_no desc, ptcl.pch_podr_dtl_no desc
  289. </if>
  290. </if>
  291. </when>
  292. <otherwise>
  293. order by base.pch_podr_unq_no asc
  294. </otherwise>
  295. </choose>
  296. <if test="gridRequest.pagingYn == true">
  297. limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
  298. </if>
  299. </select>
  300. <select id="selectSpplyTargetOdrGridCnt" resultType="int">
  301. select count(*)
  302. from pch_odr_base_info base
  303. join pch_odr_dtl_ptcl ptcl on base.pch_podr_unq_no = ptcl.pch_podr_unq_no and ptcl.podr_dtl_st_cd = 'POD0'
  304. <if test="sItemNm != null and sItemNm != ''">
  305. and (ptcl.item_id like concat('%',#{sItemNm},'%') or ptcl.item_nm like concat('%',#{sItemNm},'%') or ptcl.pch_podr_unq_no like concat('%',#{sItemNm},'%'))
  306. </if>
  307. join item_base_info itm on ptcl.item_id = itm.item_id
  308. 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
  309. and ptcl.item_id = stck.item_id
  310. where 1=1
  311. and base.brand_id = #{sBrandId}
  312. and base.dlv_req_dt between #{fromDt} and #{toDt}
  313. and base.dlv_dvsn = 'DL02' -- 본사배송구분
  314. and base.spply_id = #{sSpplyId}
  315. <if test="sWhsId != null and sWhsId != ''">
  316. and base.whs_id = #{sWhsId}
  317. </if>
  318. </select>
  319. <select id="selectSpplyShmtOdrInfo" resultType="com.oqpo.api.entity.pomng.PchOdrBaseInfoEntity">
  320. 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
  321. , (select sum(podr_amt) from pch_odr_dtl_ptcl where pch_podr_unq_no = #{pchPodrUnqNo} and podr_dtl_st_cd = 'POD0' ) as podr_total_amt
  322. , base.whs_id, fn_whs_nm(base.brand_id, base.whs_id) as whs_nm
  323. , base.location, fn_whs_location_nm(brand_id, base.whs_id, base.location) as location_nm
  324. , fn_get_telno((select tel_no from store_base_info where store_id = base.store_id )) as deli_tel_no
  325. from pch_odr_base_info base
  326. where 1=1
  327. and base.brand_id = #{brandId}
  328. and base.spply_id = #{spplyId}
  329. and base.dlv_dvsn = 'DL02'
  330. and base.pch_podr_unq_no = #{pchPodrUnqNo}
  331. </select>
  332. <select id="selectSpplyShmtOdrList" resultType="com.oqpo.api.entity.pomng.PchOdrDtlPtclEntity">
  333. 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
  334. ,itm.expry_yn as expry_yn, itm.expry_period as expry_period, ptcl.unit_amt
  335. , date_format(adddate(now(), interval itm.expry_period day),'%Y.%m.%d') as expry_date
  336. from pch_odr_dtl_ptcl ptcl
  337. join item_base_info itm on ptcl.item_id = itm.item_id
  338. where ptcl.pch_podr_unq_no = #{pchPodrUnqNo}
  339. and ptcl.podr_dtl_st_cd = 'POD0'
  340. </select>
  341. <select id="selectDeliGridList" resultType="com.oqpo.api.entity.inoutmng.DeliInfoMgntEntity">
  342. select info.brand_id, fn_brand_nm(info.brand_id) as brand_nm, info.dlv_sttmt_unq_no
  343. , 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
  344. , info.whs_id, info.location, fn_whs_nm(info.brand_id, info.whs_id) as whs_nm
  345. , fn_whs_location_nm(info.brand_id, info.whs_id, info.location) as location_nm
  346. , 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
  347. , 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
  348. , date_format(info.dlv_cmplt_dt, '%y.%m.%d') as dlv_cmplt_dt
  349. , ptcl.item_id as 'deliDtlMgntInfo.item_id', ptcl.item_nm as 'deliDtlMgntInfo.item_nm'
  350. , ptcl.podr_qty as 'deliDtlMgntInfo.podr_qty', ptcl.dlv_qty as 'deliDtlMgntInfo.dlv_qty'
  351. , ptcl.unit as 'deliDtlMgntInfo.unit', ptcl.unit_amt as 'deliDtlMgntInfo.unit_amt'
  352. , ptcl.pch_podr_unq_no as 'deliDtlMgntInfo.pch_podr_unq_no' , ptcl.pch_podr_dtl_no as 'deliDtlMgntInfo.pch_podr_dtl_no'
  353. , info.dlv_mgr_nm , info.dlv_mgr_mbl_no
  354. from deli_info_mgnt info
  355. , deli_dtl_ptcl ptcl
  356. where 1 = 1
  357. and info.dlv_sttmt_unq_no = ptcl.dlv_sttmt_unq_no
  358. and info.brand_id = #{sBrandId}
  359. <if test="dtGubun eq '1'.toString()">
  360. and info.podr_reg_dt between #{fromDt} and #{toDt} -- 1인경우 발주생성일로 조회
  361. </if>
  362. <if test="dtGubun eq '2'.toString()">
  363. and info.dlv_req_dt between #{fromDt} and #{toDt} -- 2인경우 납품요청일로 조회
  364. </if>
  365. <if test="dtGubun eq '3'.toString()">
  366. and info.dlv_sch_dt between #{fromDt} and #{toDt} -- 3인경우 납품예정일로 조회
  367. </if>
  368. <if test="dtGubun eq '4'.toString()">
  369. and info.dlv_cmplt_dt between #{fromDt} and #{toDt} -- 3인경우 납품완료일 조회
  370. </if>
  371. <if test="sDlvStCd != null and sDlvStCd != ''">
  372. and info.dlv_st_cd = #{sDlvStCd} -- 납품상태
  373. </if>
  374. <if test="sSpplyId != null and sSpplyId != ''">
  375. and info.spply_id = #{sSpplyId}
  376. </if>
  377. <if test="sWhsId != null and sWhsId != ''">
  378. and info.whs_id = #{sWhsId}
  379. </if>
  380. <if test="sItemNm != null and sItemNm != ''">
  381. and (ptcl.item_id like concat('%', #{sItemNm}, '%') or ptcl.item_nm like concat('%', #{sItemNm}, '%'))
  382. </if>
  383. <choose>
  384. <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
  385. <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
  386. <if test="gridRequest.sord == 'asc'.toString()">
  387. order by pch_req_unq_no asc
  388. </if>
  389. <if test="gridRequest.sord == 'desc'.toString()">
  390. order by pch_req_unq_no desc
  391. </if>
  392. </if>
  393. </when>
  394. <otherwise>
  395. order by pch_req_unq_no desc
  396. </otherwise>
  397. </choose>
  398. <if test="gridRequest.pagingYn == true">
  399. limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
  400. </if>
  401. </select>
  402. <select id="selectDeliGridCnt" resultType="int">
  403. select count(*)
  404. from deli_info_mgnt info
  405. , deli_dtl_ptcl ptcl
  406. where 1 = 1
  407. and info.dlv_sttmt_unq_no = ptcl.dlv_sttmt_unq_no
  408. and info.brand_id = #{sBrandId}
  409. <if test="dtGubun eq '1'.toString()">
  410. and info.podr_reg_dt between #{fromDt} and #{toDt} -- 1인경우 발주생성일로 조회
  411. </if>
  412. <if test="dtGubun eq '2'.toString()">
  413. and info.dlv_req_dt between #{fromDt} and #{toDt} -- 2인경우 납품요청일로 조회
  414. </if>
  415. <if test="dtGubun eq '3'.toString()">
  416. and info.dlv_sch_dt between #{fromDt} and #{toDt} -- 3인경우 납품예정일로 조회
  417. </if>
  418. <if test="dtGubun eq '4'.toString()">
  419. and info.dlv_cmplt_dt between #{fromDt} and #{toDt} -- 3인경우 납품완료일 조회
  420. </if>
  421. <if test="sDlvStCd != null and sDlvStCd != ''">
  422. and info.dlv_st_cd = #{sDlvStCd} -- 납품상태
  423. </if>
  424. <if test="sSpplyId != null and sSpplyId != ''">
  425. and info.spply_id = #{sSpplyId}
  426. </if>
  427. <if test="sWhsId != null and sWhsId != ''">
  428. and info.whs_id = #{sWhsId}
  429. </if>
  430. <if test="sItemNm != null and sItemNm != ''">
  431. and (ptcl.item_id like concat('%', #{sItemNm}, '%') or ptcl.item_nm like concat('%', #{sItemNm}, '%'))
  432. </if>
  433. </select>
  434. <select id="selectSpplyDeliGridList" resultType="com.oqpo.api.entity.inoutmng.DeliInfoMgntEntity">
  435. select info.brand_id, fn_brand_nm(info.brand_id) as brand_nm, info.dlv_sttmt_unq_no
  436. , 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
  437. , info.whs_id, info.location, fn_whs_nm(info.brand_id, info.whs_id) as whs_nm
  438. , fn_whs_location_nm(info.brand_id, info.whs_id, info.location) as location_nm
  439. , 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
  440. , 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
  441. , date_format(info.dlv_cmplt_dt, '%y.%m.%d') as dlv_cmplt_dt
  442. , ptcl.item_id as 'deliDtlMgntInfo.item_id', ptcl.item_nm as 'deliDtlMgntInfo.item_nm'
  443. , ptcl.podr_qty as 'deliDtlMgntInfo.podr_qty', ptcl.dlv_qty as 'deliDtlMgntInfo.dlv_qty'
  444. , ptcl.unit as 'deliDtlMgntInfo.unit', ptcl.unit_amt as 'deliDtlMgntInfo.unit_amt'
  445. , info.dlv_mgr_nm , info.dlv_mgr_mbl_no
  446. from deli_info_mgnt info
  447. , deli_dtl_ptcl ptcl
  448. where 1 = 1
  449. and info.dlv_sttmt_unq_no = ptcl.dlv_sttmt_unq_no
  450. and info.brand_id = #{sBrandId}
  451. and info.spply_id = #{sSpplyId}
  452. and info.dlv_sch_dt between #{fromDt} and #{toDt} -- 납품 예정일
  453. <if test="sWhsId != null and sWhsId != ''">
  454. and info.whs_id = #{sWhsId}
  455. </if>
  456. <if test="sItemNm != null and sItemNm != ''">
  457. and (ptcl.item_id like concat('%', #{sItemNm}, '%') or ptcl.item_nm like concat('%', #{sItemNm}, '%'))
  458. </if>
  459. <choose>
  460. <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
  461. <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
  462. <if test="gridRequest.sord == 'asc'.toString()">
  463. order by pch_req_unq_no asc
  464. </if>
  465. <if test="gridRequest.sord == 'desc'.toString()">
  466. order by pch_req_unq_no desc
  467. </if>
  468. </if>
  469. </when>
  470. <otherwise>
  471. order by pch_req_unq_no desc
  472. </otherwise>
  473. </choose>
  474. <if test="gridRequest.pagingYn == true">
  475. limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
  476. </if>
  477. </select>
  478. <select id="selectSpplyDeliGridCnt" resultType="int">
  479. select count(*)
  480. from deli_info_mgnt info
  481. , deli_dtl_ptcl ptcl
  482. where 1 = 1
  483. and info.dlv_sttmt_unq_no = ptcl.dlv_sttmt_unq_no
  484. and info.brand_id = #{sBrandId}
  485. and info.spply_id = #{sSpplyId}
  486. and info.dlv_sch_dt between #{fromDt} and #{toDt} -- 납품 예정일
  487. <if test="sWhsId != null and sWhsId != ''">
  488. and info.whs_id = #{sWhsId}
  489. </if>
  490. <if test="sItemNm != null and sItemNm != ''">
  491. and (ptcl.item_id like concat('%', #{sItemNm}, '%') or ptcl.item_nm like concat('%', #{sItemNm}, '%'))
  492. </if>
  493. </select>
  494. <select id="selectWarehouseTargetGridList" resultType="com.oqpo.api.entity.inoutmng.DeliInfoMgntEntity">
  495. select info.brand_id, fn_brand_nm(info.brand_id) as brand_nm
  496. , info.dlv_sttmt_unq_no, ptcl.dlv_sttmt_dtl_no as 'deliDtlMgntInfo.dlv_sttmt_dtl_no'
  497. , ptcl.item_id as 'deliDtlMgntInfo.item_id' , ptcl.item_nm as 'deliDtlMgntInfo.item_nm'
  498. , ptcl.podr_qty as 'deliDtlMgntInfo.podr_qty', ptcl.dlv_qty as 'deliDtlMgntInfo.dlv_qty'
  499. , ptcl.dlv_qty as 'deliDtlMgntInfo.whs_qty' , ptcl.dlv_qty * ptcl.unit_amt as 'deliDtlMgntInfo.whs_amt'
  500. , ptcl.unit_amt as 'deliDtlMgntInfo.unit_amt'
  501. , info.whs_id, info.location, fn_whs_nm(info.brand_id, info.whs_id) as whs_nm
  502. , fn_whs_location_nm(info.brand_id, info.whs_id, info.location) as location_nm
  503. , date_format(info.dlv_sch_dt, '%Y.%m.%d %H:%i:%s') as dlv_sch_dt
  504. , date_format(info.dlv_req_dt, '%Y.%m.%d %H:%i:%s') as dlv_req_dt
  505. , info.dlv_mgr_nm, info.dlv_mgr_mbl_no, fn_get_telno(info.dlv_mgr_tel_no) AS dlv_mgr_tel_no
  506. , ptcl.pch_podr_unq_no as 'deliDtlMgntInfo.pch_podr_unq_no', ptcl.pch_podr_dtl_no as 'deliDtlMgntInfo.pch_podr_dtl_no'
  507. , ptcl.pch_req_unq_no as 'deliDtlMgntInfo.pch_req_unq_no', ptcl.pch_req_dtl_no as 'deliDtlMgntInfo.pch_req_dlt_no'
  508. , ptcl.unit as 'deliDtlMgntInfo.unit', info.dlv_cmplt_dt as 'deliDtlMgntInfo.dlv_cmplt_dt'
  509. , info.spply_id as 'deliDtlMgntInfo.spply_id', info.spply_nm as 'deliDtlMgntInfo.spply_nm'
  510. from deli_info_mgnt info
  511. , deli_dtl_ptcl ptcl
  512. where 1 = 1
  513. and info.dlv_sttmt_unq_no = ptcl.dlv_sttmt_unq_no
  514. and info.brand_id = #{sBrandId}
  515. and info.dlv_sch_dt between #{fromDt} and #{toDt}
  516. and info.dlv_st_cd = 'DLV0'
  517. and ptcl.dlv_dtl_st_cd = 'DLD0'
  518. and info.whs_id = #{sWhsId}
  519. <if test="sSpplyId != null and sSpplyId != ''">
  520. and info.spply_id = #{sSpplyId}
  521. </if>
  522. <if test="sDlvSttmtUnqNo != null and sDlvSttmtUnqNo != ''">
  523. and info.dlv_sttmt_unq_no like concat('%',#{sDlvSttmtUnqNo},'%')
  524. </if>
  525. <if test="sItemNm != null and sItemNm != ''">
  526. and (ptcl.item_id like concat('%', #{sItemNm}, '%') or ptcl.item_nm like concat('%', #{sItemNm}, '%'))
  527. </if>
  528. <choose>
  529. <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
  530. <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
  531. <if test="gridRequest.sord == 'asc'.toString()">
  532. order by pch_req_unq_no asc
  533. </if>
  534. <if test="gridRequest.sord == 'desc'.toString()">
  535. order by pch_req_unq_no desc
  536. </if>
  537. </if>
  538. </when>
  539. <otherwise>
  540. order by pch_req_unq_no desc
  541. </otherwise>
  542. </choose>
  543. <if test="gridRequest.pagingYn == true">
  544. limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
  545. </if>
  546. </select>
  547. <select id="selectWarehouseTargetGridCnt" resultType="int">
  548. select count(*)
  549. from deli_info_mgnt info
  550. , deli_dtl_ptcl ptcl
  551. where 1 = 1
  552. and info.dlv_sttmt_unq_no = ptcl.dlv_sttmt_unq_no
  553. and info.brand_id = #{sBrandId}
  554. and info.dlv_sch_dt between #{fromDt} and #{toDt}
  555. and info.dlv_st_cd = 'DLV0'
  556. and ptcl.dlv_dtl_st_cd = 'DLD0'
  557. and info.whs_id = #{sWhsId}
  558. <if test="sSpplyId != null and sSpplyId != ''">
  559. and info.spply_id = #{sSpplyId}
  560. </if>
  561. <if test="sDlvSttmtUnqNo != null and sDlvSttmtUnqNo != ''">
  562. and info.dlv_sttmt_unq_no like concat('%',#{sDlvSttmtUnqNo},'%')
  563. </if>
  564. <if test="sItemNm != null and sItemNm != ''">
  565. and (ptcl.item_id like concat('%', #{sItemNm}, '%') or ptcl.item_nm like concat('%', #{sItemNm}, '%'))
  566. </if>
  567. </select>
  568. <insert id="insertWhsProcInfoPtcl">
  569. insert into whs_proc_info_ptcl /* insertWhsProcInfoPtcl */
  570. (whs_mgnt_unq_no, dlv_sttmt_dtl_no, dlv_sttmt_unq_no, brand_id, store_id
  571. , whs_dt, whs_id, location, whs_dvsn, podr_qty, dlv_qty
  572. , whs_qty, unit, dlv_req_dt, dlv_sch_dt, dlv_cmplt_dt
  573. , whs_cnfm_nm, dlv_mgr_nm, dlv_mgr_tel_no, dlv_mgr_emal, dlv_mgr_mbl_no
  574. , item_id, item_nm, whs_amt, whs_dlv_chrg, dlv_mgr_id
  575. , dlv_cnfm_doc_file_no, sttl_yn, pch_podr_unq_no, pch_podr_dtl_no, pch_req_unq_no
  576. , pch_req_dtl_no, shmt_req_unq_no, shmt_req_dtl_no, sys_reg_dttm, sys_reg_id, sys_chg_dttm, sys_chg_id
  577. , spply_id, spply_nm , unit_amt)
  578. values
  579. <foreach collection="gridUpdateData" item="item" separator=",">
  580. (#{item.whsMgntUnqNo}, #{item.dlvSttmtDtlNo}, #{item.dlvSttmtUnqNo}, #{item.brandId}, #{item.storeId}
  581. , date_format(now(),'%Y%m%d'),#{item.whsId}, #{item.location}, #{item.whsDvsn}, #{item.podrQty}, #{item.dlvQty}
  582. , #{item.whsQty}, #{item.unit}, #{item.dlvReqDt}, #{item.dlvSchDt}, date_format(now(),'%Y%m%d')
  583. , #{item.whsCnfmNm}, #{item.dlvMgrNm}, #{item.dlvMgrTelNo}, #{item.dlvMgrEmal}, #{item.dlvMgrMblNo}
  584. , #{item.itemId}, #{item.itemNm}, #{item.whsAmt}, #{item.whsDlvChrg}, #{item.dlvMgrId}
  585. , #{item.dlvCnfmDocFileNo}, #{item.sttlYn}, #{item.pchPodrUnqNo}, #{item.pchPodrDtlNo}, #{item.pchReqUnqNo}
  586. , #{item.pchReqDtlNo}, #{item.shmtReqUnqNo}, #{item.shmtReqDtlNo}, NOW(), #{userId}, NOW(), #{userId}
  587. , #{item.spplyId} , #{item.spplyNm}, #{item.unitAmt})
  588. </foreach>
  589. </insert>
  590. <select id="selectWarehouseProcList" resultType="com.oqpo.api.entity.inoutmng.DeliInfoMgntEntity">
  591. select /* shmtOdr.selectWarehouseProcList */info.brand_id, info.store_id
  592. , info.dlv_sttmt_unq_no, ptcl.dlv_sttmt_dtl_no as 'deliDtlMgntInfo.dlv_sttmt_dtl_no'
  593. , info.whs_id, info.location, info.spply_id, info.spply_nm
  594. , info.whs_dvsn, ptcl.podr_qty as 'deliDtlMgntInfo.podr_qty'
  595. , ptcl.dlv_qty as 'deliDtlMgntInfo.dlv_qty', ptcl.unit as 'deliDtlMgntInfo.unit'
  596. , ptcl.unit_amt as 'deliDtlMgntInfo.unit_amt', info.dlv_req_dt, info.dlv_sch_dt
  597. , info.dlv_mgr_nm, info.dlv_mgr_mbl_no, info.dlv_mgr_tel_no
  598. , ptcl.item_id as 'deliDtlMgntInfo.item_id' , ptcl.item_nm as 'deliDtlMgntInfo.item_nm'
  599. , ptcl.pch_podr_unq_no as 'deliDtlMgntInfo.pch_podr_unq_no', ptcl.pch_podr_dtl_no as 'deliDtlMgntInfo.pch_podr_dtl_no'
  600. , ptcl.pch_req_unq_no as 'deliDtlMgntInfo.pch_req_unq_no', ptcl.pch_req_dtl_no as 'deliDtlMgntInfo.pch_req_dlt_no'
  601. , ptcl.shmt_req_unq_no as 'deliDtlMgntInfo.shmt_req_unq_no' , ptcl.shmt_req_dtl_no as 'deliDtlMgntInfo.shmt_req_dtl_no'
  602. , ptcl.podr_amt as 'deliDtlMgntInfo.podr_amt'
  603. from deli_info_mgnt info
  604. join deli_dtl_ptcl ptcl on info.dlv_sttmt_unq_no = ptcl.dlv_sttmt_unq_no
  605. and concat(ptcl.dlv_sttmt_unq_no, ptcl.dlv_sttmt_dtl_no) in
  606. <foreach collection="gridUpdateData" item="item" separator="," open="(" close=")">
  607. #{item.dlvSttmtDtlNo}
  608. </foreach>
  609. and ptcl.dlv_dtl_st_cd = 'DLD0'
  610. where 1=1
  611. and info.brand_id = #{brandId}
  612. and info.dlv_st_cd = 'DLV0'
  613. and info.whs_id = #{whsId}
  614. </select>
  615. <update id="updateDeliDtlStCd" >
  616. /* updateDeliDtlStCd */
  617. <foreach collection="gridUpdateData" item="item" separator=";">
  618. UPDATE deli_dtl_ptcl SET
  619. dlv_dtl_st_cd = #{item.dlvDtlStCd}, /* 상태처리 */
  620. sys_chg_dttm = NOW(),
  621. sys_chg_id = #{userId}
  622. WHERE dlv_sttmt_unq_no = #{item.dlvSttmtUnqNo}
  623. AND dlv_sttmt_dtl_no = #{item.dlvSttmtDtlNo}
  624. </foreach>
  625. </update>
  626. <select id="selectDeliInfoStList" resultType="com.oqpo.api.entity.inoutmng.DeliInfoMgntEntity">
  627. select gdlv.dlv_sttmt_unq_no
  628. , case when gdlv.dlv0 > 0 then 'DLV0'
  629. when gdlv.dlv0 = 0 and gdlv.dlv1 > 0 then 'DLV1'
  630. when gdlv.dlv0 = 0 and gdlv.dlv1 = 0 then 'DLV2'
  631. else '' end as dlv_st_cd
  632. from (
  633. select dlv_sttmt_unq_no
  634. , sum(case when dlv_dtl_st_cd = 'DLD0' then 1 else 0 end) as dlv0
  635. , sum(case when dlv_dtl_st_cd = 'DLD1' then 1 else 0 end) as dlv1
  636. , sum(case when dlv_dtl_st_cd = 'DLD2' then 1 else 0 end) as dlv2
  637. from deli_dtl_ptcl
  638. where dlv_sttmt_unq_no in
  639. <foreach collection="gridUpdateData" item="item" separator="," open="(" close=")">
  640. #{item.dlvSttmtUnqNo}
  641. </foreach>
  642. group by dlv_sttmt_unq_no
  643. ) gdlv
  644. </select>
  645. <update id="updateDeliInfoStCd" >
  646. /* updateDeliInfoStCd */
  647. <foreach collection="gridUpdateData" item="item" separator=";">
  648. UPDATE deli_info_mgnt SET
  649. dlv_st_cd = #{item.dlvStCd}, /* 상태처리 */
  650. sys_chg_dttm = NOW(),
  651. sys_chg_id = #{userId}
  652. WHERE dlv_sttmt_unq_no = #{item.dlvSttmtUnqNo}
  653. </foreach>
  654. </update>
  655. <update id="updateShmtDtlStCd" >
  656. /* updateShmtDtlStCd */
  657. <foreach collection="gridUpdateData" item="item" separator=";">
  658. UPDATE shmt_odr_dtl_ptcl SET
  659. shmt_dtl_st_cd = #{item.shmtDtlStCd}, /* 상태처리 */
  660. sys_chg_dttm = NOW(),
  661. sys_chg_id = #{userId}
  662. WHERE shmt_req_unq_no = #{item.shmtReqUnqNo}
  663. AND shmt_req_dtl_no = #{item.shmtReqDtlNo}
  664. </foreach>
  665. </update>
  666. <select id="selectShmtInfoStList" resultType="com.oqpo.api.entity.inoutmng.ShmtOdrDtlEntity">
  667. select gdlv.shmt_req_unq_no
  668. , case when gdlv.shmd1 > 0 then 'SHM1'
  669. when gdlv.shmd1 = 0 and gdlv.shmd2 > 0 then 'SHM2'
  670. when gdlv.shmd1 = 0 and gdlv.shmd2 = 0 then 'SHM3'
  671. else '' end as shmt_req_st_cd
  672. from (
  673. select shmt_req_unq_no
  674. , sum(case when shmt_dtl_st_cd = 'SHMD1' then 1 else 0 end) as shmd1
  675. , sum(case when shmt_dtl_st_cd = 'SHMD2' then 1 else 0 end) as shmd2
  676. , sum(case when shmt_dtl_st_cd = 'SHMD3' then 1 else 0 end) as shmd3
  677. from shmt_odr_dtl_ptcl
  678. where shmt_req_unq_no in
  679. <foreach collection="gridUpdateData" item="item" separator="," open="(" close=")">
  680. #{item.shmtReqUnqNo}
  681. </foreach>
  682. group by shmt_req_unq_no
  683. ) gdlv
  684. </select>
  685. <update id="updateShmtInfoStCd" >
  686. /* updateShmtInfoStCd */
  687. <foreach collection="gridUpdateData" item="item" separator=";">
  688. UPDATE shmt_odr_base_info SET
  689. shmt_req_st_cd = #{item.shmtReqStCd}, /* 상태처리 */
  690. sys_chg_dttm = NOW(),
  691. sys_chg_id = #{userId}
  692. WHERE shmt_odr_unq_no = #{item.shmtReqUnqNo}
  693. </foreach>
  694. </update>
  695. <update id="updatePchPodrDtlStCd" >
  696. /* updatePchPodrDtlStCd */
  697. <foreach collection="gridUpdateData" item="item" separator=";">
  698. UPDATE pch_odr_dtl_ptcl SET
  699. podr_dtl_st_cd = #{item.podrDtlStCd}, /* 상태처리 */
  700. sys_chg_dttm = NOW(),
  701. sys_chg_id = #{userId}
  702. WHERE pch_podr_unq_no = #{item.pchPodrUnqNo}
  703. AND pch_podr_dtl_no = #{item.pchPodrDtlNo}
  704. </foreach>
  705. </update>
  706. <select id="selectWarehouseList" resultType="com.oqpo.api.entity.stockmng.WhsProcInfoPtclEntity">
  707. select whs.pch_podr_unq_no, whs.pch_podr_dtl_no, whs.dlv_sttmt_unq_no, whs.dlv_sttmt_dtl_no
  708. , whs.podr_qty, whs.dlv_qty, whs.whs_qty
  709. , date_format(whs.dlv_req_dt, '%Y.%m.%d') as dlv_req_dt
  710. , date_format(whs.dlv_sch_dt, '%Y.%m.%d') as dlv_sch_dt
  711. , date_format(whs.dlv_cmplt_dt, '%Y.%m.%d') as dlv_cmplt_dt
  712. , whs.whs_cnfm_nm, whs.dlv_mgr_nm, whs.dlv_mgr_tel_no
  713. , whs.item_id, whs.item_nm, whs.unit, whs.whs_amt, whs.dlv_cnfm_doc_file_no
  714. from whs_proc_info_ptcl whs
  715. where 1 = 1
  716. and whs.whs_dt between #{fromDt} and #{toDt}
  717. and whs.brand_id = #{sBrandId}
  718. <if test="sStoreId != null and sStoreId != ''">
  719. and whs.store_id = #{sStoreId}
  720. </if>
  721. <if test="sPchPodrUnqNo != null and sPchPodrUnqNo != ''">
  722. and whs.pch_podr_unq_no like concat('%', #{sPchPodrUnqNo}, '%')
  723. </if>
  724. <if test="sSpplyId != null and sSpplyId != ''">
  725. and whs.spply_id = #{sSpplyId}
  726. </if>
  727. <if test="sWhsId != null and sWhsId != ''">
  728. and whs.whs_id = #{sWhsId}
  729. </if>
  730. <if test="sItemNm != null and sItemNm != ''">
  731. and (whs.item_id like concat('%', #{sItemNm}, '%') or whs.item_nm like concat('%', #{sItemNm}, '%'))
  732. </if>
  733. <choose>
  734. <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
  735. <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
  736. <if test="gridRequest.sord == 'asc'.toString()">
  737. order by pch_req_unq_no asc
  738. </if>
  739. <if test="gridRequest.sord == 'desc'.toString()">
  740. order by pch_req_unq_no desc
  741. </if>
  742. </if>
  743. </when>
  744. <otherwise>
  745. order by pch_req_unq_no desc
  746. </otherwise>
  747. </choose>
  748. <if test="gridRequest.pagingYn == true">
  749. limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
  750. </if>
  751. </select>
  752. <select id="selectWarehouseCnt" resultType="int">
  753. select count(*)
  754. from whs_proc_info_ptcl whs
  755. where 1 = 1
  756. and whs.whs_dt between #{fromDt} and #{toDt}
  757. and whs.brand_id = #{sBrandId}
  758. <if test="sStoreId != null and sStoreId != ''">
  759. and whs.store_id = #{sStoreId}
  760. </if>
  761. <if test="sPchPodrUnqNo != null and sPchPodrUnqNo != ''">
  762. and whs.pch_podr_unq_no like concat('%', #{sPchPodrUnqNo}, '%')
  763. </if>
  764. <if test="sSpplyId != null and sSpplyId != ''">
  765. and whs.spply_id = #{sSpplyId}
  766. </if>
  767. <if test="sWhsId != null and sWhsId != ''">
  768. and whs.whs_id = #{sWhsId}
  769. </if>
  770. <if test="sItemNm != null and sItemNm != ''">
  771. and (whs.item_id like concat('%', #{sItemNm}, '%') or whs.item_nm like concat('%', #{sItemNm}, '%'))
  772. </if>
  773. </select>
  774. </mapper>