Supply.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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.SupplyMapper">
  4. <select id="selectPopSpplyGridList" resultType="com.oqpo.api.entity.stinfo.SpplyEntity">
  5. select /* selectPopSpplyGridList */
  6. brand_id, fn_brand_nm(brand_id) as brand_nm, spply_id, spply_nm, st_cd, fn_code_nm('ST_CD',st_cd) as st_nm
  7. from spply_base_info
  8. where brand_id = #{sBrandId}
  9. and st_cd = 'S000'
  10. <if test="sSpplyNm != null and sSpplyNm != ''">
  11. and spply_nm like concat('%',#{sSpplyNm},'%')
  12. </if>
  13. <choose>
  14. <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
  15. <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
  16. <if test="gridRequest.sord == 'asc'.toString()">
  17. order by spply_nm asc
  18. </if>
  19. <if test="gridRequest.sord == 'desc'.toString()">
  20. order by spply_nm desc
  21. </if>
  22. </if>
  23. </when>
  24. <otherwise>
  25. order by spply_nm asc
  26. </otherwise>
  27. </choose>
  28. <if test="gridRequest.pagingYn == true">
  29. limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
  30. </if>
  31. </select>
  32. <select id="selectPopSpplyGridCnt" resultType="int">
  33. select /*selectPopSpplyGridCnt*/
  34. count(*)
  35. from spply_base_info
  36. where brand_id = #{sBrandId}
  37. and st_cd = 'S000'
  38. <if test="sSpplyNm != null and sSpplyNm != ''">
  39. and spply_nm like concat('%',#{sSpplyNm},'%')
  40. </if>
  41. </select>
  42. <select id="selectSpplyGridList" resultType="com.oqpo.api.entity.stinfo.SpplyEntity">
  43. select /* selectSpplyGridList */
  44. brand_id, fn_brand_nm(brand_id) as brand_nm, spply_id, spply_nm, st_cd, fn_code_nm('ST_CD',st_cd) as st_nm
  45. , fn_get_regno(1, bsns_reg_no) as bsns_reg_no , owner_nm, date_format(sys_reg_dttm,'%Y.%m.%d') as sys_reg_dttm
  46. from spply_base_info
  47. where brand_id = #{sBrandId}
  48. <if test="sStCd != null and sStCd != ''">
  49. and st_cd = #{sStCd}
  50. </if>
  51. <if test="sBsnsRegNo != null and sBsnsRegNo != ''">
  52. and bsns_reg_no like concat('%',#{sBsnsRegNo},'%')
  53. </if>
  54. <if test="sSpplyNm != null and sSpplyNm != ''">
  55. and spply_nm like concat('%',#{sSpplyNm},'%')
  56. </if>
  57. <choose>
  58. <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
  59. <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
  60. <if test="gridRequest.sord == 'asc'.toString()">
  61. order by spply_nm asc
  62. </if>
  63. <if test="gridRequest.sord == 'desc'.toString()">
  64. order by spply_nm desc
  65. </if>
  66. </if>
  67. </when>
  68. <otherwise>
  69. order by spply_nm asc
  70. </otherwise>
  71. </choose>
  72. <if test="gridRequest.pagingYn == true">
  73. limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
  74. </if>
  75. </select>
  76. <select id="selectSpplyGridCnt" resultType="int">
  77. select /* selectSpplyGridCnt */
  78. count(*) as cnt
  79. from spply_base_info
  80. where brand_id = #{sBrandId}
  81. <if test="sStCd != null and sStCd != ''">
  82. and st_cd = #{sStCd}
  83. </if>
  84. <if test="sBsnsRegNo != null and sBsnsRegNo != ''">
  85. and bsns_reg_no like concat('%',#{sBsnsRegNo},'%')
  86. </if>
  87. <if test="sSpplyNm != null and sSpplyNm != ''">
  88. and spply_nm like concat('%',#{sSpplyNm},'%')
  89. </if>
  90. </select>
  91. <insert id="insertSpplyInfo" >
  92. insert into spply_base_info
  93. (
  94. spply_id, spply_nm, st_cd, corp_type, bsns_reg_no,
  95. corp_reg_no, owner_nm, ctgr_bsns, bsns_cndt, corp_dvsn,
  96. mbl_no, mgr_nm, area_cd,
  97. dept_nm, mgr_emal, mgr_tel_no, mgr_mbl_no, del_yn,
  98. lst_login_dttm, zip_no, addr1, addr2, brand_id,
  99. bnk_cd, acct_no, owac_nm, bbook_copy_file_no, bsns_reg_file_no,
  100. sys_reg_dttm, sys_reg_id, sys_chg_dttm, sys_chg_id,
  101. lat_x, long_y, fax_no
  102. )
  103. values
  104. (
  105. #{entity.spplyId}, #{entity.spplyNm}, #{entity.stCd}, #{entity.corpType}, #{entity.bsnsRegNo},
  106. #{entity.corpRegNo}, #{entity.ownerNm}, #{entity.ctgrBsns}, #{entity.bsnsCndt}, #{entity.corpDvsn},
  107. #{entity.mblNo}, #{entity.mgrNm}, #{entity.areaCd},
  108. #{entity.deptNm}, #{entity.mgrEmal}, #{entity.mgrTelNo}, #{entity.mgrMblNo}, 'N',
  109. null, #{entity.zipNo}, #{entity.addr1}, #{entity.addr2}, #{entity.brandId},
  110. #{entity.bnkCd}, #{entity.acctNo}, #{entity.owacNm}, #{entity.bbookCopyFileNo}, #{entity.bsnsRegFileNo},
  111. now(), #{userId}, now(), #{userId},
  112. #{entity.latX}, #{entity.longY}, #{entity.faxNo}
  113. )
  114. </insert>
  115. <update id="updateSpplyInfo">
  116. update spply_base_info /* updateSpplyInfo */
  117. set sys_chg_id = #{userId}
  118. ,sys_chg_dttm = now()
  119. ,spply_nm = #{entity.spplyNm}
  120. ,st_cd = #{entity.stCd}
  121. ,corp_type = #{entity.corpType}
  122. ,bsns_reg_no = #{entity.bsnsRegNo}
  123. ,corp_reg_no = #{entity.corpRegNo}
  124. ,owner_nm = #{entity.ownerNm}
  125. ,ctgr_bsns = #{entity.ctgrBsns}
  126. ,bsns_cndt = #{entity.bsnsCndt}
  127. ,corp_dvsn = #{entity.corpDvsn}
  128. ,mbl_no = #{entity.mblNo}
  129. ,mgr_nm = #{entity.mgrNm}
  130. ,mgr_emal = #{entity.mgrEmal}
  131. ,mgr_tel_no = #{entity.mgrTelNo}
  132. ,mgr_mbl_no = #{entity.mgrMblNo}
  133. ,fax_no = #{entity.faxNo}
  134. ,del_yn = #{entity.delYn}
  135. ,area_cd = #{entity.areaCd}
  136. ,zip_no = #{entity.zipNo}
  137. ,addr1 = #{entity.addr1}
  138. ,addr2 = #{entity.addr2}
  139. ,lat_x = #{entity.latX}
  140. ,long_y = #{entity.longY}
  141. ,bnk_cd = #{entity.bnkCd}
  142. ,acct_no = #{entity.acctNo}
  143. ,owac_nm = #{entity.owacNm}
  144. ,bbook_copy_file_no = #{entity.bbookCopyFileNo}
  145. ,bsns_reg_file_no = #{entity.bsnsRegFileNo}
  146. where spply_id = #{entity.spplyId}
  147. </update>
  148. <insert id="insertSpplyMgrInfo" >
  149. insert into spply_mgr_mgnt /* insertSpplyMgrInfo */
  150. (
  151. spply_id, spply_mgr_id, spply_mgr_nm, rprst_tel_no,
  152. rprst_emal, position, assgn_task, sys_reg_dttm,
  153. sys_reg_id, sys_chg_dttm, sys_chg_id
  154. )
  155. values
  156. <foreach collection="gridInsertData" item="item" separator=",">
  157. (
  158. #{item.spplyId}, #{item.spplyMgrId}, #{item.spplyMgrNm}, #{item.rprstTelNo},
  159. #{item.rprstEmal}, #{item.position}, #{item.assgnTask}, now(),
  160. #{userId}, now(), #{userId}
  161. )
  162. </foreach>
  163. </insert>
  164. <delete id="deleteSpplyMgrInfo">
  165. delete from spply_mgr_mgnt
  166. where spply_id = #{spplyId}
  167. and spply_mgr_id in
  168. <foreach collection="gridDeleteData" item="item" separator="," open="(" close=")">
  169. #{item.spplyMgrId}
  170. </foreach>
  171. </delete>
  172. <update id="updateSpplyMgrInfo">
  173. <foreach collection="gridUpdateData" item="item" separator=";">
  174. UPDATE /* Supply.updateSpplyMgrInfo */ spply_mgr_mgnt
  175. SET
  176. spply_mgr_nm = #{item.spplyMgrNm}
  177. ,rprst_tel_no = #{item.rprstTelNo}
  178. ,rprst_emal = #{item.rprstEmal}
  179. ,position = #{item.position}
  180. ,assgn_task = #{item.assgnTask}
  181. ,sys_chg_id = #{userId}
  182. WHERE spply_id = #{item.spplyId}
  183. AND spply_mgr_id = #{item.spplyMgrId}
  184. </foreach>
  185. </update>
  186. <select id="selectSpplyInfo" resultType="com.oqpo.api.entity.stinfo.SpplyEntity">
  187. select /* selectSpplyInfo */
  188. spply_id, spply_nm, st_cd, fn_code_nm('ST_CD',st_cd) as st_nm, corp_type, fn_code_nm('CORP_TYPE',corp_type) AS corp_type_nm, fn_get_regno(1,bsns_reg_no) as bsns_reg_no,
  189. fn_get_regno(2,corp_reg_no) as corp_reg_no, owner_nm, ctgr_bsns, bsns_cndt, corp_dvsn, fn_code_nm('CORP_DVSN',corp_dvsn) as corp_dvsn_nm,
  190. mbl_no, mgr_nm, area_cd, fn_code_nm('AREA_CD',area_cd) as area_nm,
  191. dept_nm, mgr_emal, fn_get_telno(mgr_tel_no) as mgr_tel_no, fn_get_telno(mgr_mbl_no) as mgr_mbl_no, del_yn,
  192. lst_login_dttm, zip_no, addr1, addr2, brand_id, fn_brand_nm(brand_id) as brand_nm,
  193. bnk_cd, fn_code_nm('BNK_CD',bnk_cd) as bnk_nm, acct_no, owac_nm, bbook_copy_file_no, bsns_reg_file_no,
  194. 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,
  195. lat_x, long_y, fn_get_telno(fax_no) as fax_no
  196. from spply_base_info
  197. where brand_id = #{brandId}
  198. and spply_id = #{spplyId}
  199. </select>
  200. <select id="selectSpplyMgrList" resultType="com.oqpo.api.entity.stinfo.SpplyMgrEntity">
  201. select /* selectSpplyMgrList */
  202. spply_id, spply_mgr_id, spply_mgr_nm, fn_get_telno(rprst_tel_no) as rprst_tel_no, rprst_emal, position, assgn_task, fn_code_nm('ASSGN_TASK',assgn_task) as assgn_task_nm
  203. ,spply_mgr_nm
  204. from spply_mgr_mgnt
  205. where spply_id = #{spplyId}
  206. order by spply_mgr_id asc
  207. </select>
  208. <select id="selectSpplyInitPw" resultType="String">
  209. select bsns_reg_no
  210. from spply_base_info
  211. where brand_id = #{brandId}
  212. and spply_id = #{spplyId}
  213. </select>
  214. <select id="selectMaxSpplyMgrId" resultType="int">
  215. select /* selectMaxSpplyMgrId */
  216. nvl(max(spply_mgr_id),0) + 1 as spply_mgr_id
  217. from spply_mgr_mgnt
  218. where spply_id = #{spplyId}
  219. </select>
  220. <update id="updateCloseSpply" >
  221. update spply_base_info
  222. set sys_chg_dttm = now()
  223. ,sys_chg_id = #{userId}
  224. ,st_cd = 'S001'
  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. </update>
  233. </mapper>