StockCdd.xml 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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.stockmng.StockCddMapper">
  4. <select id="selectStockCddGridList" resultType="com.oqpo.api.entity.stockmng.StckCddMgntInfoEntity">
  5. /* StockCddMapper.selectStockCddGridList */
  6. SELECT A.brand_id, FN_BRAND_NM(A.brand_id) AS brand_nm,
  7. C.store_id, FN_STORE_NM(A.brand_id, C.store_id) AS store_nm,
  8. A.whs_id, C.whs_nm, A.location, D.location_nm, A.item_id, E.item_nm, A.unit, A.stck_qty, A.prp_stck_qty,
  9. A.sft_stck_rt, A.cur_stck_rt
  10. FROM stck_mgnt_base_info A
  11. INNER JOIN whs_mgnt_base_info C ON A.brand_id = C.brand_id AND A.whs_id = C.whs_id
  12. INNER JOIN whs_mgnt_base_loc D ON A.brand_id = D.brand_id AND A.whs_id = D.whs_id AND A.location = D.location
  13. INNER JOIN item_base_info E ON A.item_id = E.item_id
  14. <if test="sItemClass1 != null and sItemClass1 != ''">
  15. INNER JOIN item_class_ptcl B ON A.item_id = B.item_id
  16. AND B.item_class1 = #{sItemClass1}
  17. <if test="sItemClass2 != null and sItemClass2 != ''">
  18. AND B.item_class2 = #{sItemClass2}
  19. <if test="sItemClass3 != null and sItemClass3 != ''">
  20. AND B.item_class3 = #{sItemClass3}
  21. <if test="sItemClass4 != null and sItemClass4 != ''">
  22. AND B.item_class4 = #{sItemClass4}
  23. </if>
  24. </if>
  25. </if>
  26. </if>
  27. WHERE A.brand_id = #{sBrandId}
  28. <if test="sStoreId != null and sStoreId != ''">
  29. AND C.store_id = #{sStoreId}
  30. </if>
  31. <if test="sWhsId != null and sWhsId != ''">
  32. AND A.whs_id = #{sWhsId}
  33. </if>
  34. <if test="sLocation != null and sLocation != ''">
  35. AND A.location = #{sLocation}
  36. </if>
  37. <if test="sItemId != null and sItemId != ''">
  38. AND A.item_id = #{sItemId}
  39. </if>
  40. <if test="sItemNm != null and sItemNm != ''">
  41. AND A.item_nm LIKE CONCAT('%',#{sItemNm},'%')
  42. </if>
  43. <choose>
  44. <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
  45. <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
  46. <if test="gridRequest.sord == 'asc'.toString()">
  47. ORDER BY A.item_id ASC
  48. </if>
  49. <if test="gridRequest.sord == 'desc'.toString()">
  50. ORDER BY A.item_id DESC
  51. </if>
  52. </if>
  53. </when>
  54. <otherwise>
  55. ORDER BY A.item_id ASC
  56. </otherwise>
  57. </choose>
  58. <if test="gridRequest.pagingYn == true">
  59. limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
  60. </if>
  61. </select>
  62. <select id="selectStockCddGridCnt" resultType="int">
  63. /* StockCddMapper.selectStockCddGridCnt */
  64. SELECT COUNT(*)
  65. FROM stck_mgnt_base_info A
  66. INNER JOIN whs_mgnt_base_info C ON A.brand_id = C.brand_id AND A.whs_id = C.whs_id
  67. INNER JOIN whs_mgnt_base_loc D ON A.brand_id = D.brand_id AND A.whs_id = D.whs_id AND A.location = D.location
  68. INNER JOIN item_base_info E ON A.item_id = E.item_id
  69. <if test="sItemClass1 != null and sItemClass1 != ''">
  70. INNER JOIN item_class_ptcl B ON A.item_id = B.item_id
  71. AND B.item_class1 = #{sItemClass1}
  72. <if test="sItemClass2 != null and sItemClass2 != ''">
  73. AND B.item_class2 = #{sItemClass2}
  74. <if test="sItemClass3 != null and sItemClass3 != ''">
  75. AND B.item_class3 = #{sItemClass3}
  76. <if test="sItemClass4 != null and sItemClass4 != ''">
  77. AND B.item_class4 = #{sItemClass4}
  78. </if>
  79. </if>
  80. </if>
  81. </if>
  82. WHERE A.brand_id = #{sBrandId}
  83. <if test="sStoreId != null and sStoreId != ''">
  84. AND C.store_id = #{sStoreId}
  85. </if>
  86. <if test="sWhsId != null and sWhsId != ''">
  87. AND A.whs_id = #{sWhsId}
  88. </if>
  89. <if test="sLocation != null and sLocation != ''">
  90. AND A.location = #{sLocation}
  91. </if>
  92. <if test="sItemId != null and sItemId != ''">
  93. AND A.item_id = #{sItemId}
  94. </if>
  95. <if test="sItemNm != null and sItemNm != ''">
  96. AND A.item_nm LIKE CONCAT('%',#{sItemNm},'%')
  97. </if>
  98. </select>
  99. <insert id="insertStckCddMgntInfo" >
  100. /* StockCddMapper.insertStckCddMgntInfo */
  101. INSERT INTO stck_cdd_mgnt_info
  102. (cdd_id, cdd_dt, cdd_tm, cdd_dvsn, cdd_mgr_nm, brand_id, store_id, whs_id, location, sys_reg_dttm,
  103. sys_reg_id, sys_chg_dttm, sys_chg_id)
  104. VALUES
  105. (#{entity.cddId}, #{entity.cddDt}, #{entity.cddTm}, #{entity.cddDvsn}, #{entity.cddMgrNm},
  106. #{entity.brandId}, #{entity.storeId}, #{entity.whsId}, #{entity.location},
  107. NOW(), #{userId}, NOW(), #{userId})
  108. </insert>
  109. <insert id="insertStckCddMgntDtl" >
  110. /* StockCddMapper.insertStckCddMgntDtl */
  111. INSERT INTO stck_cdd_mgnt_dtl
  112. (cdd_id, cdd_seq, item_id, unit, com_exst_qty, cdd_qty, chg_qty, sys_reg_dttm,
  113. sys_reg_id, sys_chg_dttm, sys_chg_id)
  114. VALUES
  115. (#{entity.cddId}, #{entity.cddSeq}, #{entity.itemId}, #{entity.unit}, #{entity.comExstQty}, #{entity.cddQty}, #{entity.chgQty},
  116. NOW(), #{userId}, NOW(), #{userId})
  117. </insert>
  118. <select id="selectStockCddMgntInfo" resultType="com.oqpo.api.entity.stockmng.StckCddMgntInfoEntity">
  119. /* StockCddMapper.selectStockCddMgntInfo */
  120. SELECT A.cdd_id, A.cdd_dt, A.cdd_tm, A.cdd_dvsn, A.cdd_mgr_nm,
  121. A.brand_id, FN_BRAND_NM(A.brand_id) AS brand_nm,
  122. A.store_id, FN_STORE_NM(A.brand_id, A.store_id) AS store_nm,
  123. A.whs_id, B.whs_nm, A.location, C.location_nm,
  124. DATE_FORMAT(A.sys_reg_dttm,'%Y.%m.%d %H:%i:%s') AS sys_reg_dttm, A.sys_reg_id,
  125. DATE_FORMAT(A.sys_chg_dttm,'%Y.%m.%d %H:%i:%s') AS sys_chg_dttm, A.sys_chg_id
  126. FROM stck_cdd_mgnt_info A
  127. INNER JOIN whs_mgnt_base_info B ON A.brand_id = B.brand_id AND A.whs_id = B.whs_id
  128. INNER JOIN whs_mgnt_base_loc C ON A.brand_id = C.brand_id AND A.whs_id = C.whs_id AND A.location = C.location
  129. WHERE A.cdd_id = #{cddId}
  130. </select>
  131. <select id="selectStockCddDtlGridList" resultType="com.oqpo.api.entity.stockmng.StckCddMgntDtlEntity">
  132. /* StockCddMapper.selectStockCddDtlGridList */
  133. SELECT A.cdd_id, A.cdd_seq, A.item_id, E.item_nm, A.unit, A.com_exst_qty, A.cdd_qty, A.chg_qty,
  134. B.brand_id, FN_BRAND_NM(B.brand_id) AS brand_nm,
  135. B.store_id, FN_STORE_NM(B.brand_id, B.store_id) AS store_nm,
  136. B.whs_id, C.whs_nm, B.location, D.location_nm
  137. FROM stck_cdd_mgnt_dtl A
  138. INNER JOIN stck_cdd_mgnt_info B ON A.cdd_id = B.cdd_id
  139. INNER JOIN whs_mgnt_base_info C ON B.brand_id = C.brand_id AND B.whs_id = C.whs_id
  140. INNER JOIN whs_mgnt_base_loc D ON B.brand_id = D.brand_id AND B.whs_id = D.whs_id AND B.location = D.location
  141. INNER JOIN item_base_info E ON A.item_id = E.item_id
  142. WHERE A.cdd_id = #{cddId}
  143. <choose>
  144. <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
  145. <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
  146. <if test="gridRequest.sord == 'asc'.toString()">
  147. ORDER BY A.cdd_seq ASC
  148. </if>
  149. <if test="gridRequest.sord == 'desc'.toString()">
  150. ORDER BY A.cdd_seq DESC
  151. </if>
  152. </if>
  153. </when>
  154. <otherwise>
  155. ORDER BY A.cdd_seq ASC
  156. </otherwise>
  157. </choose>
  158. <if test="gridRequest.pagingYn == true">
  159. limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
  160. </if>
  161. </select>
  162. <select id="selectStockCddDtlGridCnt" resultType="int">
  163. /* StockCddMapper.selectStockCddDtlGridCnt */
  164. SELECT COUNT(*)
  165. FROM stck_cdd_mgnt_dtl A
  166. INNER JOIN stck_cdd_mgnt_info B ON A.cdd_id = B.cdd_id
  167. INNER JOIN whs_mgnt_base_info C ON B.brand_id = C.brand_id AND B.whs_id = C.whs_id
  168. INNER JOIN whs_mgnt_base_loc D ON B.brand_id = D.brand_id AND B.whs_id = D.whs_id AND B.location = D.location
  169. INNER JOIN item_base_info E ON A.item_id = E.item_id
  170. WHERE A.cdd_id = #{cddId}
  171. </select>
  172. </mapper>