OrgServiceDaoImplMapper.xml 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="orgServiceDaoImpl">
  6. <!-- 保存组织信息 add by wuxw 2018-07-03 -->
  7. <insert id="saveBusinessOrgInfo" parameterType="Map">
  8. insert into business_org(
  9. org_name,operate,parent_org_id,description,org_level,store_id,b_id,org_id
  10. ) values (
  11. #{orgName},#{operate},#{parentOrgId},#{description},#{orgLevel},#{storeId},#{bId},#{orgId}
  12. )
  13. </insert>
  14. <!-- 查询组织信息(Business) add by wuxw 2018-07-03 -->
  15. <select id="getBusinessOrgInfo" parameterType="Map" resultType="Map">
  16. select t.org_name,t.org_name orgName,t.operate,t.parent_org_id,t.parent_org_id
  17. parentOrgId,t.description,t.org_level,t.org_level orgLevel,t.store_id,t.store_id storeId,t.b_id,t.b_id
  18. bId,t.org_id,t.org_id orgId
  19. from business_org t
  20. where 1 =1
  21. <if test="orgName !=null and orgName != ''">
  22. and t.org_name= #{orgName}
  23. </if>
  24. <if test="operate !=null and operate != ''">
  25. and t.operate= #{operate}
  26. </if>
  27. <if test="parentOrgId !=null and parentOrgId != ''">
  28. and t.parent_org_id= #{parentOrgId}
  29. </if>
  30. <if test="description !=null and description != ''">
  31. and t.description= #{description}
  32. </if>
  33. <if test="orgLevel !=null and orgLevel != ''">
  34. and t.org_level= #{orgLevel}
  35. </if>
  36. <if test="storeId !=null and storeId != ''">
  37. and t.store_id= #{storeId}
  38. </if>
  39. <if test="bId !=null and bId != ''">
  40. and t.b_id= #{bId}
  41. </if>
  42. <if test="orgId !=null and orgId != ''">
  43. and t.org_id= #{orgId}
  44. </if>
  45. </select>
  46. <!-- 保存组织信息至 instance表中 add by wuxw 2018-07-03 -->
  47. <insert id="saveOrgInfoInstance" parameterType="Map">
  48. insert into u_org(
  49. org_name,parent_org_id,description,org_level,status_cd,store_id,b_id,org_id
  50. ) select t.org_name,t.parent_org_id,t.description,t.org_level,'0',t.store_id,t.b_id,t.org_id from business_org t
  51. where 1=1
  52. <if test="orgName !=null and orgName != ''">
  53. and t.org_name= #{orgName}
  54. </if>
  55. and t.operate= 'ADD'
  56. <if test="parentOrgId !=null and parentOrgId != ''">
  57. and t.parent_org_id= #{parentOrgId}
  58. </if>
  59. <if test="description !=null and description != ''">
  60. and t.description= #{description}
  61. </if>
  62. <if test="orgLevel !=null and orgLevel != ''">
  63. and t.org_level= #{orgLevel}
  64. </if>
  65. <if test="storeId !=null and storeId != ''">
  66. and t.store_id= #{storeId}
  67. </if>
  68. <if test="bId !=null and bId != ''">
  69. and t.b_id= #{bId}
  70. </if>
  71. <if test="orgId !=null and orgId != ''">
  72. and t.org_id= #{orgId}
  73. </if>
  74. </insert>
  75. <!-- 查询组织信息 add by wuxw 2018-07-03 -->
  76. <select id="getOrgInfo" parameterType="Map" resultType="Map">
  77. select t.org_name,t.org_name orgName,t.parent_org_id,t.parent_org_id
  78. parentOrgId,t.description,t.org_level,t.org_level orgLevel,td.name orgLevelName,t.status_cd,t.status_cd
  79. statusCd,t.store_id,t.store_id storeId,t.b_id,t.b_id bId,t.org_id,t.org_id orgId,uo.org_name parentOrgName
  80. from u_org t,t_dict td,u_org uo
  81. where 1 =1
  82. and t.org_level = td.status_cd
  83. and td.table_name='u_org'
  84. and td.table_columns = 'org_level'
  85. and t.parent_org_id = uo.org_id
  86. and uo.status_cd = '0'
  87. <if test="orgName !=null and orgName != ''">
  88. and t.org_name= #{orgName}
  89. </if>
  90. <if test="parentOrgId !=null and parentOrgId != ''">
  91. and t.parent_org_id= #{parentOrgId}
  92. </if>
  93. <if test="description !=null and description != ''">
  94. and t.description= #{description}
  95. </if>
  96. <if test="orgLevel !=null and orgLevel != ''">
  97. and t.org_level= #{orgLevel}
  98. </if>
  99. <if test="statusCd !=null and statusCd != ''">
  100. and t.status_cd= #{statusCd}
  101. </if>
  102. <if test="storeId !=null and storeId != ''">
  103. and t.store_id= #{storeId}
  104. </if>
  105. <if test="bId !=null and bId != ''">
  106. and t.b_id= #{bId}
  107. </if>
  108. <if test="orgId !=null and orgId != ''">
  109. and t.org_id= #{orgId}
  110. </if>
  111. <if test="page != -1 and page != null ">
  112. limit #{page}, #{row}
  113. </if>
  114. </select>
  115. <!-- 修改组织信息 add by wuxw 2018-07-03 -->
  116. <update id="updateOrgInfoInstance" parameterType="Map">
  117. update u_org t set t.status_cd = #{statusCd}
  118. <if test="newBId != null and newBId != ''">
  119. ,t.b_id = #{newBId}
  120. </if>
  121. <if test="orgName !=null and orgName != ''">
  122. , t.org_name= #{orgName}
  123. </if>
  124. <if test="parentOrgId !=null and parentOrgId != ''">
  125. , t.parent_org_id= #{parentOrgId}
  126. </if>
  127. <if test="description !=null and description != ''">
  128. , t.description= #{description}
  129. </if>
  130. <if test="orgLevel !=null and orgLevel != ''">
  131. , t.org_level= #{orgLevel}
  132. </if>
  133. <if test="storeId !=null and storeId != ''">
  134. , t.store_id= #{storeId}
  135. </if>
  136. where 1=1
  137. <if test="bId !=null and bId != ''">
  138. and t.b_id= #{bId}
  139. </if>
  140. <if test="orgId !=null and orgId != ''">
  141. and t.org_id= #{orgId}
  142. </if>
  143. </update>
  144. <!-- 查询组织数量 add by wuxw 2018-07-03 -->
  145. <select id="queryOrgsCount" parameterType="Map" resultType="Map">
  146. select count(1) count
  147. from u_org t,t_dict td,u_org uo
  148. where 1 =1
  149. and t.org_level = td.status_cd
  150. and td.table_name='u_org'
  151. and td.table_columns = 'org_level'
  152. and t.parent_org_id = uo.org_id
  153. and uo.status_cd = '0'
  154. <if test="orgName !=null and orgName != ''">
  155. and t.org_name= #{orgName}
  156. </if>
  157. <if test="parentOrgId !=null and parentOrgId != ''">
  158. and t.parent_org_id= #{parentOrgId}
  159. </if>
  160. <if test="description !=null and description != ''">
  161. and t.description= #{description}
  162. </if>
  163. <if test="orgLevel !=null and orgLevel != ''">
  164. and t.org_level= #{orgLevel}
  165. </if>
  166. <if test="statusCd !=null and statusCd != ''">
  167. and t.status_cd= #{statusCd}
  168. </if>
  169. <if test="storeId !=null and storeId != ''">
  170. and t.store_id= #{storeId}
  171. </if>
  172. <if test="bId !=null and bId != ''">
  173. and t.b_id= #{bId}
  174. </if>
  175. <if test="orgId !=null and orgId != ''">
  176. and t.org_id= #{orgId}
  177. </if>
  178. </select>
  179. <!-- 查询上级组织信息 -->
  180. <select id="getParentOrgInfo" parameterType="Map" resultType="Map">
  181. <![CDATA[
  182. SELECT t.org_name,t.org_name orgName,t.parent_org_id,t.parent_org_id
  183. parentOrgId,t.description,t.org_level,t.org_level orgLevel,t.status_cd,t.status_cd
  184. statusCd,t.store_id,t.store_id storeId,t.b_id,t.b_id bId,t.org_id,t.org_id orgId
  185. FROM u_org o,u_org t
  186. WHERE o.`org_level` = #{orgLevel}
  187. AND o.`store_id` = t.`store_id`
  188. AND o.`parent_org_id` = t.`org_id`
  189. AND o.`org_id` <> o.`parent_org_id`
  190. AND o.`store_id` = #{storeId}
  191. ]]>
  192. </select>
  193. </mapper>