WhsMng.xml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  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.WhsMngMapper">
  4. <select id="selectWhsMngGridList" resultType="com.oqpo.api.entity.stockmng.WhsMgntBaseInfoEntity">
  5. /* WhsMngMapper.selectWhsMngGridList */
  6. SELECT A.brand_id, FN_BRAND_NM(A.brand_id) AS brand_nm,
  7. A.whs_id, A.whs_nm, A.whs_dvsn, FN_CODE_NM('WHS_DVSN', A.whs_dvsn) AS whs_dvsn_nm,
  8. A.mgr_nm, FN_GET_TELNO(A.mgr_tel_no) AS mgr_tel_no, A.whs_st_cd, FN_CODE_NM('WHS_ST_CD', A.whs_st_cd) AS whs_st_nm,
  9. A.store_id, FN_STORE_NM(A.brand_id, A.store_id) AS store_nm
  10. FROM whs_mgnt_base_info A
  11. WHERE A.brand_id = #{sBrandId}
  12. <if test="sStoreId != null and sStoreId != ''">
  13. AND A.store_id = #{sStoreId}
  14. </if>
  15. <if test="sWhsDvsn != null and sWhsDvsn != ''">
  16. AND A.whs_dvsn = #{sWhsDvsn}
  17. </if>
  18. <if test="sWhsStCd != null and sWhsStCd != ''">
  19. AND A.whs_st_cd = #{sWhsStCd}
  20. </if>
  21. <if test="sWhsNm != null and sWhsNm != ''">
  22. AND A.whs_nm LIKE CONCAT('%',#{sWhsNm},'%')
  23. </if>
  24. <choose>
  25. <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
  26. <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
  27. <if test="gridRequest.sord == 'asc'.toString()">
  28. ORDER BY A.whs_id ASC
  29. </if>
  30. <if test="gridRequest.sord == 'desc'.toString()">
  31. ORDER BY A.whs_id DESC
  32. </if>
  33. </if>
  34. </when>
  35. <otherwise>
  36. ORDER BY A.whs_id ASC
  37. </otherwise>
  38. </choose>
  39. <if test="gridRequest.pagingYn == true">
  40. limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
  41. </if>
  42. </select>
  43. <select id="selectWhsMngGridCnt" resultType="int">
  44. /* WhsMngMapper.selectWhsMngGridCnt */
  45. SELECT COUNT(*)
  46. FROM whs_mgnt_base_info A
  47. WHERE A.brand_id = #{sBrandId}
  48. <if test="sStoreId != null and sStoreId != ''">
  49. AND A.store_id = #{sStoreId}
  50. </if>
  51. <if test="sWhsDvsn != null and sWhsDvsn != ''">
  52. AND A.whs_dvsn = #{sWhsDvsn}
  53. </if>
  54. <if test="sWhsStCd != null and sWhsStCd != ''">
  55. AND A.whs_st_cd = #{sWhsStCd}
  56. </if>
  57. <if test="sWhsNm != null and sWhsNm != ''">
  58. AND A.whs_nm LIKE CONCAT('%',#{sWhsNm},'%')
  59. </if>
  60. </select>
  61. <select id="selectWhsMgntBaseInfo" resultType="com.oqpo.api.entity.stockmng.WhsMgntBaseInfoEntity">
  62. /* WhsMngMapper.selectWhsMgntBaseInfo */
  63. SELECT A.brand_id, FN_BRAND_NM(A.brand_id) AS brand_nm,
  64. A.whs_id, A.whs_nm, A.whs_dvsn, FN_CODE_NM('WHS_DVSN', A.whs_dvsn) AS whs_dvsn_nm,
  65. A.mgr_nm, FN_GET_TELNO(A.mgr_tel_no) AS mgr_tel_no, A.zip_no,
  66. A.addr1, A.addr2, A.whs_st_cd, FN_CODE_NM('WHS_ST_CD', A.whs_st_cd) AS whs_st_nm,
  67. A.store_id, FN_STORE_NM(A.brand_id, A.store_id) AS store_nm,
  68. DATE_FORMAT(A.sys_reg_dttm,'%Y.%m.%d %H:%i:%s') AS sys_reg_dttm, A.sys_reg_id, DATE_FORMAT(A.sys_chg_dttm,'%Y.%m.%d %H:%i:%s') AS sys_chg_dttm, A.sys_chg_id
  69. FROM whs_mgnt_base_info A
  70. WHERE A.brand_id = #{brandId}
  71. AND A.whs_id = #{whsId}
  72. </select>
  73. <select id="selectWhsLocGridList" resultType="com.oqpo.api.entity.stockmng.WhsMgntBaseLocEntity">
  74. /* WhsMngMapper.selectWhsLocGridList */
  75. SELECT A.brand_id, A.whs_id, A.location, A.location_nm,
  76. A.stck_dvsn, FN_CODE_NM('STCK_DVSN', A.stck_dvsn) AS stck_dvsn_nm,
  77. A.loc_st_cd, FN_CODE_NM('LOC_ST_CD', A.loc_st_cd) AS loc_st_nm
  78. FROM whs_mgnt_base_loc A
  79. WHERE A.brand_id = #{brandId}
  80. AND A.whs_id = #{whsId}
  81. ORDER BY A.location ASC
  82. <if test="gridRequest.pagingYn == true">
  83. limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
  84. </if>
  85. </select>
  86. <select id="selectWhsLocGridCnt" resultType="int">
  87. /* WhsMngMapper.selectWhsLocGridCnt */
  88. SELECT COUNT(*)
  89. FROM whs_mgnt_base_loc A
  90. WHERE A.brand_id = #{brandId}
  91. AND A.whs_id = #{whsId}
  92. </select>
  93. <insert id="insertWhsMgntBaseInfo" >
  94. /* WhsMngMapper.insertWhsMgntBaseInfo */
  95. INSERT INTO whs_mgnt_base_info
  96. (brand_id, whs_id, whs_nm, whs_dvsn, mgr_nm, mgr_tel_no, zip_no, addr1, addr2, whs_st_cd, store_id,
  97. sys_reg_dttm, sys_reg_id, sys_chg_dttm, sys_chg_id)
  98. VALUES
  99. (#{entity.brandId}, #{entity.whsId}, #{entity.whsNm}, #{entity.whsDvsn}, #{entity.mgrNm}, #{entity.mgrTelNo},
  100. #{entity.zipNo}, #{entity.addr1}, #{entity.addr2}, #{entity.whsStCd}, #{entity.storeId},
  101. NOW(), #{userId}, NOW(), #{userId})
  102. </insert>
  103. <update id="updateWhsMgntBaseInfo" >
  104. /* WhsMngMapper.updateWhsMgntBaseInfo */
  105. UPDATE whs_mgnt_base_info SET
  106. whs_nm = #{entity.whsNm},
  107. whs_dvsn = #{entity.whsDvsn},
  108. mgr_nm = #{entity.mgrNm},
  109. mgr_tel_no = #{entity.mgrTelNo},
  110. zip_no = #{entity.zipNo},
  111. addr1 = #{entity.addr1},
  112. addr2 = #{entity.addr2},
  113. whs_st_cd = #{entity.whsStCd},
  114. store_id = #{entity.storeId},
  115. sys_chg_dttm = NOW(),
  116. sys_chg_id = #{userId}
  117. WHERE brand_id = #{entity.brandId}
  118. AND whs_id = #{entity.whsId}
  119. </update>
  120. <delete id="deleteWhsMgntBaseInfo" >
  121. /* WhsMngMapper.deleteWhsMgntBaseInfo */
  122. DELETE FROM whs_mgnt_base_info
  123. WHERE brand_id = #{entity.brandId}
  124. AND whs_id = #{entity.whsId}
  125. </delete>
  126. <delete id="deleteWhsMgntBaseLoc4Info" >
  127. /* WhsMngMapper.deleteWhsMgntBaseLoc4Info */
  128. DELETE FROM whs_mgnt_base_loc
  129. WHERE brand_id = #{entity.brandId}
  130. AND whs_id = #{entity.whsId}
  131. </delete>
  132. <select id="selectNextLocation4Whs" resultType="java.lang.String">
  133. /* WhsMngMapper.selectNextLocation4Whs */
  134. SELECT IFNULL(MAX(A.LOCATION), 1000) + 1
  135. FROM whs_mgnt_base_loc A
  136. WHERE A.brand_id = #{brandId}
  137. AND A.whs_id = #{whsId}
  138. </select>
  139. <insert id="insertWhsMgntBaseLoc" >
  140. /* WhsMngMapper.insertWhsMgntBaseLoc */
  141. INSERT INTO whs_mgnt_base_loc
  142. (brand_id, whs_id, location, location_nm, stck_dvsn, loc_st_cd,
  143. sys_reg_dttm, sys_reg_id, sys_chg_dttm, sys_chg_id)
  144. VALUES
  145. (#{entity.brandId}, #{entity.whsId}, #{entity.location}, #{entity.locationNm}, #{entity.stckDvsn}, #{entity.locStCd},
  146. NOW(), #{userId}, NOW(), #{userId})
  147. </insert>
  148. <update id="updateWhsMgntBaseLoc" >
  149. /* WhsMngMapper.updateWhsMgntBaseLoc */
  150. UPDATE whs_mgnt_base_loc SET
  151. location_nm = #{entity.locationNm},
  152. stck_dvsn = #{entity.stckDvsn},
  153. loc_st_cd = #{entity.locStCd},
  154. sys_chg_dttm = NOW(),
  155. sys_chg_id = #{entity.sysChgId}
  156. WHERE brand_id = #{entity.brandId}
  157. AND whs_id = #{entity.whsId}
  158. AND location = #{entity.location}
  159. </update>
  160. <delete id="deleteWhsMgntBaseLoc" >
  161. /* WhsMngMapper.deleteWhsMgntBaseLoc */
  162. DELETE FROM whs_mgnt_base_loc
  163. WHERE brand_id = #{entity.brandId}
  164. AND whs_id = #{entity.whsId}
  165. AND location = #{entity.location}
  166. </delete>
  167. <update id="updateStoreWhsStatus" >
  168. /* WhsMngMapper.updateStoreWhsStatus */
  169. UPDATE whs_mgnt_base_info SET
  170. <if test="whsStCd != null and whsStCd != ''">
  171. whs_st_cd = #{whsStCd},
  172. </if>
  173. sys_chg_dttm = NOW(),
  174. sys_chg_id = #{userId}
  175. WHERE 1=1
  176. <if test="brandId != null and brandId != ''">
  177. and brand_id = #{brandId}
  178. </if>
  179. <if test="storeId != null and storeId != ''">
  180. AND store_id = #{storeId}
  181. </if>
  182. </update>
  183. <update id="updateWhsLocStatus" >
  184. /* WhsMngMapper.updateWhsLocStatus */
  185. UPDATE whs_mgnt_base_loc SET
  186. <if test="locStCd != null and locStCd != ''">
  187. loc_st_cd = #{locStCd},
  188. </if>
  189. sys_chg_dttm = NOW(),
  190. sys_chg_id = #{userId}
  191. WHERE concat(brand_id , whs_id) in (
  192. select concat(brand_id, whs_id)
  193. from whs_mgnt_base_info
  194. WHERE 1=1
  195. <if test="brandId != null and brandId != ''">
  196. and brand_id = #{brandId}
  197. </if>
  198. <if test="storeId != null and storeId != ''">
  199. AND store_id = #{storeId}
  200. </if>
  201. )
  202. </update>
  203. <update id="updateCloseWhs" >
  204. update whs_mgnt_base_info
  205. set sys_chg_dttm = now()
  206. ,sys_chg_id = #{userId}
  207. ,whs_st_cd = 'W003'
  208. where 1=1
  209. <if test="brandId != null and brandId != ''">
  210. and brand_id = #{brandId}
  211. </if>
  212. <if test="afflShopId != null and afflShopId != ''">
  213. and brand_id in (select brand_id from affl_shop_base_info where affl_shop_id = #{afflShopId})
  214. </if>
  215. </update>
  216. <update id="updateCloseWhsLoc" >
  217. UPDATE whs_mgnt_base_loc
  218. SET sys_chg_dttm = now()
  219. ,sys_chg_id = #{userId}
  220. loc_st_cd = 'LOC003'
  221. WHERE 1=1
  222. and concat(brand_id , whs_id) in (
  223. select concat(brand_id, whs_id)
  224. from whs_mgnt_base_info
  225. WHERE 1=1
  226. <if test="brandId != null and brandId != ''">
  227. and brand_id = #{brandId}
  228. </if>
  229. <if test="afflShopId != null and afflShopId != ''">
  230. and brand_id in (select brand_id from affl_shop_base_info where affl_shop_id = #{afflShopId})
  231. </if>
  232. )
  233. </update>
  234. </mapper>