OrgServiceDaoImplMapper.xml 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  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,belong_community_id,allow_operation
  10. ) values (
  11. #{orgName},#{operate},#{parentOrgId},#{description},#{orgLevel},#{storeId},#{bId},#{orgId},#{belongCommunityId},#{allowOperation}
  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,t.belong_community_id ,t.belong_community_id belongCommunityId,
  19. t.allow_operation ,t.allow_operation allowOperation
  20. from business_org t
  21. where 1 =1
  22. <if test="orgName !=null and orgName != ''">
  23. and t.org_name= #{orgName}
  24. </if>
  25. <if test="operate !=null and operate != ''">
  26. and t.operate= #{operate}
  27. </if>
  28. <if test="parentOrgId !=null and parentOrgId != ''">
  29. and t.parent_org_id= #{parentOrgId}
  30. </if>
  31. <if test="description !=null and description != ''">
  32. and t.description= #{description}
  33. </if>
  34. <if test="orgLevel !=null and orgLevel != ''">
  35. and t.org_level= #{orgLevel}
  36. </if>
  37. <if test="storeId !=null and storeId != ''">
  38. and t.store_id= #{storeId}
  39. </if>
  40. <if test="bId !=null and bId != ''">
  41. and t.b_id= #{bId}
  42. </if>
  43. <if test="orgId !=null and orgId != ''">
  44. and t.org_id= #{orgId}
  45. </if>
  46. <if test="belongCommunityId !=null and belongCommunityId != ''">
  47. and t.belong_community_id= #{belongCommunityId}
  48. </if>
  49. <if test="allowOperation !=null and allowOperation != ''">
  50. and t.allow_operation= #{allowOperation}
  51. </if>
  52. </select>
  53. <!-- 保存组织信息至 instance表中 add by wuxw 2018-07-03 -->
  54. <insert id="saveOrgInfoInstance" parameterType="Map">
  55. insert into u_org(
  56. org_name,parent_org_id,description,org_level,status_cd,store_id,b_id,org_id,belong_community_id,allow_operation
  57. ) select t.org_name,t.parent_org_id,t.description,t.org_level,'0',t.store_id,t.b_id,t.org_id,t.belong_community_id,t.allow_operation
  58. from business_org t
  59. where 1=1
  60. <if test="orgName !=null and orgName != ''">
  61. and t.org_name= #{orgName}
  62. </if>
  63. and t.operate= 'ADD'
  64. <if test="parentOrgId !=null and parentOrgId != ''">
  65. and t.parent_org_id= #{parentOrgId}
  66. </if>
  67. <if test="description !=null and description != ''">
  68. and t.description= #{description}
  69. </if>
  70. <if test="orgLevel !=null and orgLevel != ''">
  71. and t.org_level= #{orgLevel}
  72. </if>
  73. <if test="storeId !=null and storeId != ''">
  74. and t.store_id= #{storeId}
  75. </if>
  76. <if test="bId !=null and bId != ''">
  77. and t.b_id= #{bId}
  78. </if>
  79. <if test="orgId !=null and orgId != ''">
  80. and t.org_id= #{orgId}
  81. </if>
  82. <if test="belongCommunityId !=null and belongCommunityId != ''">
  83. and t.belong_community_id= #{belongCommunityId}
  84. </if>
  85. <if test="allowOperation !=null and allowOperation != ''">
  86. and t.allow_operation= #{allowOperation}
  87. </if>
  88. </insert>
  89. <!-- 查询组织信息 add by wuxw 2018-07-03 -->
  90. <select id="getOrgInfo" parameterType="Map" resultType="Map">
  91. select t.org_name,t.org_name orgName,t.parent_org_id,t.parent_org_id
  92. parentOrgId,t.description,t.org_level,t.org_level orgLevel,td.name orgLevelName,t.status_cd,t.status_cd
  93. 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,
  94. t.belong_community_id ,t.belong_community_id belongCommunityId,
  95. t.allow_operation ,t.allow_operation allowOperation
  96. from u_org t,t_dict td,u_org uo
  97. <if test="staffId != null and staffId !=''">
  98. ,u_org_staff_rel uosr
  99. </if>
  100. where 1 =1
  101. and t.org_level = td.status_cd
  102. and td.table_name='u_org'
  103. and td.table_columns = 'org_level'
  104. and t.parent_org_id = uo.org_id
  105. and uo.status_cd = '0'
  106. <if test="staffId != null and staffId !=''">
  107. and uosr.org_id = t.org_id
  108. and uosr.staff_id = #{staffId}
  109. and uosr.status_cd = '0'
  110. </if>
  111. <if test="orgName !=null and orgName != ''">
  112. and t.org_name= #{orgName}
  113. </if>
  114. <if test="parentOrgId !=null and parentOrgId != ''">
  115. and t.parent_org_id= #{parentOrgId}
  116. </if>
  117. <if test="description !=null and description != ''">
  118. and t.description= #{description}
  119. </if>
  120. <if test="orgLevel !=null and orgLevel != ''">
  121. and t.org_level= #{orgLevel}
  122. </if>
  123. <if test="statusCd !=null and statusCd != ''">
  124. and t.status_cd= #{statusCd}
  125. </if>
  126. <if test="storeId !=null and storeId != ''">
  127. and t.store_id= #{storeId}
  128. </if>
  129. <if test="bId !=null and bId != ''">
  130. and t.b_id= #{bId}
  131. </if>
  132. <if test="orgId !=null and orgId != ''">
  133. and t.org_id= #{orgId}
  134. </if>
  135. <if test="belongCommunityId !=null and belongCommunityId != ''">
  136. and t.belong_community_id= #{belongCommunityId}
  137. </if>
  138. <if test="allowOperation !=null and allowOperation != ''">
  139. and t.allow_operation= #{allowOperation}
  140. </if>
  141. <if test="page != -1 and page != null ">
  142. limit #{page}, #{row}
  143. </if>
  144. </select>
  145. <!-- 修改组织信息 add by wuxw 2018-07-03 -->
  146. <update id="updateOrgInfoInstance" parameterType="Map">
  147. update u_org t set t.status_cd = #{statusCd}
  148. <if test="newBId != null and newBId != ''">
  149. ,t.b_id = #{newBId}
  150. </if>
  151. <if test="orgName !=null and orgName != ''">
  152. , t.org_name= #{orgName}
  153. </if>
  154. <if test="parentOrgId !=null and parentOrgId != ''">
  155. , t.parent_org_id= #{parentOrgId}
  156. </if>
  157. <if test="description !=null and description != ''">
  158. , t.description= #{description}
  159. </if>
  160. <if test="orgLevel !=null and orgLevel != ''">
  161. , t.org_level= #{orgLevel}
  162. </if>
  163. <if test="belongCommunityId !=null and belongCommunityId != ''">
  164. , t.belong_community_id= #{belongCommunityId}
  165. </if>
  166. <if test="storeId !=null and storeId != ''">
  167. , t.store_id= #{storeId}
  168. </if>
  169. <if test="allowOperation !=null and allowOperation != ''">
  170. , t.allow_operation= #{allowOperation}
  171. </if>
  172. where 1=1
  173. <if test="bId !=null and bId != ''">
  174. and t.b_id= #{bId}
  175. </if>
  176. <if test="orgId !=null and orgId != ''">
  177. and t.org_id= #{orgId}
  178. </if>
  179. </update>
  180. <!-- 查询组织数量 add by wuxw 2018-07-03 -->
  181. <select id="queryOrgsCount" parameterType="Map" resultType="Map">
  182. select count(1) count
  183. from u_org t,t_dict td,u_org uo
  184. <if test="staffId != null and staffId !=''">
  185. ,u_org_staff_rel uosr
  186. </if>
  187. where 1 =1
  188. and t.org_level = td.status_cd
  189. and td.table_name='u_org'
  190. and td.table_columns = 'org_level'
  191. and t.parent_org_id = uo.org_id
  192. and uo.status_cd = '0'
  193. <if test="staffId != null and staffId !=''">
  194. and uosr.org_id = t.org_id
  195. and uosr.staff_id = #{staffId}
  196. and uosr.status_cd = '0'
  197. </if>
  198. <if test="orgName !=null and orgName != ''">
  199. and t.org_name= #{orgName}
  200. </if>
  201. <if test="parentOrgId !=null and parentOrgId != ''">
  202. and t.parent_org_id= #{parentOrgId}
  203. </if>
  204. <if test="description !=null and description != ''">
  205. and t.description= #{description}
  206. </if>
  207. <if test="orgLevel !=null and orgLevel != ''">
  208. and t.org_level= #{orgLevel}
  209. </if>
  210. <if test="statusCd !=null and statusCd != ''">
  211. and t.status_cd= #{statusCd}
  212. </if>
  213. <if test="storeId !=null and storeId != ''">
  214. and t.store_id= #{storeId}
  215. </if>
  216. <if test="bId !=null and bId != ''">
  217. and t.b_id= #{bId}
  218. </if>
  219. <if test="orgId !=null and orgId != ''">
  220. and t.org_id= #{orgId}
  221. </if>
  222. <if test="belongCommunityId !=null and belongCommunityId != ''">
  223. and t.belong_community_id= #{belongCommunityId}
  224. </if>
  225. <if test="allowOperation !=null and allowOperation != ''">
  226. and t.allow_operation= #{allowOperation}
  227. </if>
  228. </select>
  229. <!-- 查询上级组织信息 -->
  230. <select id="getParentOrgInfo" parameterType="Map" resultType="Map">
  231. <![CDATA[
  232. SELECT t.org_name,t.org_name orgName,t.parent_org_id,t.parent_org_id
  233. parentOrgId,t.description,t.org_level,t.org_level orgLevel,t.status_cd,t.status_cd
  234. statusCd,t.store_id,t.store_id storeId,t.b_id,t.b_id bId,t.org_id,t.org_id orgId
  235. FROM u_org o,u_org t
  236. WHERE o.`org_level` = #{orgLevel}
  237. AND o.`store_id` = t.`store_id`
  238. AND o.`parent_org_id` = t.`org_id`
  239. AND o.`org_id` <> o.`parent_org_id`
  240. AND o.`store_id` = #{storeId}
  241. ]]>
  242. </select>
  243. </mapper>