ItemUnit.xml 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910
  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.stinfo.ItemUnitMapper">
  4. <select id="selectItemUnitGridList" resultType="com.oqpo.api.entity.stinfo.ItemUnitEntity">
  5. select /*selectItemUnitGridList*/
  6. iunit.brand_unit_unq_no, iunit.brand_id, iunit.item_id, iunit.item_nm, iunit.spply_id,
  7. iunit.spply_nm, date_format(iunit.cont_stt_dt,'%Y.%m.%d') as cont_stt_dt, date_format(iunit.cont_end_dt,'%Y.%m.%d') as cont_end_dt,
  8. iunit.curr, fn_code_nm('CURR', iunit.curr) as curr_nm, iunit.unit, fn_code_nm('DSTRBT_COST_UNIT', iunit.unit) as unit_nm,
  9. iunit.unit_amt, iunit.lead_time, iunit.spply_item_id,
  10. iunit.unit_st_cd, fn_code_nm('UNIT_ST_CD', iunit.unit_st_cd) as unit_st_nm, iunit.stdd_qty
  11. from brand_item_unit_info iunit
  12. join item_base_info item on iunit.brand_id = item.brand_id and iunit.item_id = item.item_id
  13. left outer join item_class_ptcl iclas on item.item_id = iclas.item_id
  14. left outer join item_class_mgnt mclas on iclas.item_class_mgnt_no = mclas.item_class_mgnt_no
  15. where iunit.brand_id = #{sBrandId}
  16. <if test="fromDt != null and fromDt != '' and toDt != null and toDt != ''">
  17. and iunit.cont_stt_dt between #{fromDt} and #{toDt}
  18. and #{toDt} between iunit.cont_stt_dt and iunit.cont_end_dt
  19. </if>
  20. <if test="sUnitStCd != null and sUnitStCd != ''">
  21. and iunit.unit_st_cd = #{sUnitStCd}
  22. </if>
  23. <if test="sSpplyId != null and sSpplyId != ''">
  24. and iunit.spply_id = #{sSpplyId}
  25. </if>
  26. <if test="sClass1 != null and sClass1 != ''">
  27. and iclas.item_class1 = #{sClass1}
  28. </if>
  29. <if test="sClass2 != null and sClass2 != ''">
  30. and iclas.item_class2 = #{sClass2}
  31. </if>
  32. <if test="sClass3 != null and sClass3 != ''">
  33. and iclas.item_class3 = #{sClass3}
  34. </if>
  35. <if test="sClass4 != null and sClass4 != ''">
  36. and iclas.item_class4 = #{sClass4}
  37. </if>
  38. <if test="sItemNm != null and sItemNm != ''">
  39. and iunit.item_id like concat('%',#{sItemNm},'%') or iunit.item_nm like concat('%',#{sItemNm},'%')
  40. </if>
  41. <choose>
  42. <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
  43. <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
  44. <if test="gridRequest.sord == 'asc'.toString()">
  45. order by iunit.item_nm asc
  46. </if>
  47. <if test="gridRequest.sord == 'desc'.toString()">
  48. order by iunit.item_nm desc
  49. </if>
  50. </if>
  51. </when>
  52. <otherwise>
  53. order by iunit.item_nm asc
  54. </otherwise>
  55. </choose>
  56. <if test="gridRequest.pagingYn == true">
  57. limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
  58. </if>
  59. </select>
  60. <select id="selectItemUnitGridCnt" resultType="int">
  61. select /*selectBrandGridCnt*/
  62. count(*)
  63. from brand_item_unit_info iunit
  64. join item_base_info item on iunit.brand_id = item.brand_id and iunit.item_id = item.item_id
  65. left outer join item_class_ptcl iclas on item.item_id = iclas.item_id
  66. left outer join item_class_mgnt mclas on iclas.item_class_mgnt_no = mclas.item_class_mgnt_no
  67. where iunit.brand_id = #{sBrandId}
  68. <if test="fromDt != null and fromDt != '' and toDt != null and toDt != ''">
  69. and iunit.cont_stt_dt between #{fromDt} and #{toDt}
  70. and #{toDt} between iunit.cont_stt_dt and iunit.cont_end_dt
  71. </if>
  72. <if test="sUnitStCd != null and sUnitStCd != ''">
  73. and iunit.unit_st_cd = #{sUnitStCd}
  74. </if>
  75. <if test="sSpplyId != null and sSpplyId != ''">
  76. and iunit.spply_id = #{sSpplyId}
  77. </if>
  78. <if test="sClass1 != null and sClass1 != ''">
  79. and iclas.item_class1 = #{sClass1}
  80. </if>
  81. <if test="sClass2 != null and sClass2 != ''">
  82. and iclas.item_class2 = #{sClass2}
  83. </if>
  84. <if test="sClass3 != null and sClass3 != ''">
  85. and iclas.item_class3 = #{sClass3}
  86. </if>
  87. <if test="sClass4 != null and sClass4 != ''">
  88. and iclas.item_class4 = #{sClass4}
  89. </if>
  90. <if test="sItemNm != null and sItemNm != ''">
  91. and iunit.item_id like concat('%',#{sItemNm},'%') or iunit.item_nm like concat('%',#{sItemNm},'%')
  92. </if>
  93. </select>
  94. <select id="selectItemUnitInfo" resultType="com.oqpo.api.entity.stinfo.ItemUnitEntity">
  95. select /*selectItemUnitInfo*/
  96. iunit.brand_unit_unq_no, iunit.brand_id, fn_brand_nm(iunit.brand_id) as brand_nm, iunit.item_id, iunit.item_nm, iunit.spply_id,
  97. iunit.spply_nm, date_format(iunit.cont_stt_dt,'%Y.%m.%d') as cont_stt_dt, date_format(iunit.cont_end_dt,'%Y.%m.%d') as cont_end_dt,
  98. iunit.curr, fn_code_nm('CURR', iunit.curr) as curr_nm, iunit.unit, fn_code_nm('DSTRBT_COST_UNIT', iunit.unit) as unit,
  99. iunit.unit_amt, iunit.lead_time, iunit.spply_item_id,
  100. iunit.dlv_cndt, fn_code_nm('DLV_CNDT', iunit.dlv_cndt) as dlv_cndt_nm,
  101. iunit.unit_st_cd, fn_code_nm('UNIT_ST_CD', iunit.unit_st_cd) as unit_st_nm, iunit.stdd_qty,
  102. iunit.store_sale_stdd_qty, iunit.store_sale_unit_amt, iunit.short_cont_file_no,
  103. date_format(iunit.sys_reg_dttm,'%Y.%m.%d %H:%i:%s') as sys_reg_dttm, iunit.sys_reg_id, date_format(iunit.sys_chg_dttm,'%Y.%m.%d %H:%i:%s') as sys_chg_dttm, iunit.sys_chg_id
  104. from brand_item_unit_info iunit
  105. where iunit.brand_unit_unq_no = #{brandUnitUnqNo}
  106. and iunit.brand_id = #{brandId}
  107. </select>
  108. <select id="selectItemUnitDupCnt" resultType="int">
  109. select /* selectItemUnitDupCnt */
  110. count(*) as cnt
  111. from brand_item_unit_info
  112. where brand_id = #{brandId}
  113. and spply_id = #{spplyId}
  114. and item_id = #{itemId}
  115. and date_format(cont_end_dt,'%Y%m%d') <![CDATA[ >= ]]> date_format(#{contSttDt} ,'%Y%m%d')
  116. </select>
  117. <select id="selectItemUnitChaPass" resultType="String">
  118. select case when cont_stt_dt = #{contSttDt} then 'Y' else 'N' end
  119. from brand_item_unit_info
  120. where brand_unit_unq_no =#{brandUnitUnqNo}
  121. </select>
  122. <update id="updateItemUnitContEnd" >
  123. update /* updateItemUnitContEnd */
  124. brand_item_unit_info
  125. set cont_end_dt = DATE_SUB(date_format(#{contEndDt},'%Y%m%d'), INTERVAL 1 DAY)
  126. where brand_id = #{brandId}
  127. and brand_unit_unq_no = #{brandUnitUnqNo}
  128. </update>
  129. <insert id="insertItemUnitInfo" >
  130. insert into /** insertItemUnitInfo */
  131. brand_item_unit_info
  132. (brand_unit_unq_no, brand_id, item_id, item_nm, spply_id,
  133. spply_nm, cont_stt_dt, cont_end_dt, curr, unit,
  134. unit_amt, lead_time, dlv_cndt, short_cont_file_no, spply_item_id,
  135. unit_st_cd, stdd_qty, store_sale_stdd_qty, store_sale_unit_amt,
  136. sys_reg_dttm, sys_reg_id, sys_chg_dttm, sys_chg_id)
  137. values
  138. ( fn_get_dealno(33,''), #{entity.brandId}, #{entity.itemId}, #{entity.itemNm}, #{entity.spplyId},
  139. #{entity.spplyNm}, #{entity.contSttDt}, #{entity.contEndDt}, #{entity.curr}, #{entity.unit},
  140. #{entity.unitAmt}, #{entity.leadTime}, #{entity.dlvCndt}, #{entity.shortContFileNo}, #{entity.spplyItemId},
  141. #{entity.unitStCd}, #{entity.stddQty}, #{entity.storeSaleStddQty}, #{entity.storeSaleUnitAmt},
  142. now(), #{userId}, now(), #{userId})
  143. </insert>
  144. <update id="updateItemUnitInfo" >
  145. update brand_item_unit_info
  146. set sys_chg_dttm = now()
  147. ,sys_chg_id = #{userId}
  148. ,cont_stt_dt = #{entity.contSttDt}
  149. ,cont_end_dt = #{entity.contEndDt}
  150. ,curr = #{entity.curr}
  151. ,unit = #{entity.unit}
  152. ,unit_amt = #{entity.unitAmt}
  153. ,lead_time = #{entity.leadTime}
  154. ,dlv_cndt = #{entity.dlvCndt}
  155. ,short_cont_file_no = #{entity.shortContFileNo}
  156. ,unit_st_cd = #{entity.unitStCd}
  157. ,stdd_qty = #{entity.stddQty}
  158. ,store_sale_stdd_qty = #{entity.storeSaleStddQty}
  159. ,store_sale_unit_amt = #{entity.storeSaleUnitAmt}
  160. where brand_unit_unq_no = #{entity.brandUnitUnqNo}
  161. </update>
  162. <insert id="insertMergItemUnitInfo" >
  163. insert into /** Merge insertMergItemUnitInfo */
  164. brand_item_unit_info
  165. (brand_unit_unq_no, brand_id, item_id, item_nm, spply_id,
  166. spply_nm, cont_stt_dt, cont_end_dt, curr, unit,
  167. unit_amt, lead_time, dlv_cndt, short_cont_file_no, spply_item_id,
  168. unit_st_cd, stdd_qty, store_sale_stdd_qty, store_sale_unit_amt,
  169. sys_reg_dttm, sys_reg_id, sys_chg_dttm, sys_chg_id)
  170. values
  171. ( fn_get_dealno(33,''), #{entity.brandId}, #{entity.itemId}, #{entity.itemNm}, #{entity.spplyId},
  172. #{entity.spplyNm}, #{entity.contSttDt}, #{entity.contEndDt}, #{entity.curr}, #{entity.unit},
  173. #{entity.unitAmt}, #{entity.leadTime}, #{entity.dlvCndt}, #{entity.shortContFileNo}, #{entity.spplyItemId},
  174. #{entity.unitStCd}, #{entity.stddQty}, #{entity.storeSaleStddQty}, #{entity.storeSaleUnitAmt},
  175. now(), #{userId}, now(), #{userId})
  176. on duplicate key
  177. update
  178. sys_chg_dttm = now()
  179. ,sys_chg_id = #{userId}
  180. ,cont_stt_dt = VALUES(cont_stt_dt)
  181. ,cont_end_dt = VALUES(cont_end_dt)
  182. ,curr = VALUES(curr)
  183. ,unit = VALUES(unit)
  184. ,unit_amt = VALUES(unit_amt)
  185. ,lead_time = VALUES(lead_time)
  186. ,dlv_cndt = VALUES(dlv_cndt)
  187. ,short_cont_file_no = VALUES(short_cont_file_no)
  188. ,unit_st_cd = VALUES(unit_st_cd)
  189. ,stdd_qty = VALUES(stdd_qty)
  190. ,store_sale_stdd_qty =VALUES(store_sale_stdd_qty)
  191. ,store_sale_unit_amt = VALUES(store_sale_unit_amt)
  192. </insert>
  193. <select id="selectPopItemBrandUnitGridList" resultType="com.oqpo.api.entity.stinfo.ItemUnitEntity">
  194. select /* selectPopItemBrandUnitGridList */
  195. iInfo.item_id,iInfo.item_nm,iInfo.podr_pssbl_dvsn, fn_code_nm('PODR_PSSBL_DVSN',iInfo.podr_pssbl_dvsn) AS podr_pssbl_dvsn_nm
  196. ,bInfo.unit, fn_code_nm('DSTRBT_COST_UNIT', bInfo.unit) as unit_nm, bInfo.stdd_qty, bInfo.unit_amt, bInfo.brand_unit_unq_no
  197. ,'B' as unit_gubun, bInfo.spply_id, fn_spply_nm(bInfo.spply_id) as spplyNm
  198. <if test="sWhsId == null or sWhsId == '' or sLocation = null or sLocation == ''">
  199. ,0 as whs_pass_qty
  200. </if>
  201. <if test="sWhsId != null and sWhsId != '' and sLocation != null and sLocation != ''">
  202. , nvl((stck.stck_qty - stck.wait_qty),0) as whs_pass_qty
  203. </if>
  204. from item_base_info iInfo
  205. join brand_item_unit_info bInfo on iInfo.brand_id = bInfo.brand_id and iInfo.item_id = bInfo.item_id and date_format(now(),'%Y%m%d') between bInfo.cont_stt_dt and bInfo.cont_end_dt
  206. <if test="sSpplyId != null and sSpplyId != '' ">
  207. and bInfo.spply_id = #{sSpplyId}
  208. </if>
  209. <if test="sWhsId != null and sWhsId != '' and sLocation != null and sLocation != ''">
  210. left outer join stck_mgnt_base_info stck on stck.brand_id = iInfo.brand_id and stck.item_id = iInfo.item_id and whs_id = #{sWhsId} and location = #{sLocation}
  211. </if>
  212. where iInfo.brand_id = #{sBrandId}
  213. AND iInfo.item_st_cd = 'IS00'
  214. <if test="sItemNm != null and sItemNm != ''">
  215. and (iInfo.item_nm like concat('%',#{sItemNm},'%') or iInfo.item_id like concat('%',#{sItemNm},'%'))
  216. </if>
  217. <if test="sPodrPssblDvsn != null and sPodrPssblDvsn != ''">
  218. and iInfo.podr_pssbl_dvsn = #{sPodrPssblDvsn}
  219. </if>
  220. <choose>
  221. <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
  222. <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
  223. <if test="gridRequest.sord == 'asc'.toString()">
  224. order by iInfo.item_nm asc
  225. </if>
  226. <if test="gridRequest.sord == 'desc'.toString()">
  227. order by iInfo.item_nm desc
  228. </if>
  229. </if>
  230. </when>
  231. <otherwise>
  232. order by iInfo.item_nm asc
  233. </otherwise>
  234. </choose>
  235. <if test="gridRequest.pagingYn == true">
  236. limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
  237. </if>
  238. </select>
  239. <select id="selectPopItemBrandUnitGridCnt" resultType="int">
  240. select /* selectPopItemBrandUnitGridCnt */
  241. count(*)
  242. from item_base_info iInfo
  243. join brand_item_unit_info bInfo on iInfo.brand_id = bInfo.brand_id and iInfo.item_id = bInfo.item_id and date_format(now(),'%Y%m%d') between bInfo.cont_stt_dt and bInfo.cont_end_dt
  244. <if test="sSpplyId != null and sSpplyId != '' ">
  245. and bInfo.spply_id = #{sSpplyId}
  246. </if>
  247. where iInfo.brand_id = #{sBrandId}
  248. AND iInfo.item_st_cd = 'IS00'
  249. <if test="sItemNm != null and sItemNm != ''">
  250. and (iInfo.item_nm like concat('%',#{sItemNm},'%') or iInfo.item_id like concat('%',#{sItemNm},'%'))
  251. </if>
  252. <if test="sPodrPssblDvsn != null and sPodrPssblDvsn != ''">
  253. and iInfo.podr_pssbl_dvsn = #{sPodrPssblDvsn}
  254. </if>
  255. </select>
  256. <select id="selectPopNewItemBrandUnitGridList" resultType="com.oqpo.api.entity.stinfo.ItemUnitEntity">
  257. select /* selectPopNewItemBrandUnitGridList */
  258. iInfo.item_id,iInfo.item_nm,iInfo.podr_pssbl_dvsn, fn_code_nm('PODR_PSSBL_DVSN',iInfo.podr_pssbl_dvsn) AS podr_pssbl_dvsn_nm
  259. ,iInfo.unit, fn_code_nm('DSTRBT_COST_UNIT', iInfo.unit) as unit_nm, bInfo.stdd_qty, bInfo.unit_amt, bInfo.brand_unit_unq_no
  260. ,'B' as unit_gubun, bInfo.spply_id
  261. <if test="sWhsId == null or sWhsId == '' or sLocation = null or sLocation == ''">
  262. ,0 as whs_pass_qty
  263. </if>
  264. <if test="sWhsId != null and sWhsId != '' and sLocation != null and sLocation != ''">
  265. , nvl((stck.stck_qty - stck.wait_qty),0) as whs_pass_qty
  266. </if>
  267. from item_base_info iInfo
  268. left outer join brand_item_unit_info bInfo on iInfo.brand_id = bInfo.brand_id and iInfo.item_id = bInfo.item_id and date_format(now(),'%Y%m%d') between bInfo.cont_stt_dt and bInfo.cont_end_dt
  269. <if test="sSpplyId != null and sSpplyId != '' ">
  270. and bInfo.spply_id = #{sSpplyId}
  271. </if>
  272. <if test="sWhsId != null and sWhsId != '' and sLocation != null and sLocation != ''">
  273. left outer join stck_mgnt_base_info stck on stck.brand_id = iInfo.brand_id and stck.item_id = iInfo.item_id and whs_id = #{sWhsId} and location = #{sLocation}
  274. </if>
  275. where iInfo.brand_id = #{sBrandId}
  276. AND iInfo.item_st_cd = 'IS00'
  277. <if test="sItemNm != null and sItemNm != ''">
  278. and (iInfo.item_nm like concat('%',#{sItemNm},'%') or iInfo.item_id like concat('%',#{sItemNm},'%'))
  279. </if>
  280. <if test="sPodrPssblDvsn != null and sPodrPssblDvsn != ''">
  281. and iInfo.podr_pssbl_dvsn = #{sPodrPssblDvsn}
  282. </if>
  283. <choose>
  284. <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
  285. <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
  286. <if test="gridRequest.sord == 'asc'.toString()">
  287. order by iInfo.item_nm asc
  288. </if>
  289. <if test="gridRequest.sord == 'desc'.toString()">
  290. order by iInfo.item_nm desc
  291. </if>
  292. </if>
  293. </when>
  294. <otherwise>
  295. order by iInfo.item_nm asc
  296. </otherwise>
  297. </choose>
  298. <if test="gridRequest.pagingYn == true">
  299. limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
  300. </if>
  301. </select>
  302. <select id="selectPopNewItemBrandUnitGridCnt" resultType="int">
  303. select /* selectPopNewItemBrandUnitGridCnt */
  304. count(*)
  305. from item_base_info iInfo
  306. left outer join brand_item_unit_info bInfo on iInfo.brand_id = bInfo.brand_id and iInfo.item_id = bInfo.item_id and date_format(now(),'%Y%m%d') between bInfo.cont_stt_dt and bInfo.cont_end_dt
  307. <if test="sSpplyId != null and sSpplyId != '' ">
  308. and bInfo.spply_id = #{sSpplyId}
  309. </if>
  310. where iInfo.brand_id = #{sBrandId}
  311. AND iInfo.item_st_cd = 'IS00'
  312. <if test="sItemNm != null and sItemNm != ''">
  313. and (iInfo.item_nm like concat('%',#{sItemNm},'%') or iInfo.item_id like concat('%',#{sItemNm},'%'))
  314. </if>
  315. <if test="sPodrPssblDvsn != null and sPodrPssblDvsn != ''">
  316. and iInfo.podr_pssbl_dvsn = #{sPodrPssblDvsn}
  317. </if>
  318. </select>
  319. <select id="selectPopItemStoreUnitGridList" resultType="com.oqpo.api.entity.stinfo.ItemUnitEntity">
  320. select /* selectPopItemStoreUnitGridList */
  321. iInfo.item_id,iInfo.item_nm,iInfo.podr_pssbl_dvsn, fn_code_nm('PODR_PSSBL_DVSN',iInfo.podr_pssbl_dvsn) AS podr_pssbl_dvsn_nm
  322. ,sInfo.unit, fn_code_nm('DSTRBT_COST_UNIT', sInfo.unit) as unit_nm, sInfo.stdd_qty, sInfo.unit_amt, sInfo.store_unit_unq_no
  323. ,'S' as unit_gubun, sInfo.brand_unit_unq_no
  324. , 0 as whs_pass_qty, '' as spply_id
  325. from item_base_info iInfo
  326. join store_base_info store on iInfo.brand_id = store.brand_id and store.store_id = #{sStoreId}
  327. join store_item_unit_info sInfo on iInfo.brand_id = sInfo.brand_id and iInfo.item_id = sInfo.item_id and sInfo.unit_target_cd = 'Y'
  328. and store.store_id = sInfo.store_id and sInfo.store_id = #{sStoreId}
  329. and date_format(now(),'%Y%m%d') between sInfo.cont_stt_dt and sInfo.cont_end_dt
  330. where iInfo.brand_id = #{sBrandId}
  331. AND iInfo.item_st_cd = 'IS00'
  332. <if test="sItemNm != null and sItemNm != ''">
  333. and (iInfo.item_nm like concat('%',#{sItemNm},'%') or iInfo.item_id like concat('%',#{sItemNm},'%'))
  334. </if>
  335. <if test="sPodrPssblDvsn != null and sPodrPssblDvsn != ''">
  336. and iInfo.podr_pssbl_dvsn = #{sPodrPssblDvsn}
  337. </if>
  338. <choose>
  339. <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
  340. <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
  341. <if test="gridRequest.sord == 'asc'.toString()">
  342. order by iInfo.item_nm asc
  343. </if>
  344. <if test="gridRequest.sord == 'desc'.toString()">
  345. order by iInfo.item_nm desc
  346. </if>
  347. </if>
  348. </when>
  349. <otherwise>
  350. order by iInfo.item_nm asc
  351. </otherwise>
  352. </choose>
  353. <if test="gridRequest.pagingYn == true">
  354. limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
  355. </if>
  356. </select>
  357. <select id="selectPopItemStoreUnitGridCnt" resultType="int">
  358. select /* selectPopItemStoreUnitGridCnt */
  359. count(*)
  360. from item_base_info iInfo
  361. join store_base_info store on iInfo.brand_id = store.brand_id and store.store_id = #{sStoreId}
  362. join store_item_unit_info sInfo on iInfo.brand_id = sInfo.brand_id and iInfo.item_id = sInfo.item_id and sInfo.unit_target_cd = 'Y'
  363. and store.store_id = sInfo.store_id and sInfo.store_id = #{sStoreId}
  364. and date_format(now(),'%Y%m%d') between sInfo.cont_stt_dt and sInfo.cont_end_dt
  365. where iInfo.brand_id = #{sBrandId}
  366. AND iInfo.item_st_cd = 'IS00'
  367. <if test="sItemNm != null and sItemNm != ''">
  368. and (iInfo.item_nm like concat('%',#{sItemNm},'%') or iInfo.item_id like concat('%',#{sItemNm},'%'))
  369. </if>
  370. <if test="sPodrPssblDvsn != null and sPodrPssblDvsn != ''">
  371. and iInfo.podr_pssbl_dvsn = #{sPodrPssblDvsn}
  372. </if>
  373. </select>
  374. <select id="selectPopNewItemStoreUnitGridList" resultType="com.oqpo.api.entity.stinfo.ItemUnitEntity">
  375. select /* selectPopNewItemStoreUnitGridList */
  376. iInfo.item_id,iInfo.item_nm,iInfo.podr_pssbl_dvsn, fn_code_nm('PODR_PSSBL_DVSN',iInfo.podr_pssbl_dvsn) AS podr_pssbl_dvsn_nm
  377. ,iInfo.unit, fn_code_nm('DSTRBT_COST_UNIT', iInfo.unit) as unit_nm, sInfo.stdd_qty, sInfo.unit_amt, sInfo.store_unit_unq_no
  378. ,'S' as unit_gubun, sInfo.brand_unit_unq_no
  379. , 0 as whs_pass_qty, '' as spply_id
  380. from item_base_info iInfo
  381. join store_base_info store on iInfo.brand_id = store.brand_id and store.store_id = #{sStoreId}
  382. join store_item_unit_info sInfo on iInfo.brand_id = sInfo.brand_id and iInfo.item_id = sInfo.item_id and sInfo.unit_target_cd = 'Y'
  383. and store.store_id = sInfo.store_id and sInfo.store_id = #{sStoreId}
  384. and date_format(now(),'%Y%m%d') between sInfo.cont_stt_dt and sInfo.cont_end_dt
  385. where iInfo.brand_id = #{sBrandId}
  386. AND iInfo.item_st_cd = 'IS00'
  387. <if test="sItemNm != null and sItemNm != ''">
  388. and (iInfo.item_nm like concat('%',#{sItemNm},'%') or iInfo.item_id like concat('%',#{sItemNm},'%'))
  389. </if>
  390. <if test="sPodrPssblDvsn != null and sPodrPssblDvsn != ''">
  391. and iInfo.podr_pssbl_dvsn = #{sPodrPssblDvsn}
  392. </if>
  393. <choose>
  394. <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
  395. <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
  396. <if test="gridRequest.sord == 'asc'.toString()">
  397. order by iInfo.item_nm asc
  398. </if>
  399. <if test="gridRequest.sord == 'desc'.toString()">
  400. order by iInfo.item_nm desc
  401. </if>
  402. </if>
  403. </when>
  404. <otherwise>
  405. order by iInfo.item_nm asc
  406. </otherwise>
  407. </choose>
  408. <if test="gridRequest.pagingYn == true">
  409. limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
  410. </if>
  411. </select>
  412. <select id="selectPopNewItemStoreUnitGridCnt" resultType="int">
  413. select /* selectPopNewItemStoreUnitGridCnt */
  414. count(*)
  415. from item_base_info iInfo
  416. join store_base_info store on iInfo.brand_id = store.brand_id and store.store_id = #{sStoreId}
  417. join store_item_unit_info sInfo on iInfo.brand_id = sInfo.brand_id and iInfo.item_id = sInfo.item_id and sInfo.unit_target_cd = 'Y'
  418. and store.store_id = sInfo.store_id and sInfo.store_id = #{sStoreId}
  419. and date_format(now(),'%Y%m%d') between sInfo.cont_stt_dt and sInfo.cont_end_dt
  420. where iInfo.brand_id = #{sBrandId}
  421. AND iInfo.item_st_cd = 'IS00'
  422. <if test="sItemNm != null and sItemNm != ''">
  423. and (iInfo.item_nm like concat('%',#{sItemNm},'%') or iInfo.item_id like concat('%',#{sItemNm},'%'))
  424. </if>
  425. <if test="sPodrPssblDvsn != null and sPodrPssblDvsn != ''">
  426. and iInfo.podr_pssbl_dvsn = #{sPodrPssblDvsn}
  427. </if>
  428. </select>
  429. <select id="selectBarcodeItemBrandUnitInfo" resultType="com.oqpo.api.entity.stinfo.ItemUnitEntity">
  430. select /* selectBarcodeItemBrandUnitInfo */
  431. iInfo.item_id,iInfo.item_nm,iInfo.podr_pssbl_dvsn, fn_code_nm('PODR_PSSBL_DVSN',iInfo.podr_pssbl_dvsn) AS podr_pssbl_dvsn_nm
  432. ,bInfo.unit, fn_code_nm('DSTRBT_COST_UNIT', bInfo.unit) as unit_nm, bInfo.stdd_qty, bInfo.unit_amt, bInfo.brand_unit_unq_no
  433. ,'B' as unit_gubun, bInfo.spply_id, fn_spply_nm(bInfo.spply_id) as spplyNm
  434. ,0 as whs_pass_qty
  435. from item_base_info iInfo
  436. join brand_item_unit_info bInfo on iInfo.brand_id = bInfo.brand_id and iInfo.item_id = bInfo.item_id and date_format(now(),'%Y%m%d') between bInfo.cont_stt_dt and bInfo.cont_end_dt
  437. where iInfo.brand_id = #{sBrandId}
  438. and iInfo.barcode = #{sBarcode}
  439. AND iInfo.item_st_cd = 'IS00'
  440. and iInfo.podr_pssbl_dvsn = 'PO01'
  441. </select>
  442. <select id="selectBarcodeItemStoreUnitInfo" resultType="com.oqpo.api.entity.stinfo.ItemUnitEntity">
  443. select /* selectBarcodeItemStoreUnitInfo */
  444. iInfo.item_id,iInfo.item_nm,iInfo.podr_pssbl_dvsn, fn_code_nm('PODR_PSSBL_DVSN',iInfo.podr_pssbl_dvsn) AS podr_pssbl_dvsn_nm
  445. ,sInfo.unit, fn_code_nm('DSTRBT_COST_UNIT', sInfo.unit) as unit_nm, sInfo.stdd_qty, sInfo.unit_amt, sInfo.store_unit_unq_no
  446. ,'S' as unit_gubun, sInfo.brand_unit_unq_no
  447. , 0 as whs_pass_qty, '' as spply_id
  448. from item_base_info iInfo
  449. join store_base_info store on iInfo.brand_id = store.brand_id and store.store_id = #{sStoreId}
  450. join store_item_unit_info sInfo on iInfo.brand_id = sInfo.brand_id and iInfo.item_id = sInfo.item_id and sInfo.unit_target_cd = 'Y'
  451. and store.store_id = sInfo.store_id and sInfo.store_id = #{sStoreId}
  452. and date_format(now(),'%Y%m%d') between sInfo.cont_stt_dt and sInfo.cont_end_dt
  453. where iInfo.brand_id = #{sBrandId}
  454. and iInfo.barcode = #{sBarcode}
  455. AND iInfo.item_st_cd = 'IS00'
  456. and iInfo.podr_pssbl_dvsn = 'PO01'
  457. </select>
  458. <select id="selectPopWishGridList" resultType="com.oqpo.api.entity.stinfo.ItemUnitEntity">
  459. SELECT mgnt.wish_list_mgnt_no, mgnt.wish_list_nm
  460. FROM store_wish_list_mgnt mgnt
  461. WHERE 1 = 1
  462. AND mgnt.store_id = #{sStoreId}
  463. AND mgnt.del_yn = 'N'
  464. </select>
  465. <select id="selectPopItemStoreUnitWishGridList" resultType="com.oqpo.api.entity.stinfo.ItemUnitEntity">
  466. select /* selectPopItemStoreUnitWishGridList */
  467. iInfo.item_id,iInfo.item_nm,iInfo.podr_pssbl_dvsn, fn_code_nm('PODR_PSSBL_DVSN',iInfo.podr_pssbl_dvsn) AS podr_pssbl_dvsn_nm
  468. ,sInfo.unit, fn_code_nm('DSTRBT_COST_UNIT', sInfo.unit) as unit_nm, sInfo.stdd_qty, sInfo.unit_amt, sInfo.store_unit_unq_no
  469. ,'S' as unit_gubun, sInfo.brand_unit_unq_no
  470. , 0 as whs_pass_qty, '' as spply_id
  471. from item_base_info iInfo
  472. join store_base_info store on iInfo.brand_id = store.brand_id and store.store_id = #{sStoreId}
  473. join store_item_unit_info sInfo on iInfo.brand_id = sInfo.brand_id and iInfo.item_id = sInfo.item_id and sInfo.unit_target_cd = 'Y'
  474. and store.store_id = sInfo.store_id and sInfo.store_id = #{sStoreId}
  475. and date_format(now(),'%Y%m%d') between sInfo.cont_stt_dt and sInfo.cont_end_dt
  476. join store_wish_list_mgnt wishmng on sInfo.store_id = wishmng.store_id and wishmng.wish_list_mgnt_no = #{sWishListMgntNo} and wishmng.del_yn = 'N'
  477. join store_wish_list_ptcl wishptcl on wishmng.wish_list_mgnt_no = wishptcl.wish_list_mgnt_no and iInfo.item_id = wishptcl.item_id
  478. where iInfo.brand_id = #{sBrandId}
  479. AND iInfo.item_st_cd = 'IS00'
  480. and iInfo.podr_pssbl_dvsn = 'PO01'
  481. <choose>
  482. <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
  483. <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
  484. <if test="gridRequest.sord == 'asc'.toString()">
  485. order by iInfo.item_nm asc
  486. </if>
  487. <if test="gridRequest.sord == 'desc'.toString()">
  488. order by iInfo.item_nm desc
  489. </if>
  490. </if>
  491. </when>
  492. <otherwise>
  493. order by iInfo.item_nm asc
  494. </otherwise>
  495. </choose>
  496. <if test="gridRequest.pagingYn == true">
  497. limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
  498. </if>
  499. </select>
  500. <select id="selectPopItemStoreUnitWishGridCnt" resultType="int">
  501. select /* selectPopItemStoreUnitWishGridCnt */
  502. count(*)
  503. from item_base_info iInfo
  504. join store_base_info store on iInfo.brand_id = store.brand_id and store.store_id = #{sStoreId}
  505. join store_item_unit_info sInfo on iInfo.brand_id = sInfo.brand_id and iInfo.item_id = sInfo.item_id and sInfo.unit_target_cd = 'Y'
  506. and store.store_id = sInfo.store_id and sInfo.store_id = #{sStoreId}
  507. and date_format(now(),'%Y%m%d') between sInfo.cont_stt_dt and sInfo.cont_end_dt
  508. join store_wish_list_mgnt wishmng on sInfo.store_id = wishmng.store_id and wishmng.wish_list_mgnt_no = #{sWishListMgntNo} and wishmng.del_yn = 'N'
  509. join store_wish_list_ptcl wishptcl on wishmng.wish_list_mgnt_no = wishptcl.wish_list_mgnt_no and iInfo.item_id = wishptcl.item_id
  510. where iInfo.brand_id = #{sBrandId}
  511. AND iInfo.item_st_cd = 'IS00'
  512. and iInfo.podr_pssbl_dvsn = 'PO01'
  513. </select>
  514. <select id="selectPopStoreItemLackStockGridCnt" resultType="int">
  515. SELECT count(*) as cnt
  516. FROM store_base_info store
  517. INNER JOIN whs_mgnt_base_info whs
  518. ON store.STORE_ID = whs.STORE_ID AND store.BRAND_ID = whs.BRAND_ID and whs.WHS_ID = #{sWhsId} and whs.WHS_DVSN = 'W02'
  519. INNER JOIN whs_mgnt_base_loc loc
  520. ON whs.whs_id = loc.whs_id and whs.brand_id = loc.brand_id
  521. INNER JOIN stck_mgnt_base_info stck
  522. ON store.BRAND_ID = stck.BRAND_ID AND whs.WHS_ID = stck.WHS_ID and loc.location = stck.location
  523. INNER JOIN store_item_unit_info sitem
  524. ON stck.ITEM_ID = sitem.ITEM_ID AND store.BRAND_ID = sitem.BRAND_ID AND store.STORE_ID = sitem.STORE_ID
  525. and date_format(now() ,'%Y%m%d') between sitem.cont_stt_dt and sitem.cont_end_dt
  526. INNER JOIN item_base_info item
  527. ON sitem.ITEM_ID = item.ITEM_ID AND sitem.BRAND_ID = item.BRAND_ID
  528. WHERE 1 = 1
  529. AND store.BRAND_ID = #{sBrandId}
  530. AND store.STORE_ID = #{sStoreId}
  531. AND whs.WHS_ID = #{sWhsId}
  532. AND whs.WHS_DVSN = 'W02'
  533. AND stck.STCK_QTY <![CDATA[ < ]]> FLOOR(stck.PRP_STCK_QTY * stck.SFT_STCK_RT <![CDATA[ / ]]> 100)
  534. </select>
  535. <select id="selectPopStoreItemLackStockGridList" resultType="com.oqpo.api.entity.stinfo.ItemUnitEntity">
  536. SELECT item.ITEM_ID
  537. , item.ITEM_NM
  538. , item.UNIT
  539. , FN_CODE_NM('DSTRBT_COST_UNIT', item.UNIT) AS unit_nm
  540. , item.PODR_PSSBL_DVSN
  541. , FN_CODE_NM('PODR_PSSBL_DVSN', item.PODR_PSSBL_DVSN) AS PODR_PSSBL_DVSN_NM
  542. , sitem.UNIT_AMT
  543. , sitem.STORE_UNIT_UNQ_NO
  544. , sitem.BRAND_UNIT_UNQ_NO
  545. , stck.STCK_QTY /* 현 수량 */
  546. , nvl(stck.PRP_STCK_QTY,0) * #{podrNum} AS podr_qty /* 발주 수량 */
  547. , FLOOR(stck.PRP_STCK_QTY * stck.SFT_STCK_RT / 100) AS cur_qty /* 안전재고 수량 */
  548. , stck.PRP_STCK_QTY /* 안전재고 기준수량 */
  549. , stck.SFT_STCK_RT /* 안전재고율 */
  550. ,'S' as unit_gubun
  551. , concat( whs.whs_nm , case when loc.location is null then '' else concat('-',loc.LOCATION_NM) end) as whs_nm
  552. FROM store_base_info store
  553. INNER JOIN whs_mgnt_base_info whs
  554. ON store.STORE_ID = whs.STORE_ID AND store.BRAND_ID = whs.BRAND_ID and whs.WHS_ID = #{sWhsId} and whs.WHS_DVSN = 'W02'
  555. INNER JOIN whs_mgnt_base_loc loc
  556. ON whs.whs_id = loc.whs_id and whs.brand_id = loc.brand_id
  557. INNER JOIN stck_mgnt_base_info stck
  558. ON store.BRAND_ID = stck.BRAND_ID AND whs.WHS_ID = stck.WHS_ID and loc.location = stck.location
  559. INNER JOIN store_item_unit_info sitem
  560. ON stck.ITEM_ID = sitem.ITEM_ID AND store.BRAND_ID = sitem.BRAND_ID AND store.STORE_ID = sitem.STORE_ID
  561. and date_format(now() ,'%Y%m%d') between sitem.cont_stt_dt and sitem.cont_end_dt
  562. INNER JOIN item_base_info item
  563. ON sitem.ITEM_ID = item.ITEM_ID AND sitem.BRAND_ID = item.BRAND_ID
  564. WHERE 1 = 1
  565. AND store.BRAND_ID = #{sBrandId}
  566. AND store.STORE_ID = #{sStoreId}
  567. AND stck.STCK_QTY <![CDATA[ < ]]> FLOOR(stck.PRP_STCK_QTY * stck.SFT_STCK_RT <![CDATA[ / ]]> 100)
  568. <choose>
  569. <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
  570. <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
  571. <if test="gridRequest.sord == 'asc'.toString()">
  572. order by item.item_nm asc
  573. </if>
  574. <if test="gridRequest.sord == 'desc'.toString()">
  575. order by item.item_nm desc
  576. </if>
  577. </if>
  578. </when>
  579. <otherwise>
  580. order by item.item_nm asc
  581. </otherwise>
  582. </choose>
  583. <if test="gridRequest.pagingYn == true">
  584. limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
  585. </if>
  586. </select>
  587. <select id="selectPopBrandItemLackStockGridCnt" resultType="int">
  588. SELECT count(*) as cnt
  589. FROM brand_base_info brand
  590. INNER JOIN whs_mgnt_base_info whs
  591. ON brand.BRAND_ID = whs.BRAND_ID and whs.WHS_ID = #{sWhsId} and whs.WHS_DVSN = 'W01'
  592. INNER JOIN whs_mgnt_base_loc loc
  593. ON whs.whs_id = loc.whs_id and whs.brand_id = loc.brand_id
  594. INNER JOIN stck_mgnt_base_info stck
  595. ON brand.BRAND_ID = stck.BRAND_ID AND whs.WHS_ID = stck.WHS_ID and loc.location = stck.location
  596. INNER JOIN brand_item_unit_info bitem
  597. ON stck.ITEM_ID = bitem.ITEM_ID AND brand.BRAND_ID = bitem.BRAND_ID
  598. and date_format(now() ,'%Y%m%d') between bitem.cont_stt_dt and bitem.cont_end_dt
  599. INNER JOIN item_base_info item
  600. ON bitem.ITEM_ID = item.ITEM_ID AND bitem.BRAND_ID = item.BRAND_ID
  601. WHERE 1 = 1
  602. AND brand.BRAND_ID = #{sBrandId}
  603. AND stck.STCK_QTY <![CDATA[ < ]]> FLOOR(stck.PRP_STCK_QTY * stck.SFT_STCK_RT <![CDATA[ / ]]> 100)
  604. </select>
  605. <select id="selectPopBrandItemLackStockGridList" resultType="com.oqpo.api.entity.stinfo.ItemUnitEntity">
  606. SELECT item.ITEM_ID
  607. , item.ITEM_NM
  608. , item.UNIT
  609. , FN_CODE_NM('DSTRBT_COST_UNIT', item.UNIT) AS unit_nm
  610. , item.PODR_PSSBL_DVSN
  611. , FN_CODE_NM('PODR_PSSBL_DVSN', item.PODR_PSSBL_DVSN) AS PODR_PSSBL_DVSN_NM
  612. , bitem.UNIT_AMT
  613. , '' AS STORE_UNIT_UNQ_NO
  614. , bitem.BRAND_UNIT_UNQ_NO
  615. , stck.STCK_QTY /* 현 수량 */
  616. , nvl(stck.PRP_STCK_QTY,0) * #{podrNum} AS podr_qty /* 발주 수량 */
  617. , FLOOR(stck.PRP_STCK_QTY * stck.SFT_STCK_RT / 100) AS cur_qty /* 안전재고 수량 */
  618. , stck.PRP_STCK_QTY /* 안전재고 기준수량 */
  619. , stck.SFT_STCK_RT /* 안전재고율 */
  620. , whs.WHS_ID
  621. ,'B' as unit_gubun
  622. , concat( whs.whs_nm , case when loc.location is null then '' else concat('-',loc.LOCATION_NM) end) as whs_nm
  623. FROM brand_base_info brand
  624. INNER JOIN whs_mgnt_base_info whs
  625. ON brand.BRAND_ID = whs.BRAND_ID and whs.WHS_ID = #{sWhsId} and whs.WHS_DVSN = 'W01'
  626. INNER JOIN whs_mgnt_base_loc loc
  627. ON whs.whs_id = loc.whs_id and whs.brand_id = loc.brand_id
  628. INNER JOIN stck_mgnt_base_info stck
  629. ON brand.BRAND_ID = stck.BRAND_ID AND whs.WHS_ID = stck.WHS_ID and loc.location = stck.location
  630. INNER JOIN brand_item_unit_info bitem
  631. ON stck.ITEM_ID = bitem.ITEM_ID AND brand.BRAND_ID = bitem.BRAND_ID
  632. and date_format(now() ,'%Y%m%d') between bitem.cont_stt_dt and bitem.cont_end_dt
  633. INNER JOIN item_base_info item
  634. ON bitem.ITEM_ID = item.ITEM_ID AND bitem.BRAND_ID = item.BRAND_ID
  635. WHERE 1 = 1
  636. AND brand.BRAND_ID = #{sBrandId}
  637. AND stck.STCK_QTY <![CDATA[ < ]]> FLOOR(stck.PRP_STCK_QTY * stck.SFT_STCK_RT <![CDATA[ / ]]> 100)
  638. <choose>
  639. <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
  640. <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
  641. <if test="gridRequest.sord == 'asc'.toString()">
  642. order by item.item_nm asc
  643. </if>
  644. <if test="gridRequest.sord == 'desc'.toString()">
  645. order by item.item_nm desc
  646. </if>
  647. </if>
  648. </when>
  649. <otherwise>
  650. order by item.item_nm asc
  651. </otherwise>
  652. </choose>
  653. <if test="gridRequest.pagingYn == true">
  654. limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
  655. </if>
  656. </select>
  657. <select id="selectPopWishListItem" resultType="com.oqpo.api.entity.stinfo.ItemUnitEntity">
  658. select /* selectPopWishListItem */
  659. iInfo.item_id,iInfo.item_nm,iInfo.podr_pssbl_dvsn, fn_code_nm('PODR_PSSBL_DVSN',iInfo.podr_pssbl_dvsn) AS podr_pssbl_dvsn_nm
  660. ,sInfo.unit, fn_code_nm('DSTRBT_COST_UNIT', sInfo.unit) as unit_nm, sInfo.stdd_qty, sInfo.unit_amt
  661. , sInfo.store_unit_unq_no,'S' as unit_gubun, sInfo.brand_unit_unq_no
  662. from item_base_info iInfo
  663. join store_base_info store on iInfo.brand_id = store.brand_id and store.store_id = #{storeId}
  664. join store_item_unit_info sInfo on iInfo.brand_id = sInfo.brand_id and iInfo.item_id = sInfo.item_id and sInfo.unit_target_cd = 'Y'
  665. join store_wish_list_mgnt wish on wish_list_mgnt_no = #{wishListMgntNo} and wish.store_id = store.store_id and wish.del_yn = 'N'
  666. join store_wish_list_ptcl wishptcl on wish.wish_list_mgnt_no = wishptcl.wish_list_mgnt_no and wishptcl.item_id = iInfo.item_id and wishptcl.del_yn = 'N'
  667. and store.store_id = sInfo.store_id and sInfo.store_id = #{storeId}
  668. and date_format(now(),'%Y%m%d') between sInfo.cont_stt_dt and sInfo.cont_end_dt
  669. where iInfo.brand_id = #{brandId}
  670. AND iInfo.item_st_cd = 'IS00'
  671. <choose>
  672. <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
  673. <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
  674. <if test="gridRequest.sord == 'asc'.toString()">
  675. order by iInfo.item_nm asc
  676. </if>
  677. <if test="gridRequest.sord == 'desc'.toString()">
  678. order by iInfo.item_nm desc
  679. </if>
  680. </if>
  681. </when>
  682. <otherwise>
  683. order by iInfo.item_nm asc
  684. </otherwise>
  685. </choose>
  686. <if test="gridRequest.pagingYn == true">
  687. limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
  688. </if>
  689. </select>
  690. <select id="selectPopWishListItemCnt" resultType="int">
  691. select /* selectPopWishListItemCnt */
  692. count(*) as cnt
  693. from item_base_info iInfo
  694. join store_base_info store on iInfo.brand_id = store.brand_id and store.store_id = #{storeId}
  695. join store_item_unit_info sInfo on iInfo.brand_id = sInfo.brand_id and iInfo.item_id = sInfo.item_id and sInfo.unit_target_cd = 'Y'
  696. join store_wish_list_mgnt wish on wish_list_mgnt_no = #{wishListMgntNo} and wish.store_id = store.store_id and wish.del_yn = 'N'
  697. join store_wish_list_ptcl wishptcl on wish.wish_list_mgnt_no = wishptcl.wish_list_mgnt_no and wishptcl.item_id = iInfo.item_id and wishptcl.del_yn = 'N'
  698. and store.store_id = sInfo.store_id and sInfo.store_id = #{storeId}
  699. and date_format(now(),'%Y%m%d') between sInfo.cont_stt_dt and sInfo.cont_end_dt
  700. where iInfo.brand_id = #{brandId}
  701. AND iInfo.item_st_cd = 'IS00'
  702. </select>
  703. <select id="selectPopItemBrandBaseUnitGridCnt" resultType="int">
  704. select /* selectPopItemBrandUnitGridCnt */
  705. count(*)
  706. from item_base_info iInfo
  707. where iInfo.brand_id = #{sBrandId}
  708. AND iInfo.item_st_cd = 'IS00'
  709. <if test="sItemNm != null and sItemNm != ''">
  710. and (iInfo.item_nm like concat('%',#{sItemNm},'%') or iInfo.item_id like concat('%',#{sItemNm},'%'))
  711. </if>
  712. <if test="sPodrPssblDvsn != null and sPodrPssblDvsn != ''">
  713. and iInfo.podr_pssbl_dvsn = #{sPodrPssblDvsn}
  714. </if>
  715. </select>
  716. <select id="selectPopItemBrandBaseUnitGridList" resultType="com.oqpo.api.entity.stinfo.ItemUnitEntity">
  717. select /* selectPopNewItemBrandUnitGridList */
  718. iInfo.item_id,iInfo.item_nm,iInfo.podr_pssbl_dvsn, fn_code_nm('PODR_PSSBL_DVSN',iInfo.podr_pssbl_dvsn) AS podr_pssbl_dvsn_nm
  719. ,iInfo.unit, fn_code_nm('DSTRBT_COST_UNIT', iInfo.unit) as unit_nm
  720. , iInfo.store_deli_type, fn_code_nm('STORE_DELI_TYPE', iInfo.store_deli_type) as store_deli_type_nm
  721. from item_base_info iInfo
  722. where iInfo.brand_id = #{sBrandId}
  723. AND iInfo.item_st_cd = 'IS00'
  724. <if test="sItemNm != null and sItemNm != ''">
  725. and (iInfo.item_nm like concat('%',#{sItemNm},'%') or iInfo.item_id like concat('%',#{sItemNm},'%'))
  726. </if>
  727. <if test="sPodrPssblDvsn != null and sPodrPssblDvsn != ''">
  728. and iInfo.podr_pssbl_dvsn = #{sPodrPssblDvsn}
  729. </if>
  730. <choose>
  731. <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
  732. <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
  733. <if test="gridRequest.sord == 'asc'.toString()">
  734. order by iInfo.item_nm asc
  735. </if>
  736. <if test="gridRequest.sord == 'desc'.toString()">
  737. order by iInfo.item_nm desc
  738. </if>
  739. </if>
  740. </when>
  741. <otherwise>
  742. order by iInfo.item_nm asc
  743. </otherwise>
  744. </choose>
  745. <if test="gridRequest.pagingYn == true">
  746. limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
  747. </if>
  748. </select>
  749. <select id="selectPopItemStoreUnitBaseGridList" resultType="com.oqpo.api.entity.stinfo.ItemUnitEntity">
  750. select /* selectPopItemStoreUnitBaseGridList */
  751. distinct iInfo.item_id,iInfo.item_nm,iInfo.podr_pssbl_dvsn, fn_code_nm('PODR_PSSBL_DVSN',iInfo.podr_pssbl_dvsn) AS podr_pssbl_dvsn_nm
  752. ,sInfo.unit, fn_code_nm('DSTRBT_COST_UNIT', sInfo.unit) as unit_nm
  753. , iInfo.store_deli_type, fn_code_nm('STORE_DELI_TYPE', iInfo.store_deli_type) as store_deli_type_nm
  754. from item_base_info iInfo
  755. join store_base_info store on iInfo.brand_id = store.brand_id and store.store_id = #{sStoreId}
  756. join store_item_unit_info sInfo on iInfo.brand_id = sInfo.brand_id and iInfo.item_id = sInfo.item_id and sInfo.unit_target_cd = 'Y'
  757. and store.store_id = sInfo.store_id and sInfo.store_id = #{sStoreId}
  758. and date_format(now(),'%Y%m%d') between sInfo.cont_stt_dt and sInfo.cont_end_dt
  759. where iInfo.brand_id = #{sBrandId}
  760. AND iInfo.item_st_cd = 'IS00'
  761. <if test="sItemNm != null and sItemNm != ''">
  762. and (iInfo.item_nm like concat('%',#{sItemNm},'%') or iInfo.item_id like concat('%',#{sItemNm},'%'))
  763. </if>
  764. <if test="sPodrPssblDvsn != null and sPodrPssblDvsn != ''">
  765. and iInfo.podr_pssbl_dvsn = #{sPodrPssblDvsn}
  766. </if>
  767. <choose>
  768. <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
  769. <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
  770. <if test="gridRequest.sord == 'asc'.toString()">
  771. order by iInfo.item_nm asc
  772. </if>
  773. <if test="gridRequest.sord == 'desc'.toString()">
  774. order by iInfo.item_nm desc
  775. </if>
  776. </if>
  777. </when>
  778. <otherwise>
  779. order by iInfo.item_nm asc
  780. </otherwise>
  781. </choose>
  782. <if test="gridRequest.pagingYn == true">
  783. limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
  784. </if>
  785. </select>
  786. <select id="selectPopItemStoreUnitBaseGridCnt" resultType="int">
  787. select /* selectPopItemStoreUnitBaseGridCnt */
  788. count(distinct iInfo.item_id, iInfo.item_nm, iInfo.podr_pssbl_dvsn, sInfo.unit)
  789. from item_base_info iInfo
  790. join store_base_info store on iInfo.brand_id = store.brand_id and store.store_id = #{sStoreId}
  791. join store_item_unit_info sInfo on iInfo.brand_id = sInfo.brand_id and iInfo.item_id = sInfo.item_id and sInfo.unit_target_cd = 'Y'
  792. and store.store_id = sInfo.store_id and sInfo.store_id = #{sStoreId}
  793. and date_format(now(),'%Y%m%d') between sInfo.cont_stt_dt and sInfo.cont_end_dt
  794. where iInfo.brand_id = #{sBrandId}
  795. AND iInfo.item_st_cd = 'IS00'
  796. <if test="sItemNm != null and sItemNm != ''">
  797. and (iInfo.item_nm like concat('%',#{sItemNm},'%') or iInfo.item_id like concat('%',#{sItemNm},'%'))
  798. </if>
  799. <if test="sPodrPssblDvsn != null and sPodrPssblDvsn != ''">
  800. and iInfo.podr_pssbl_dvsn = #{sPodrPssblDvsn}
  801. </if>
  802. </select>
  803. <select id="selectPopContItemBrandUnitGridList" resultType="com.oqpo.api.entity.stinfo.ItemUnitEntity">
  804. select /* selectPopContItemBrandUnitGridList */
  805. iInfo.item_id,iInfo.item_nm,iInfo.podr_pssbl_dvsn, fn_code_nm('PODR_PSSBL_DVSN',iInfo.podr_pssbl_dvsn) AS podr_pssbl_dvsn_nm
  806. ,iInfo.unit, fn_code_nm('DSTRBT_COST_UNIT', iInfo.unit) as unit_nm
  807. from item_base_info iInfo
  808. where iInfo.brand_id = #{sBrandId}
  809. AND iInfo.item_st_cd = 'IS00'
  810. <if test="sItemNm != null and sItemNm != ''">
  811. and (iInfo.item_nm like concat('%',#{sItemNm},'%') or iInfo.item_id like concat('%',#{sItemNm},'%'))
  812. </if>
  813. <if test="sPodrPssblDvsn != null and sPodrPssblDvsn != ''">
  814. and iInfo.podr_pssbl_dvsn = #{sPodrPssblDvsn}
  815. </if>
  816. <if test="contYn == 'N'.toString()">
  817. and iInfo.item_id not in ( select item_id
  818. from brand_item_unit_info iunit
  819. where iunit.brand_id = #{sBrandId}
  820. and date_format(now() , '%Y%m%d') between cont_stt_dt and cont_end_dt )
  821. </if>
  822. <choose>
  823. <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
  824. <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
  825. <if test="gridRequest.sord == 'asc'.toString()">
  826. order by iInfo.item_nm asc
  827. </if>
  828. <if test="gridRequest.sord == 'desc'.toString()">
  829. order by iInfo.item_nm desc
  830. </if>
  831. </if>
  832. </when>
  833. <otherwise>
  834. order by iInfo.item_nm asc
  835. </otherwise>
  836. </choose>
  837. <if test="gridRequest.pagingYn == true">
  838. limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
  839. </if>
  840. </select>
  841. <select id="selectPopContItemBrandUnitGridCnt" resultType="int">
  842. select /* selectPopContItemBrandUnitGridCnt */
  843. count(*)
  844. from item_base_info iInfo
  845. where iInfo.brand_id = #{sBrandId}
  846. AND iInfo.item_st_cd = 'IS00'
  847. <if test="sItemNm != null and sItemNm != ''">
  848. and (iInfo.item_nm like concat('%',#{sItemNm},'%') or iInfo.item_id like concat('%',#{sItemNm},'%'))
  849. </if>
  850. <if test="sPodrPssblDvsn != null and sPodrPssblDvsn != ''">
  851. and iInfo.podr_pssbl_dvsn = #{sPodrPssblDvsn}
  852. </if>
  853. <if test="contYn == 'N'.toString()">
  854. and iInfo.item_id not in ( select item_id
  855. from brand_item_unit_info iunit
  856. where iunit.brand_id = #{sBrandId}
  857. and date_format(now() , '%Y%m%d') between cont_stt_dt and cont_end_dt )
  858. </if>
  859. </select>
  860. </mapper>