CompanyWxClientMapper.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  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="com.fs.company.mapper.CompanyWxClientMapper">
  6. <resultMap type="CompanyWxClient" id="CompanyWxClientResult">
  7. <result property="id" column="id" />
  8. <result property="roboticWxId" column="robotic_wx_id" />
  9. <result property="nickName" column="nick_name" />
  10. <result property="avatar" column="avatar" />
  11. <result property="phone" column="phone" />
  12. <result property="wxNo" column="wx_no" />
  13. <result property="isAdd" column="is_add" />
  14. <result property="addTime" column="add_time" />
  15. <result property="remark" column="remark" />
  16. <result property="createTime" column="create_time" />
  17. </resultMap>
  18. <sql id="selectCompanyWxClientVo">
  19. select a.* from company_wx_client a
  20. </sql>
  21. <select id="selectCompanyWxClientList" resultType="com.fs.company.domain.CompanyWxClient">
  22. select a.*,b.wx_nick_name,c.name as dialogName,robotic.name roboticName from company_wx_client a
  23. inner join company_voice_robotic_wx wx on a.robotic_wx_id = wx.id
  24. inner join company_wx_account b on wx.account_id = b.id
  25. inner join company_wx_dialog c on a.dialog_id = c.id
  26. inner join company_voice_robotic robotic on a.robotic_id = robotic.id
  27. <where>
  28. <if test="roboticId != null "> and a.robotic_id = #{roboticId}</if>
  29. <if test="roboticWxId != null "> and b.id = #{roboticWxId}</if>
  30. <if test="customerId != null "> and a.customer_id = #{customerId}</if>
  31. <if test="dialogId != null "> and a.dialog_id = #{dialogId}</if>
  32. <if test="nickName != null and nickName != ''"> and a.nick_name = #{nickName}</if>
  33. <if test="avatar != null and avatar != ''"> and a.avatar = #{avatar}</if>
  34. <if test="phone != null and phone != ''"> and a.phone = #{phone}</if>
  35. <if test="wxNo != null and wxNo != ''"> and a.wx_no = #{wxNo}</if>
  36. <if test="isAdd != null "> and a.is_add = #{isAdd}</if>
  37. <if test="addTime != null "> and a.add_time = #{addTime}</if>
  38. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  39. and date_format(a.add_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')
  40. </if>
  41. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  42. AND date_format(a.add_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
  43. </if>
  44. </where>
  45. </select>
  46. <select id="selectCompanyWxClientListCompany" resultType="com.fs.company.domain.CompanyWxClient">
  47. select a.*,b.wx_nick_name,c.name as dialogName,robotic.name roboticName from company_wx_client a
  48. inner join company_voice_robotic_wx wx on a.robotic_wx_id = wx.id
  49. inner join company_wx_account b on wx.account_id = b.id
  50. inner join company_user u on b.company_user_id = u.user_id
  51. inner join company_dept d on u.dept_id = d.dept_id
  52. inner join company_wx_dialog c on a.dialog_id = c.id
  53. inner join company_voice_robotic robotic on a.robotic_id = robotic.id
  54. <where>
  55. <if test="companyId != null"> and b.company_id = #{companyId}</if>
  56. <if test="isWeCom != null"> and a.is_we_com = #{isWeCom}</if>
  57. <if test="roboticId != null "> and a.robotic_id = #{roboticId}</if>
  58. <if test="roboticWxId != null "> and b.id = #{roboticWxId}</if>
  59. <if test="customerId != null "> and a.customer_id = #{customerId}</if>
  60. <if test="dialogId != null "> and a.dialog_id = #{dialogId}</if>
  61. <if test="nickName != null and nickName != ''"> and a.nick_name = #{nickName}</if>
  62. <if test="avatar != null and avatar != ''"> and a.avatar = #{avatar}</if>
  63. <if test="phone != null and phone != ''"> and a.phone = #{phone}</if>
  64. <if test="wxNo != null and wxNo != ''"> and a.wx_no = #{wxNo}</if>
  65. <if test="isAdd != null "> and a.is_add = #{isAdd}</if>
  66. <if test="addTime != null "> and a.add_time = #{addTime}</if>
  67. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  68. and date_format(a.add_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')
  69. </if>
  70. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  71. AND date_format(a.add_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
  72. </if>
  73. ${params.dataScope}
  74. </where>
  75. </select>
  76. <select id="selectCompanyWxClientById" parameterType="Long" resultMap="CompanyWxClientResult">
  77. <include refid="selectCompanyWxClientVo"/>
  78. where id = #{id}
  79. </select>
  80. <insert id="insertCompanyWxClient" parameterType="CompanyWxClient" useGeneratedKeys="true" keyProperty="id">
  81. insert into company_wx_client
  82. <trim prefix="(" suffix=")" suffixOverrides=",">
  83. <if test="roboticWxId != null">robotic_wx_id,</if>
  84. <if test="nickName != null">nick_name,</if>
  85. <if test="avatar != null">avatar,</if>
  86. <if test="phone != null">phone,</if>
  87. <if test="wxNo != null">wx_no,</if>
  88. <if test="isAdd != null">is_add,</if>
  89. <if test="addTime != null">add_time,</if>
  90. <if test="remark != null">remark,</if>
  91. <if test="createTime != null">create_time,</if>
  92. </trim>
  93. <trim prefix="values (" suffix=")" suffixOverrides=",">
  94. <if test="roboticWxId != null">#{roboticWxId},</if>
  95. <if test="nickName != null">#{nickName},</if>
  96. <if test="avatar != null">#{avatar},</if>
  97. <if test="phone != null">#{phone},</if>
  98. <if test="wxNo != null">#{wxNo},</if>
  99. <if test="isAdd != null">#{isAdd},</if>
  100. <if test="addTime != null">#{addTime},</if>
  101. <if test="remark != null">#{remark},</if>
  102. <if test="createTime != null">#{createTime},</if>
  103. </trim>
  104. </insert>
  105. <update id="updateCompanyWxClient" parameterType="CompanyWxClient">
  106. update company_wx_client
  107. <trim prefix="SET" suffixOverrides=",">
  108. <if test="roboticWxId != null">robotic_wx_id = #{roboticWxId},</if>
  109. <if test="nickName != null">nick_name = #{nickName},</if>
  110. <if test="avatar != null">avatar = #{avatar},</if>
  111. <if test="phone != null">phone = #{phone},</if>
  112. <if test="wxNo != null">wx_no = #{wxNo},</if>
  113. <if test="isAdd != null">is_add = #{isAdd},</if>
  114. <if test="addTime != null">add_time = #{addTime},</if>
  115. <if test="remark != null">remark = #{remark},</if>
  116. <if test="createTime != null">create_time = #{createTime},</if>
  117. <if test="dialogId != null">dialog_id = #{dialogId},</if>
  118. </trim>
  119. where id = #{id}
  120. </update>
  121. <delete id="deleteCompanyWxClientById" parameterType="Long">
  122. delete from company_wx_client where id = #{id}
  123. </delete>
  124. <delete id="deleteCompanyWxClientByIds" parameterType="String">
  125. delete from company_wx_client where id in
  126. <foreach item="id" collection="array" open="(" separator="," close=")">
  127. #{id}
  128. </foreach>
  129. </delete>
  130. <select id="toDayAddWxAccountList" resultType="com.fs.company.domain.CompanyWxClient">
  131. select a.*,b.wx_nick_name,c.name as dialogName,c.template_details,d.name roboticName from company_wx_client a
  132. inner join company_voice_robotic_wx wx on a.robotic_wx_id = wx.id
  133. inner join company_wx_account b on wx.account_id = b.id
  134. inner join company_wx_dialog c on a.dialog_id = c.id
  135. inner join company_voice_robotic d on a.robotic_id = d.id
  136. where b.id = #{accountId} and b.company_user_id = #{companyId} and a.is_add = #{addType}
  137. </select>
  138. <select id="selectCompanyByAccountId" resultType="com.fs.company.domain.CompanyUser">
  139. select c.* from company_voice_robotic_wx a
  140. inner join company_wx_account b on a.account_id = b.id
  141. inner join company_user c on b.company_user_id = c.user_id
  142. where a.id = #{wxId}
  143. </select>
  144. <select id="listCompanyIds" resultType="com.fs.company.domain.CompanyWxClient">
  145. select a.*,b.company_user_id from
  146. company_wx_client a
  147. inner join company_wx_account b on a.account_id = b.id
  148. where b.company_user_id in <foreach collection="ids" open="(" separator="," close=")" item="item">#{item}</foreach>
  149. </select>
  150. <select id="getAddWxList" resultType="com.fs.company.domain.CompanyWxClient">
  151. SELECT * FROM company_wx_client where is_add = 0 and account_id is not null
  152. <if test="accountIdList != null and !accountIdList.isEmpty()">
  153. and account_id in <foreach collection="accountIdList" open="(" separator="," close=")" item="item">#{item}</foreach>
  154. </if>
  155. <if test="isWeCom != null">
  156. and is_we_com = #{isWeCom}
  157. </if>
  158. group by account_id
  159. </select>
  160. <select id="getQwAddWxList" resultType="com.fs.company.domain.CompanyWxClient">
  161. SELECT * FROM company_wx_client where is_add = 2 and account_id is not null
  162. <if test="accountIdList != null and !accountIdList.isEmpty()">
  163. and account_id in <foreach collection="accountIdList" open="(" separator="," close=")" item="item">#{item}</foreach>
  164. </if>
  165. <if test="isWeCom != null">
  166. and is_we_com = #{isWeCom}
  167. </if>
  168. group by account_id
  169. </select>
  170. <select id="getAddWxList4Workflow" resultType="com.fs.company.vo.CompanyWxClient4WorkFlowVO">
  171. SELECT t1.*,t3.workflow_instance_id,t3.current_node_key,t3.current_node_name,t3.current_node_type FROM company_wx_client t1
  172. inner join company_voice_robotic_business t2 on t1.id = t2.wx_client_id and t1.robotic_id = t2.robotic_id
  173. inner join company_ai_workflow_exec t3 on t3.business_key = t2.id
  174. where t1.is_add = 0 and t1.account_id is not null and t1.is_we_com = 1
  175. and t3.current_node_type = #{execNodeType} And t3.status = #{execStatus}
  176. <if test="accountIdList != null and !accountIdList.isEmpty()">
  177. and t1.account_id in <foreach collection="accountIdList" open="(" separator="," close=")" item="item">#{item}</foreach>
  178. </if>
  179. group by t1.account_id
  180. </select>
  181. <select id="getQwAddWxList4Workflow" resultType="com.fs.company.vo.CompanyWxClient4WorkFlowVO">
  182. SELECT t1.*,t3.workflow_instance_id,t3.current_node_key,t3.current_node_name,t3.current_node_type FROM company_wx_client t1
  183. inner join company_voice_robotic_business t2 on t1.id = t2.wx_client_id and t1.robotic_id = t2.robotic_id
  184. inner join company_ai_workflow_exec t3 on t3.business_key = t2.id
  185. where t1.is_add = 0 and t1.account_id is not null and t1.is_we_com = 2
  186. and t3.current_node_type = #{execNodeType} And t3.status = #{execStatus}
  187. <if test="accountIdList != null and !accountIdList.isEmpty()">
  188. and t1.account_id in <foreach collection="accountIdList" open="(" separator="," close=")" item="item">#{item}</foreach>
  189. </if>
  190. group by t1.account_id
  191. </select>
  192. <select id="selectWx" resultType="com.fs.company.domain.CompanyWxClient">
  193. select * from company_wx_client where account_id = #{accountId} and wx_v3 = #{v3}
  194. </select>
  195. <select id="selectListByRoboticId" resultType="com.fs.company.domain.CompanyWxClient">
  196. select * from company_wx_client where robotic_id = #{roboticId}
  197. </select>
  198. <select id="selectOneByRoboticIdAndUserId" resultType="com.fs.company.domain.CompanyWxClient">
  199. select * from company_wx_client
  200. where 1=1
  201. <if test="roboticId != null"> and robotic_id = #{roboticId} </if>
  202. <if test="customerId != null"> and customer_id = #{customerId} </if>
  203. </select>
  204. <select id="getWxClientInfoByCustomerId" resultType="com.fs.company.domain.CompanyWxClient">
  205. select * from company_wx_client
  206. where 1=1
  207. <if test="customerId != null"> and customer_id = #{customerId} </if>
  208. </select>
  209. </mapper>