CompanyVoiceRoboticBusinessMapper.xml 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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.CompanyVoiceRoboticBusinessMapper">
  6. <resultMap type="CompanyVoiceRoboticBusiness" id="CompanyVoiceRoboticBusinessResult">
  7. <result property="id" column="id" />
  8. <result property="roboticId" column="robotic_id" />
  9. <result property="calleeId" column="callee_id" />
  10. <result property="wxClientId" column="wx_client_id" />
  11. <result property="addWxDone" column="add_wx_done" />
  12. <result property="callPhoneDone" column="call_phone_done" />
  13. <result property="sendMsgDone" column="send_msg_done" />
  14. <result property="createTime" column="create_time" />
  15. <result property="updateTime" column="update_time" />
  16. </resultMap>
  17. <sql id="selectCompanyVoiceRoboticBusinessVo">
  18. select id, robotic_id, callee_id, wx_client_id, add_wx_done, call_phone_done, send_msg_done, create_time, update_time from company_voice_robotic_business
  19. </sql>
  20. <select id="selectCompanyVoiceRoboticBusinessList" parameterType="CompanyVoiceRoboticBusiness" resultMap="CompanyVoiceRoboticBusinessResult">
  21. <include refid="selectCompanyVoiceRoboticBusinessVo"/>
  22. <where>
  23. <if test="roboticId != null "> and robotic_id = #{roboticId}</if>
  24. <if test="calleeId != null "> and callee_id = #{calleeId}</if>
  25. <if test="wxClientId != null "> and wx_client_id = #{wxClientId}</if>
  26. <if test="addWxDone != null "> and add_wx_done = #{addWxDone}</if>
  27. <if test="callPhoneDone != null "> and call_phone_done = #{callPhoneDone}</if>
  28. <if test="sendMsgDone != null "> and send_msg_done = #{sendMsgDone}</if>
  29. </where>
  30. </select>
  31. <select id="selectCompanyVoiceRoboticBusinessById" parameterType="Long" resultMap="CompanyVoiceRoboticBusinessResult">
  32. <include refid="selectCompanyVoiceRoboticBusinessVo"/>
  33. where id = #{id}
  34. </select>
  35. <insert id="insertCompanyVoiceRoboticBusiness" parameterType="CompanyVoiceRoboticBusiness" useGeneratedKeys="true" keyProperty="id">
  36. insert into company_voice_robotic_business
  37. <trim prefix="(" suffix=")" suffixOverrides=",">
  38. <if test="roboticId != null">robotic_id,</if>
  39. <if test="calleeId != null">callee_id,</if>
  40. <if test="wxClientId != null">wx_client_id,</if>
  41. <if test="addWxDone != null">add_wx_done,</if>
  42. <if test="callPhoneDone != null">call_phone_done,</if>
  43. <if test="sendMsgDone != null">send_msg_done,</if>
  44. <if test="createTime != null">create_time,</if>
  45. <if test="updateTime != null">update_time,</if>
  46. </trim>
  47. <trim prefix="values (" suffix=")" suffixOverrides=",">
  48. <if test="roboticId != null">#{roboticId},</if>
  49. <if test="calleeId != null">#{calleeId},</if>
  50. <if test="wxClientId != null">#{wxClientId},</if>
  51. <if test="addWxDone != null">#{addWxDone},</if>
  52. <if test="callPhoneDone != null">#{callPhoneDone},</if>
  53. <if test="sendMsgDone != null">#{sendMsgDone},</if>
  54. <if test="createTime != null">#{createTime},</if>
  55. <if test="updateTime != null">#{updateTime},</if>
  56. </trim>
  57. </insert>
  58. <update id="updateCompanyVoiceRoboticBusiness" parameterType="CompanyVoiceRoboticBusiness">
  59. update company_voice_robotic_business
  60. <trim prefix="SET" suffixOverrides=",">
  61. <if test="roboticId != null">robotic_id = #{roboticId},</if>
  62. <if test="calleeId != null">callee_id = #{calleeId},</if>
  63. <if test="wxClientId != null">wx_client_id = #{wxClientId},</if>
  64. <if test="addWxDone != null">add_wx_done = #{addWxDone},</if>
  65. <if test="callPhoneDone != null">call_phone_done = #{callPhoneDone},</if>
  66. <if test="sendMsgDone != null">send_msg_done = #{sendMsgDone},</if>
  67. <if test="createTime != null">create_time = #{createTime},</if>
  68. <if test="updateTime != null">update_time = #{updateTime},</if>
  69. </trim>
  70. where id = #{id}
  71. </update>
  72. <delete id="deleteCompanyVoiceRoboticBusinessById" parameterType="Long">
  73. delete from company_voice_robotic_business where id = #{id}
  74. </delete>
  75. <delete id="deleteCompanyVoiceRoboticBusinessByIds" parameterType="String">
  76. delete from company_voice_robotic_business where id in
  77. <foreach item="id" collection="array" open="(" separator="," close=")">
  78. #{id}
  79. </foreach>
  80. </delete>
  81. <insert id="insertBatch" parameterType="java.util.List">
  82. INSERT INTO company_voice_robotic_business
  83. (robotic_id, callee_id, wx_client_id, add_wx_done, call_phone_done, send_msg_done, create_time, update_time)
  84. VALUES
  85. <foreach collection="list" item="item" index="index" separator=",">
  86. (
  87. #{item.roboticId},
  88. #{item.calleeId},
  89. #{item.wxClientId},
  90. #{item.addWxDone},
  91. #{item.callPhoneDone},
  92. #{item.sendMsgDone},
  93. #{item.createTime},
  94. #{item.updateTime}
  95. )
  96. </foreach>
  97. </insert>
  98. <update id="updateActionCount" >
  99. update company_voice_robotic_business
  100. <if test="actionType == 1">
  101. set add_wx_done = add_wx_done + 1
  102. </if>
  103. <if test="actionType == 2">
  104. set call_phone_done = call_phone_done + 1
  105. </if>
  106. <if test="actionType == 3">
  107. set send_msg_done = send_msg_done + 1
  108. </if>
  109. where
  110. robotic_id = #{roboticId}
  111. <if test="callerId != null">
  112. and callee_id = #{callerId}
  113. </if>
  114. <if test="wxClientId != null">
  115. and wx_client_id = #{wxClientId}
  116. </if>
  117. </update>
  118. <select id="selectCompanyVoiceRoboticBusinessByWorkflowInstanceId" resultType="CompanyVoiceRoboticBusiness">
  119. select
  120. t2.*
  121. from company_ai_workflow_exec t1
  122. INNER JOIN company_voice_robotic_business t2 on t1.business_key = t2.id
  123. where t1.workflow_instance_id = #{workflowInstanceId}
  124. </select>
  125. <select id="selectCalleesByBusinessId" resultType="CompanyVoiceRoboticCallees">
  126. SELECT t2.* FROM company_voice_robotic_business t1
  127. inner join company_voice_robotic_callees t2 on t1.callee_id = t2.id
  128. where t1.id = #{businessId}
  129. </select>
  130. <select id="selectUnfinishedTaskCountByRoboticId" resultType="Integer">
  131. SELECT
  132. count(*)
  133. FROM
  134. company_voice_robotic_business t1
  135. inner join company_ai_workflow_exec t2 on t1.id = t2.business_key
  136. where t1.robotic_id = #{roboticId} and t2.current_node_key != #{endNodeKey};
  137. </select>
  138. </mapper>