OrgStaffRelServiceDaoImplMapper.xml 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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="orgStaffRelServiceDaoImpl">
  6. <!-- 保存组织员工关系信息 add by wuxw 2018-07-03 -->
  7. <insert id="saveBusinessOrgStaffRelInfo" parameterType="Map">
  8. insert into business_org_staff_rel(
  9. rel_id,operate,store_id,b_id,org_id,staff_id,rel_cd
  10. ) values (
  11. #{relId},#{operate},#{storeId},#{bId},#{orgId},#{staffId},#{relCd}
  12. )
  13. </insert>
  14. <!-- 查询组织员工关系信息(Business) add by wuxw 2018-07-03 -->
  15. <select id="getBusinessOrgStaffRelInfo" parameterType="Map" resultType="Map">
  16. select t.rel_id,t.rel_id relId,t.operate,t.store_id,t.store_id storeId,t.b_id,t.b_id bId,t.org_id,t.org_id
  17. orgId,t.staff_id,t.staff_id staffId,t.rel_cd,t.rel_cd relCd
  18. from business_org_staff_rel t
  19. where 1 =1
  20. <if test="relId !=null and relId != ''">
  21. and t.rel_id= #{relId}
  22. </if>
  23. <if test="operate !=null and operate != ''">
  24. and t.operate= #{operate}
  25. </if>
  26. <if test="storeId !=null and storeId != ''">
  27. and t.store_id= #{storeId}
  28. </if>
  29. <if test="bId !=null and bId != ''">
  30. and t.b_id= #{bId}
  31. </if>
  32. <if test="orgId !=null and orgId != ''">
  33. and t.org_id= #{orgId}
  34. </if>
  35. <if test="staffId !=null and staffId != ''">
  36. and t.staff_id= #{staffId}
  37. </if>
  38. <if test="relCd !=null and relCd != ''">
  39. and t.rel_cd= #{relCd}
  40. </if>
  41. </select>
  42. <!-- 保存组织员工关系信息至 instance表中 add by wuxw 2018-07-03 -->
  43. <insert id="saveOrgStaffRelInfoInstance" parameterType="Map">
  44. insert into u_org_staff_rel(
  45. rel_id,status_cd,store_id,b_id,org_id,staff_id,rel_cd
  46. ) select t.rel_id,'0',t.store_id,t.b_id,t.org_id,t.staff_id,t.rel_cd from business_org_staff_rel t where 1=1
  47. <if test="relId !=null and relId != ''">
  48. and t.rel_id= #{relId}
  49. </if>
  50. and t.operate= 'ADD'
  51. <if test="storeId !=null and storeId != ''">
  52. and t.store_id= #{storeId}
  53. </if>
  54. <if test="bId !=null and bId != ''">
  55. and t.b_id= #{bId}
  56. </if>
  57. <if test="orgId !=null and orgId != ''">
  58. and t.org_id= #{orgId}
  59. </if>
  60. <if test="staffId !=null and staffId != ''">
  61. and t.staff_id= #{staffId}
  62. </if>
  63. <if test="relCd !=null and relCd != ''">
  64. and t.rel_cd= #{relCd}
  65. </if>
  66. </insert>
  67. <!-- 查询组织员工关系信息 add by wuxw 2018-07-03 -->
  68. <select id="getOrgStaffRelInfo" parameterType="Map" resultType="Map">
  69. select t.rel_id,t.rel_id relId,t.status_cd,t.status_cd statusCd,t.store_id,t.store_id storeId,t.b_id,t.b_id
  70. bId,t.org_id,t.org_id orgId,t.staff_id,t.staff_id staffId,t.rel_cd,t.rel_cd relCd,uo.parent_org_id parentOrgId,
  71. uu.name staffName,uo.org_name departmentName,uo.org_id departmentId,td.`name` relCdName,puo.org_name parentOrgName,uo.org_name orgName
  72. from u_org_staff_rel t
  73. inner join u_org uo on t.org_id = uo.org_id and uo.status_cd = '0'
  74. inner join u_org puo on uo.parent_org_id = puo.org_id and puo.status_cd = '0'
  75. inner join u_user uu on t.staff_id = uu.user_id
  76. left join t_dict td on t.rel_cd = td.status_cd and td.table_name = 'u_org_staff_rel' and td.table_columns = 'rel_cd'
  77. where 1=1
  78. <if test='statusCd ==null or statusCd != "1"'>
  79. and uu.status_cd = '0'
  80. and uo.status_cd = '0'
  81. and t.status_cd= '0'
  82. </if>
  83. <if test="relId !=null and relId != ''">
  84. and t.rel_id= #{relId}
  85. </if>
  86. <if test="storeId !=null and storeId != ''">
  87. and t.store_id= #{storeId}
  88. </if>
  89. <if test="bId !=null and bId != ''">
  90. and t.b_id= #{bId}
  91. </if>
  92. <if test="orgId !=null and orgId != ''">
  93. and t.org_id= #{orgId}
  94. </if>
  95. <if test="staffId !=null and staffId != ''">
  96. and t.staff_id= #{staffId}
  97. </if>
  98. <if test="relCd !=null and relCd != ''">
  99. and t.rel_cd= #{relCd}
  100. </if>
  101. <if test="page != -1 and page != null ">
  102. limit #{page}, #{row}
  103. </if>
  104. </select>
  105. <!-- 修改组织员工关系信息 add by wuxw 2018-07-03 -->
  106. <update id="updateOrgStaffRelInfoInstance" parameterType="Map">
  107. update u_org_staff_rel t set t.status_cd = #{statusCd}
  108. <if test="newBId != null and newBId != ''">
  109. ,t.b_id = #{newBId}
  110. </if>
  111. <if test="storeId !=null and storeId != ''">
  112. , t.store_id= #{storeId}
  113. </if>
  114. <if test="orgId !=null and orgId != ''">
  115. , t.org_id= #{orgId}
  116. </if>
  117. <if test="staffId !=null and staffId != ''">
  118. , t.staff_id= #{staffId}
  119. </if>
  120. <if test="relCd !=null and relCd != ''">
  121. , t.rel_cd= #{relCd}
  122. </if>
  123. where 1=1
  124. <if test="relId !=null and relId != ''">
  125. and t.rel_id= #{relId}
  126. </if>
  127. <if test="bId !=null and bId != ''">
  128. and t.b_id= #{bId}
  129. </if>
  130. </update>
  131. <!-- 查询组织员工关系数量 add by wuxw 2018-07-03 -->
  132. <select id="queryOrgStaffRelsCount" parameterType="Map" resultType="Map">
  133. select count(1) count
  134. from u_org_staff_rel t,u_org uo
  135. where t.org_id = uo.org_id
  136. and uo.status_cd = '0'
  137. <if test="relId !=null and relId != ''">
  138. and t.rel_id= #{relId}
  139. </if>
  140. <if test="statusCd !=null and statusCd != ''">
  141. and t.status_cd= #{statusCd}
  142. </if>
  143. <if test="storeId !=null and storeId != ''">
  144. and t.store_id= #{storeId}
  145. </if>
  146. <if test="bId !=null and bId != ''">
  147. and t.b_id= #{bId}
  148. </if>
  149. <if test="orgId !=null and orgId != ''">
  150. and t.org_id= #{orgId}
  151. </if>
  152. <if test="staffId !=null and staffId != ''">
  153. and t.staff_id= #{staffId}
  154. </if>
  155. <if test="relCd !=null and relCd != ''">
  156. and t.rel_cd= #{relCd}
  157. </if>
  158. </select>
  159. <!-- 根据员工ID查询部门,公司信息 add by zc 2020-02-17 -->
  160. <select id="queryOrgInfoByStaffIds" parameterType="Map" resultType="Map">
  161. select
  162. t.rel_id relId,t.org_id departmentId,t.staff_id staffId,t.store_id storeId,u.org_name departmentName,
  163. u.parent_org_id companyId,o.org_name companyName,o.org_id companyId
  164. from
  165. u_org_staff_rel t
  166. inner join u_org u on t.org_id = u.org_id
  167. inner join u_org o on u.parent_org_id = o.org_id
  168. WHERE 1 = 1
  169. <if test="staffIds !=null">
  170. and t.staff_id in
  171. <foreach collection="staffIds" item="item" open="(" close=")" separator=",">
  172. #{item}
  173. </foreach>
  174. </if>
  175. <if test="staffId !=null and staffId !=''">
  176. and t.staff_id =#{staffId}
  177. </if>
  178. </select>
  179. </mapper>