123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.oqpo.api.mapper.rtnmng.RtnReqMapper">
- <insert id="insertRtnReqBaseInfo" >
- INSERT INTO rtn_req_base_info /* RtnReqMapper.insertRtnReqBaseInfo */
- (rtn_req_unq_no, store_id, brand_id, rtn_req_dt, rtn_req_tm
- , rtn_req_st_cd, rtn_req_mgr_id, rtn_req_mgr_nm, rtn_req_mgr_tel_no
- , whs_dvsn, col_req_dt, note, rtn_rjct_dt, rtn_rjct_nm
- , rtn_rjct_id, rtn_rjct_rsn, rtn_req_amt, rtn_req_item_qty, rtn_whs_id, rtn_location
- , sys_reg_dttm, sys_reg_id, sys_chg_dttm, sys_chg_id)
- VALUES
- (#{entity.rtnReqUnqNo}, #{entity.storeId}, #{entity.brandId}, case when #{entity.rtnReqStCd} = 'RR20' then date_format(now(),'%Y%m%d') else null end , #{entity.rtnReqTm}
- , #{entity.rtnReqStCd}, #{userId}, #{entity.rtnReqMgrNm}, #{entity.rtnReqMgrTelNo}
- , #{entity.whsDvsn}, #{entity.colReqDt}, #{entity.note}, #{entity.rtnRjctDt}, #{entity.rtnRjctNm}
- , #{entity.rtnRjctId}, #{entity.rtnRjctRsn}, #{entity.rtnReqAmt}, #{entity.rtnReqItemQty}, #{entity.rtnWhsId}, #{entity.rtnLocation}
- , NOW(), #{userId}, NOW(), #{userId})
- </insert>
- <update id="updateRtnReqBaseInfo">
- UPDATE rtn_req_base_info SET /* RtnReqMapper.updateRtnReqBaseInfo */
- rtn_req_dt = case when #{entity.rtnReqStCd} = 'RR20' then date_format(now(),'%Y%m%d') else null end,
- rtn_req_tm = #{entity.rtnReqTm},
- rtn_req_st_cd = #{entity.rtnReqStCd},
- whs_dvsn = #{entity.whsDvsn},
- col_req_dt = #{entity.colReqDt},
- note = #{entity.note},
- rtn_req_amt = #{entity.rtnReqAmt},
- rtn_req_item_qty = #{entity.rtnReqItemQty},
- rtn_whs_id = #{entity.rtnWhsId},
- rtn_location = #{entity.rtnLocation},
- sys_chg_dttm = NOW(),
- sys_chg_id = #{userId}
- WHERE rtn_req_unq_no = #{entity.rtnReqUnqNo}
- AND brand_id = #{entity.brandId}
- </update>
- <insert id="insertRtnReqDtlPtcl" >
- INSERT INTO rtn_req_dtl_ptcl /* RtnReqMapper.insertRtnReqDtlPtcl */
- (rtn_req_unq_no, rtn_req_dtl_no, item_id, item_nm, unit
- , rtn_qty, rtn_amt, rtn_dvsn, rtn_rsn
- , spply_id, unit_amt, store_unit_unq_no, brand_unit_unq_no, rtn_rsn_dvsn, unit_gubun
- , sys_reg_dttm, sys_reg_id, sys_chg_dttm, sys_chg_id)
- VALUES
- <foreach collection="gridInsertData" item="item" separator=",">
- (#{item.rtnReqUnqNo}, #{item.rtnReqDtlNo}, #{item.itemId}, #{item.itemNm}, #{item.unit}
- , #{item.rtnQty}, #{item.rtnAmt}, #{item.rtnDvsn}, #{item.rtnRsn}
- , #{item.spplyId}, #{item.unitAmt}, #{item.storeUnitUnqNo}, #{item.brandUnitUnqNo}, #{item.rtnRsnDvsn}, #{unitGubun}
- , NOW(), #{userId}, NOW(), #{userId})
- </foreach>
- </insert>
- <update id="updateRtnReqDtlPtcl">
- <foreach collection="gridUpdateData" item="item" separator=";">
- UPDATE rtn_req_dtl_ptcl SET /* RtnReqMapper.updateRtnReqDtlPtcl */
- rtn_qty = #{item.rtnQty},
- rtn_amt = #{item.rtnAmt},
- rtn_dvsn = #{item.rtnDvsn},
- rtn_rsn = #{item.rtnRsn},
- rtn_rsn_dvsn = #{item.rtnRsnDvsn},
- sys_chg_dttm = NOW(),
- sys_chg_id = #{userId}
- WHERE rtn_req_unq_no = #{item.rtnReqUnqNo}
- AND rtn_req_dtl_no = #{item.rtnReqDtlNo}
- </foreach>
- </update>
- <delete id="deleteRtnReqDtlPtcl">
- DELETE FROM rtn_req_dtl_ptcl /* RtnReqMapper.deleteRtnReqDtlPtcl */
- WHERE rtn_req_unq_no = #{rtnReqUnqNo}
- AND rtn_req_dtl_no in
- <foreach collection="gridDeleteData" item="item" separator="," open="(" close=")">
- #{item.rtnReqDtlNo}
- </foreach>
- </delete>
- <select id="selectMaxRtnReqDtlNo" resultType="int">
- SELECT nvl(Max(convert(rtn_req_dtl_no,int)),0)
- FROM rtn_req_dtl_ptcl
- WHERE rtn_req_unq_no = #{rtnReqUnqNo}
- </select>
- <select id="selectSumRtnAmt" resultType="com.oqpo.api.entity.rtnmng.RtnReqBaseInfoEntity">
- select count(*) as rtn_req_item_qty, nvl(sum(rtn_amt),0) as rtn_req_amt
- from rtn_req_dtl_ptcl
- where rtn_req_unq_no = #{rtnReqUnqNo}
- </select>
- <select id="selectRtnReqGridList" resultType="com.oqpo.api.entity.rtnmng.RtnReqBaseInfoEntity">
- select base.brand_id, fn_brand_nm(base.brand_id) as brand_nm
- ,base.store_id , fn_store_nm(base.brand_id, base.store_id) as store_nm
- , base.rtn_req_unq_no
- , base.rtn_req_st_cd, fn_code_nm(upper('rtn_req_st_cd'), base.rtn_req_st_cd) as rtn_req_st_nm
- , base.rtn_whs_id, base.rtn_location, fn_whs_nm(base.brand_id, base.rtn_whs_id) as rtn_whs_nm
- , fn_whs_location_nm(base.brand_id, base.rtn_whs_id, base.rtn_location) as rtn_location_nm
- , date_format(base.rtn_req_dt, '%Y.%m.%d') as rtn_req_dt, base.rtn_req_item_qty, base.rtn_req_amt
- , date_format(base.col_req_dt, '%Y.%m.%d') as col_req_dt, base.rtn_req_mgr_nm, base.rtn_req_mgr_id
- , date_format(base.rtn_rjct_dt, '%Y.%m.%d') as rtn_rjct_dt, base.rtn_rjct_nm
- from rtn_req_base_info base
- where 1 = 1
- and base.brand_id = #{sBrandId}
- and base.col_req_dt between #{fromDt} and #{toDt}
- <if test="sStoreId != null and sStoreId != ''">
- and base.store_id = #{sStoreId}
- </if>
- <if test="sWhsId != null and sWhsId != ''">
- and base.rtn_whs_id = #{sWhsId}
- </if>
- <if test="sRtnReqStCd != null and sRtnReqStCd != ''">
- and base.rtn_req_st_cd = #{sRtnReqStCd}
- </if>
- <if test="sItemNm != null and sItemNm != ''">
- and base.rtn_req_unq_no in (select ptcl.rtn_req_unq_no
- from rtn_req_base_info sbase,
- rtn_req_dtl_ptcl ptcl
- where sbase.rtn_req_unq_no = ptcl.rtn_req_unq_no
- and sbase.brand_id = #{sBrandId}
- and sbase.col_req_dt between #{fromDt} and #{toDt}
- <if test="sStoreId != null and sStoreId != ''">
- and sbase.store_id = #{sStoreId}
- </if>
- <if test="sWhsId != null and sWhsId != ''">
- and sbase.rtn_whs_id = #{sWhsId}
- </if>
- <if test="sRtnReqStCd != null and sRtnReqStCd != ''">
- and sbase.rtn_req_st_cd = #{sRtnReqStCd}
- </if>
- and (ptcl.item_id like concat('%', #{sItemNm}, '%') or ptcl.item_nm like concat('%', #{sItemNm}, '%')) )
- </if>
- <choose>
- <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
- <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
- <if test="gridRequest.sord == 'asc'.toString()">
- order by base.rtn_req_unq_no asc
- </if>
- <if test="gridRequest.sord == 'desc'.toString()">
- order by base.rtn_req_unq_no desc
- </if>
- </if>
- </when>
- <otherwise>
- order by base.rtn_req_unq_no desc
- </otherwise>
- </choose>
- <if test="gridRequest.pagingYn == true">
- limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
- </if>
- </select>
- <select id="selectRtnReqGridCnt" resultType="int">
- select count(*)
- from rtn_req_base_info base
- where 1 = 1
- and base.brand_id = #{sBrandId}
- and base.col_req_dt between #{fromDt} and #{toDt}
- <if test="sStoreId != null and sStoreId != ''">
- and base.store_id = #{sStoreId}
- </if>
- <if test="sWhsId != null and sWhsId != ''">
- and base.rtn_whs_id = #{sWhsId}
- </if>
- <if test="sRtnReqStCd != null and sRtnReqStCd != ''">
- and base.rtn_req_st_cd = #{sRtnReqStCd}
- </if>
- <if test="sItemNm != null and sItemNm != ''">
- and base.rtn_req_unq_no in (select ptcl.rtn_req_unq_no
- from rtn_req_base_info sbase,
- rtn_req_dtl_ptcl ptcl
- where sbase.rtn_req_unq_no = ptcl.rtn_req_unq_no
- and sbase.brand_id = #{sBrandId}
- and sbase.col_req_dt between #{fromDt} and #{toDt}
- <if test="sStoreId != null and sStoreId != ''">
- and sbase.store_id = #{sStoreId}
- </if>
- <if test="sWhsId != null and sWhsId != ''">
- and sbase.rtn_whs_id = #{sWhsId}
- </if>
- <if test="sRtnReqStCd != null and sRtnReqStCd != ''">
- and sbase.rtn_req_st_cd = #{sRtnReqStCd}
- </if>
- and (ptcl.item_id like concat('%', #{sItemNm}, '%') or ptcl.item_nm like concat('%', #{sItemNm}, '%')) )
- </if>
- </select>
- <select id="selectRtnReqInfo" resultType="com.oqpo.api.entity.rtnmng.RtnReqBaseInfoEntity">
- SELECT rtn_req_unq_no, brand_id, fn_brand_nm(brand_id) as brand_nm
- , store_id, fn_store_nm(brand_id, store_id) as store_nm
- , date_format(rtn_req_dt,'%Y.%m.%d') as rtn_req_dt, rtn_req_st_cd, fn_code_nm('RTN_REQ_ST_Cd',rtn_req_st_cd) as rtn_req_st_nm
- , rtn_req_mgr_id, rtn_req_mgr_nm, whs_dvsn, fn_code_nm('WHS_DVSN',whs_dvsn) as whs_dvsn_nm
- , date_format(col_req_dt,'%Y.%m.%d') as col_req_dt, note, date_format(rtn_rjct_dt,'%Y.%m.%d') as rtn_rjct_dt, rtn_rjct_nm, rtn_rjct_id
- , rtn_rjct_rsn, rtn_req_amt, rtn_req_item_qty
- , rtn_whs_id, fn_whs_nm(brand_id, rtn_whs_id) as rtn_whs_nm
- , rtn_location, fn_whs_location_nm(brand_id, rtn_whs_id, rtn_location) as rtn_location_nm
- , date_format(sys_reg_dttm,'%Y.%m.%d') AS sys_reg_dttm, sys_reg_id, date_format(sys_chg_dttm,'%Y.%m.%d') AS sys_chg_dttm, sys_chg_id
- FROM rtn_req_base_info
- WHERE 1=1
- AND brand_id = #{brandId}
- <if test="storeId != null and storeId != ''">
- and store_id = #{storeId}
- </if>
- AND rtn_req_unq_no = #{rtnReqUnqNo}
- </select>
- <select id="selectRtnReqDtlList" resultType="com.oqpo.api.entity.rtnmng.RtnReqDtlPtclEntity">
- SELECT rtn_req_unq_no, rtn_req_dtl_no, item_id, item_nm, unit
- , rtn_qty, rtn_amt, rtn_dvsn, fn_code_nm('RTN_DVSN',rtn_dvsn) as rtn_dvsn_nm
- , rtn_rsn, spply_id
- , unit_amt, store_unit_unq_no, brand_unit_unq_no, rtn_rsn_dvsn, fn_code_nm('RTN_RSN_DVSN',rtn_rsn_dvsn) as rtn_rsn_dvsn_nm
- , unit_gubun, fn_code_nm('UNIT_GUBUN',unit_gubun) as unit_gubun_nm
- FROM rtn_req_dtl_ptcl
- WHERE rtn_req_unq_no = #{rtnReqUnqNo}
- </select>
- <!--
- <select id="selectPchReqGridCnt" resultType="int">
- select count(*) as cnt
- from pch_req_base_info
- where brand_id = #{sBrandId}
- <if test="sStoreId != null and sStoreId != ''">
- and store_id = #{sStoreId}
- </if>
- and date_format(sys_reg_dttm,'%Y%m%d') between #{fromDt} and #{toDt}
- <if test="sWhsId != null and sWhsId != ''">
- and whs_id = #{sWhsId}
- </if>
- <if test="sPchReqStCd != null and sPchReqStCd != ''">
- and pch_req_st_cd = #{sPchReqStCd}
- </if>
- <if test="sItemNm != null and sItemNm != ''">
- and pch_req_unq_no in ( select pch_req_unq_no from pch_req_dtl_ptcl
- where date_format(sys_reg_dttm,'%Y%m%d') between #{fromDt} and #{toDt})
- and item_id like concat('%',#{sItemNm},'%') or item_nm like concat('%',#{sItemNm},'%')
- </if>
- </select>
- <select id="selectPchReqInfo" resultType="com.oqpo.api.entity.pomng.PchReqBaseInfoEntity">
- SELECT pch_req_unq_no, brand_id, fn_brand_nm(brand_id) as brand_nm, store_id, pch_req_nm, pch_req_dept
- , pch_req_mgr_nm, DATE_FORMAT(pch_req_dt,'%Y.%m.%d') as pch_req_dt, pch_req_st_cd, fn_code_nm('PCH_REQ_ST_CD', pch_req_st_cd ) AS pch_req_st_nm, pch_req_dvsn
- , note, pch_req_item_qty, pch_req_total_amt, DATE_FORMAT(pch_req_rjct_dt,'%Y.%m.%d') as pch_req_rjct_dt, pch_req_rjct_nm
- , pch_req_rjct_rsn, pch_req_mgr_id, pch_req_rjct_id
- ,whs_id, fn_whs_nm(brand_id, whs_id) as whs_nm
- ,location, fn_whs_location_nm(brand_id, whs_id, location) as location_nm
- , DATE_FORMAT(dlv_req_dt ,'%Y.%m.%d') as dlv_req_dt
- , DATE_FORMAT(sys_reg_dttm,'%Y.%m.%d %H:%i:%s') AS sys_reg_dttm, sys_reg_id, DATE_FORMAT(sys_chg_dttm,'%Y.%m.%d %H:%i:%s') AS sys_chg_dttm, sys_chg_id
- , nvl(pch_appr_amt,0) as pch_appr_amt, case when pch_req_total_amt = pch_appr_amt then 'Y' else 'N' end pch_appr_yn
- FROM pch_req_base_info
- WHERE brand_id = #{brandId}
- and pch_req_unq_no = #{pchReqUnqNo}
- </select>
- <select id="selectPchReqDtlPtcl" resultType="com.oqpo.api.entity.pomng.PchReqDtlPtclEntity">
- SELECT ptcl.pch_req_unq_no, ptcl.pch_req_dtl_no, ptcl.item_id, ptcl.item_nm, ptcl.unit, fn_code_nm('DSTRBT_COST_UNIT',ptcl.unit) AS unit_nm
- , ptcl.pch_req_qty, ptcl.pch_req_amt, ptcl.unit_amt, ptcl.brand_unit_unq_no, ptcl.store_unit_unq_no, ptcl.unit_gubun
- , odr.podr_dtl_st_cd, fn_code_nm(upper('podr_dtl_st_cd'), odr.podr_dtl_st_cd) as podr_dtl_st_nm
- FROM pch_req_dtl_ptcl ptcl
- left outer join pch_odr_dtl_ptcl odr on odr.pch_req_unq_no = ptcl.pch_req_unq_no and odr.pch_req_dtl_no = ptcl.pch_req_dtl_no
- WHERE ptcl.pch_req_unq_no = #{pchReqUnqNo}
- </select>
- <insert id="insertPchReqBaseInfo" >
- INSERT INTO /* PchReq.insertPchReqBaseInfo */ pch_req_base_info
- (pch_req_unq_no, brand_id, store_id, pch_req_nm, pch_req_dept
- , pch_req_mgr_nm, pch_req_dt, pch_req_tm, pch_req_st_cd, pch_req_dvsn
- , note, pch_req_item_qty, pch_req_total_amt, pch_req_rjct_dt, pch_req_rjct_nm
- , pch_req_rjct_rsn, pch_req_mgr_id, pch_req_rjct_id
- , whs_id, location,dlv_req_dt
- , sys_reg_dttm, sys_reg_id, sys_chg_dttm, sys_chg_id)
- VALUES
- (#{entity.pchReqUnqNo}, #{entity.brandId}, #{entity.storeId}, #{entity.pchReqNm}, #{entity.pchReqDept}
- , #{entity.pchReqMgrNm}, case when #{entity.pchReqStCd} = 'PR20' then date_format(now(),'%Y%m%d') else null end, null, #{entity.pchReqStCd}, #{entity.pchReqDvsn}
- , #{entity.note}, #{entity.pchReqItemQty}, #{entity.pchReqTotalAmt}, null, null
- , null, #{userId}, null
- , #{entity.whsId}, #{entity.location}, #{entity.dlvReqDt}
- , NOW(), #{userId}, NOW(), #{userId})
- </insert>
- <update id="updateOrdPchReqBaseInfo">
- UPDATE /* PchReq.updateOrdPchReqBaseInfo */
- pch_req_base_info SET
- pch_req_dt = case when #{entity.pchReqStCd} = 'PR20' then date_format(now(),'%Y%m%d') else null end ,
- pch_req_st_cd = #{entity.pchReqStCd},
- note = #{entity.note},
- pch_req_item_qty = #{entity.pchReqItemQty},
- pch_req_total_amt = #{entity.pchReqTotalAmt},
- whs_id = #{entity.whsId},
- location = #{entity.location},
- dlv_req_dt = #{entity.dlvReqDt},
- sys_chg_dttm = NOW(),
- sys_chg_id = #{userId}
- WHERE brand_id = #{entity.brandId}
- and pch_req_unq_no = #{entity.pchReqUnqNo}
- </update>
- <update id="updateRejPchReqBaseInfo">
- UPDATE /* PchReq.updateRejPchReqBaseInfo */
- pch_req_base_info SET
- pch_req_rjct_nm = #{pchReqRjctNm},
- pch_req_rjct_dt = date_format(now(),'%Y%m%d'),
- pch_req_rjct_rsn = #{pchReqRjctRsn},
- pch_req_rjct_id = #{userId},
- sys_chg_dttm = NOW(),
- sys_chg_id = #{userId}
- WHERE pch_req_unq_no = #{pchReqUnqNo}
- </update>
- <insert id="insertPchReqDtlPtcl" >
- INSERT INTO /* PchReq.insertPchReqDtlPtcl */ pch_req_dtl_ptcl
- (pch_req_unq_no, pch_req_dtl_no, item_nm, unit, pch_req_qty
- , pch_req_amt, unit_amt, unit_gubun, brand_unit_unq_no, store_unit_unq_no
- , item_id, sys_reg_dttm, sys_reg_id, sys_chg_dttm, sys_chg_id)
- VALUES
- <foreach collection="gridInsertData" item="item" separator=",">
- (#{item.pchReqUnqNo}, #{item.pchReqDtlNo}, #{item.itemNm}, #{item.unit}, #{item.pchReqQty}
- , #{item.pchReqAmt}, #{item.unitAmt}, #{item.unitGubun} , #{item.brandUnitUnqNo} , #{item.storeUnitUnqNo}
- , #{item.itemId} , NOW(), #{userId}, NOW(), #{userId})
- </foreach>
- </insert>
- <update id="updatePchReqDtlPtcl">
- <foreach collection="gridUpdateData" item="item" separator=";">
- UPDATE /* PchReq.updatePchReqDtlPtcl */
- pch_req_dtl_ptcl SET
- unit = #{item.unit},
- pch_req_qty = #{item.pchReqQty},
- pch_req_amt = #{item.pchReqAmt},
- unit_amt = #{item.unitAmt},
- sys_chg_dttm = NOW(),
- sys_chg_id = #{userId}
- WHERE pch_req_unq_no = #{pchReqUnqNo}
- AND pch_req_dtl_no = #{item.pchReqDtlNo}
- </foreach>
- </update>
- <delete id="deletePchReqDtlPtcl">
- DELETE /* PchReq.deletePchReqDtlPtcl */
- FROM pch_req_dtl_ptcl
- WHERE pch_req_unq_no = #{pchReqUnqNo}
- and pch_req_dtl_no in
- <foreach collection="gridDeleteData" item="item" separator="," open="(" close=")">
- #{item.pchReqDtlNo}
- </foreach>
- </delete>
- <select id="selectMaxPchReqDtlNo" resultType="int">
- SELECT nvl(Max(convert(pch_req_dtl_no,int)),0)
- FROM pch_req_dtl_ptcl
- WHERE pch_req_unq_no = #{pchReqUnqNo}
- </select>
- <select id="selectSumReqAmt" resultType="com.oqpo.api.entity.pomng.PchReqBaseInfoEntity">
- select count(*) as pch_req_item_qty, nvl(sum(pch_req_amt),0) as pch_req_total_amt
- from pch_req_dtl_ptcl
- where pch_req_unq_no = #{pchReqUnqNo}
- </select>
- <select id="selectPchReqPoTargetGridList" resultType="com.oqpo.api.entity.pomng.PchReqBaseInfoEntity">
- select base.pch_req_unq_no, ptcl.pch_req_dtl_no as 'pchReqDtlInfo.pch_req_dtl_no', base.brand_id, fn_brand_nm(base.brand_id) as brand_nm
- , base.store_id, store.store_nm
- , bitem.spply_nm as 'itemUnitInfo.spply_nm'
- , fn_whs_nm(base.brand_id, base.whs_id) as whs_nm, fn_whs_location_nm(base.brand_id, base.whs_id, base.location) as location_nm
- , ptcl.item_id as 'pchReqDtlInfo.item_id', ptcl.item_nm as 'pchReqDtlInfo.item_nm', ptcl.unit_amt as 'pchReqDtlInfo.unit_amt'
- , bitem.unit_amt as 'itemUnitInfo.unit_amt' , ptcl.pch_req_qty as 'pchReqDtlInfo.pch_req_qty', date_format(base.dlv_req_dt, '%Y.%m.%d') as dlv_req_dt
- , ptcl.pch_req_amt as 'pchReqDtlInfo.pch_req_amt', bitem.unit_amt * ptcl.pch_req_qty as 'pchReqDtlInfo.pch_ord_amt'
- , bitem.lead_time as 'itemUnitInfo.lead_time', bitem.spply_id as 'itemUnitInfo.spply_id', base.whs_id, base.location
- from pch_req_base_info base
- join pch_req_dtl_ptcl ptcl on base.pch_req_unq_no = ptcl.pch_req_unq_no
- join brand_item_unit_info bitem on ptcl.brand_unit_unq_no = bitem.brand_unit_unq_no
- left outer join store_base_info store on base.brand_id = store.brand_id and base.store_id = store.store_id
- where 1 = 1
- and base.brand_id = #{sBrandId}
- and base.pch_req_st_cd = 'PR20'
- and base.dlv_req_dt between #{fromDt} and #{toDt}
- <if test="sSpplyId != null and sSpplyId != ''">
- and bitem.spply_id = #{sSpplyId}
- </if>
- <if test="sWhsId != null and sWhsId != ''">
- and base.whs_id = #{sWhsId}
- </if>
- <if test="sItemNm != null and sItemNm != ''">
- and (ptcl.item_id like concat('%', #{sItemNm}, '%') or ptcl.item_nm like concat('%', #{sItemNm}, '%'))
- </if>
- <choose>
- <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
- <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
- <if test="gridRequest.sord == 'asc'.toString()">
- order by base.dlv_req_dt asc, base.whs_id, base.location, bitem.spply_id, base.pch_req_unq_no, ptcl.pch_req_dtl_no
- </if>
- <if test="gridRequest.sord == 'desc'.toString()">
- order by base.dlv_req_dt desc, base.whs_id, base.location, bitem.spply_id, base.pch_req_unq_no, ptcl.pch_req_dtl_no
- </if>
- </if>
- </when>
- <otherwise>
- order by base.dlv_req_dt asc, base.whs_id, base.location, bitem.spply_id, base.pch_req_unq_no, ptcl.pch_req_dtl_no
- </otherwise>
- </choose>
- <if test="gridRequest.pagingYn == true">
- limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
- </if>
- </select>
- <select id="selectPchReqPoTargetGridCnt" resultType="int">
- select count(*)
- from pch_req_base_info base
- join pch_req_dtl_ptcl ptcl on base.pch_req_unq_no = ptcl.pch_req_unq_no
- join brand_item_unit_info bitem on ptcl.brand_unit_unq_no = bitem.brand_unit_unq_no
- left outer join store_base_info store on base.brand_id = store.brand_id and base.store_id = store.store_id
- where 1 = 1
- and base.brand_id = #{sBrandId}
- and base.pch_req_st_cd = 'PR20'
- and base.dlv_req_dt between #{fromDt} and #{toDt}
- <if test="sSpplyId != null and sSpplyId != ''">
- and bitem.spply_id = #{sSpplyId}
- </if>
- <if test="sWhsId != null and sWhsId != ''">
- and base.whs_id = #{sWhsId}
- </if>
- <if test="sItemNm != null and sItemNm != ''">
- and (ptcl.item_id like concat('%', #{sItemNm}, '%') or ptcl.item_nm like concat('%', #{sItemNm}, '%'))
- </if>
- </select>
- <select id="selectPchRejectPrTargetList" resultType="com.oqpo.api.entity.pomng.PchReqDtlPtclEntity">
- select /* PchReq.selectPchRejectPrTargetList */
- base.pch_req_unq_no, ptcl.pch_req_dtl_no
- , ptcl.item_id, ptcl.item_nm
- , ptcl.pch_req_qty, ptcl.pch_req_amt
- from pch_req_base_info base
- , pch_req_dtl_ptcl ptcl
- where 1 = 1
- and base.pch_req_unq_no = ptcl.pch_req_unq_no
- and base.pch_req_st_cd = 'PR20'
- and base.pch_req_unq_no = #{pchReqUnqNo}
- </select>
- <update id="updatePchReqStCd">
- <foreach collection="gridUpdateData" item="item" separator=";">
- UPDATE /* PchReq.updatePchReqDtlPtcl */
- pch_req_base_info SET
- pch_req_st_cd = #{item.pchReqStCd},
- sys_chg_dttm = NOW(),
- sys_chg_id = #{userId}
- WHERE pch_req_unq_no = #{item.pchReqUnqNo}
- </foreach>
- </update>
- -->
- </mapper>
|