BizArchiveInputTempMapper.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  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="cn.ezhizao.project.business.upgrade.mapper.BizArchiveInputTempMapper">
  6. <resultMap type="cn.ezhizao.project.business.upgrade.domain.BizArchiveInputUpdate" id="BizArchiveInputResult">
  7. <id column="id" property="id"/>
  8. <result column="source_id" property="sourceId"/>
  9. <result column="referrer_data_source" property="referrerDataSource"/>
  10. <association property="sourceName"
  11. column="{ source_id = source_id, referrer_data_source = referrer_data_source }"
  12. select="getSourceName"/>
  13. <association property="alterNumber" column="{ id = id, from_id = from_id }" select="getAlterNumber"/>
  14. </resultMap>
  15. <resultMap type="cn.ezhizao.project.business.upgrade.domain.BizArchiveInputUpdate" id="BizArchiveInputDetailResult">
  16. <id column="id" property="id"/>
  17. <collection property="details" select="getdetails" column="id" />
  18. </resultMap>
  19. <select id="getdetails" resultMap="BizArchiveInputDetailResult">
  20. select *
  21. from biz_archive_input_detail_update
  22. where contract_id = #{id}
  23. </select>
  24. <select id="selectByUpgradeId" parameterType="cn.ezhizao.project.business.upgrade.domain.BizArchiveInputUpdate" resultType="cn.ezhizao.project.business.order.domain.BizArchiveInput">
  25. select * from biz_archive_input_update where tenant_id = #{tenantId} and deleted = 0
  26. </select>
  27. <select id="selectBatchIds" resultMap="BizArchiveInputDetailResult">
  28. select * from biz_archive_input_update where id in
  29. <foreach item="id" index="index" collection="coll" open="(" separator="," close=")">
  30. #{id}
  31. </foreach>
  32. </select>
  33. <select id="getSourceName" resultType="java.lang.String">
  34. <if test="referrer_data_source == null">
  35. select '' as name
  36. </if>
  37. <if test="referrer_data_source == 'company'">
  38. select name from biz_company where biz_company.id = #{source_id}
  39. </if>
  40. <if test="referrer_data_source == 'employee'">
  41. select nick_name from sys_user where sys_user.user_id = #{source_id}
  42. </if>
  43. <if test="referrer_data_source == 'channel'">
  44. select name from biz_channel where biz_channel.id = #{source_id}
  45. </if>
  46. <if test="referrer_data_source == ''">
  47. select '' as name
  48. </if>
  49. </select>
  50. <select id="getAlterNumber" resultType="java.lang.Integer">
  51. select count(1) from biz_archive_input_update t where t.deleted = 0
  52. <if test="from_id == 0">
  53. and t.from_id = #{id}
  54. </if>
  55. <if test="from_id != 0">
  56. and t.from_id = #{from_id} or t.id = #{from_id}
  57. </if>
  58. </select>
  59. <select id="getList" parameterType="InputVo" resultMap="BizArchiveInputResult">
  60. SELECT
  61. t1.*,
  62. t2.name as company_name,
  63. t2.social_credit_code as social_credit_code,
  64. t3.nick_name as signer_name,
  65. t4.title as source_category_name,
  66. t4.referrer_data_source
  67. FROM biz_archive_input_update t1
  68. left join biz_company t2 on t2.id = t1.company_id
  69. left join sys_user t3 on t3.user_id = t1.signer_id
  70. left join biz_source t4 on t4.id = t1.source_category_id
  71. <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
  72. t1.deleted = 0
  73. <if test="fromId != null">AND (t1.from_id = #{fromId} or t1.id = #{fromId})</if>
  74. <if test="id != null and id != ''">AND t1.id = #{id}</if>
  75. <if test="companyName != null and companyName != ''">AND t2.name like concat("%", #{companyName}, "%")</if>
  76. <if test="archiveTypeId != null">and archive_type_id = #{archiveTypeId}</if>
  77. <if test="companyId != null and companyId != ''">AND t1.company_id = #{companyId}</if>
  78. <if test="archiveCode != null and archiveCode != ''">AND t1.archive_code = #{archiveCode}</if>
  79. <if test="startMonth != null ">AND t1.start_month = #{startMonth}</if>
  80. <if test="endMonth != null ">AND t1.end_month = #{endMonth}</if>
  81. <if test="proofUrl != null and proofUrl != ''">AND t1.proof_url = #{proofUrl}</if>
  82. <if test="contractNo != null and contractNo != ''">AND t1.contract_no = #{contractNo}</if>
  83. <if test="formDate != null ">AND t1.form_date = #{formDate}</if>
  84. <if test="amount != null ">AND t1.amount = #{amount}</if>
  85. <if test="verifyStatus != null ">AND t1.verify_status = #{verifyStatus}</if>
  86. <if test="contractType != null ">AND t1.contract_type = #{contractType}</if>
  87. <if test="serviceType != null ">AND t1.service_type = #{serviceType}</if>
  88. <if test="outputDate != null ">AND t1.output_date = #{outputDate}</if>
  89. <if test="monthNum != null ">AND t1.month_num = #{monthNum}</if>
  90. <if test="companyName != null and companyName != '' ">AND t2.name like concat('%', #{companyName}, '%')</if>
  91. <if test="verifyRemark != null and verifyRemark != ''">AND t1.verify_remark = #{verifyRemark}</if>
  92. <if test="tenantId != null">AND t1.tenant_id = #{tenantId}</if>
  93. <if test="isKeepAccount != null">AND <if test="isKeepAccount == 0">not</if> exists (select 1 from
  94. biz_archive_input_update_detail t5 where t5.deleted = 0 and t5.contract_id = t1.id and t5.task_type_id = 1)
  95. </if>
  96. <if test="isSocialSecurity != null">AND <if test="isSocialSecurity == 0">not</if> exists (select 1 from
  97. biz_archive_input_update_detail t5 where t5.deleted = 0 and t5.contract_id = t1.id and t5.task_type_id = 2)
  98. </if>
  99. <if test="isHousingFund != null">AND <if test="isHousingFund == 0">not</if> exists (select 1 from
  100. biz_archive_input_update_detail t5 where t5.deleted = 0 and t5.contract_id = t1.id and t5.task_type_id = 3)
  101. </if>
  102. <if test="isReturnTax != null">AND <if test="isReturnTax == 0">not</if> exists (select 1 from
  103. biz_archive_input_update_detail t5 where t5.deleted = 0 and t5.contract_id = t1.id and t5.task_type_id = 4)
  104. </if>
  105. <if test="isRegister != null">AND <if test="isRegister == 0">not</if> exists (select 1 from
  106. biz_archive_input_update_detail t5 where t5.deleted = 0 and t5.contract_id = t1.id and t5.task_type_id = 5)
  107. </if>
  108. <if test="isAlter != null">AND <if test="isAlter == 0">not</if> exists (select 1 from
  109. biz_archive_input_update_detail t5 where t5.deleted = 0 and t5.contract_id = t1.id and t5.task_type_id = 6)
  110. </if>
  111. <if test="isLogout != null">AND <if test="isLogout == 0">not</if> exists (select 1 from
  112. biz_archive_input_update_detail t5 where t5.deleted = 0 and t5.contract_id = t1.id and t5.task_type_id = 7)
  113. </if>
  114. <if test="isQualified != null">AND <if test="isQualified == 0">not</if> exists (select 1 from
  115. biz_archive_input_update_detail t5 where t5.deleted = 0 and t5.contract_id = t1.id and t5.task_type_id = 8)
  116. </if>
  117. <if test="isOther != null">AND <if test="isOther == 0">not</if> exists (select 1 from
  118. biz_archive_input_update_detail t5 where t5.deleted = 0 and t5.contract_id = t1.id and t5.task_type_id = 9)
  119. </if>
  120. </trim>
  121. </select>
  122. <select id="getListByInput" parameterType="InputVo" resultMap="BizArchiveInputResult">
  123. SELECT
  124. t1.*,
  125. t2.name as company_name,
  126. t2.customer_label_id as customerLabelId,
  127. t5.lable as customerLabelName,
  128. t2.social_credit_code as social_credit_code,
  129. t3.nick_name as signer_name,
  130. t4.title as source_category_name,
  131. t4.referrer_data_source
  132. FROM biz_archive_input_update t1
  133. left join biz_company t2 on t2.id = t1.company_id
  134. left join sys_user t3 on t3.user_id = t1.signer_id
  135. left join biz_source t4 on t4.id = t1.source_category_id
  136. left join biz_lable t5 on t5.id = t2.customer_label_id
  137. <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
  138. t1.deleted = 0
  139. <if test="fromId != null">AND (t1.from_id = #{fromId} or t1.id = #{fromId})</if>
  140. <if test="id != null and id != ''">AND t1.id = #{id}</if>
  141. <if test="contractNo!=null and contractNo != '' ">AND t1.contract_no like concat("%",#{contractNo}, "%")</if>
  142. <if test="companyName != null and companyName != ''">AND t2.name like concat("%", #{companyName}, "%")</if>
  143. <if test="archiveTypeId != null">and archive_type_id = #{archiveTypeId}</if>
  144. <if test="companyId != null and companyId != ''">AND t1.company_id = #{companyId}</if>
  145. <if test="archiveCode != null and archiveCode != ''">AND t1.archive_code = #{archiveCode}</if>
  146. <if test="startMonth != null ">AND t1.start_month = #{startMonth}</if>
  147. <if test="endMonth != null ">AND t1.end_month = #{endMonth}</if>
  148. <if test="proofUrl != null and proofUrl != ''">AND t1.proof_url = #{proofUrl}</if>
  149. <if test="boss != null and boss != ''">AND t1.boss like concat("%",#{boss}, "%")</if>
  150. <if test="formDate!= null and formDate.size() ">
  151. AND (
  152. DATE_FORMAT(t1.form_date,'%Y-%m-%d') &gt;= #{formDate[0]}
  153. AND
  154. DATE_FORMAT(t1.form_date,'%Y-%m-%d') &lt;= #{formDate[1]}
  155. )
  156. </if>
  157. <if test="amount != null ">AND t1.amount = #{amount}</if>
  158. <if test="verifyStatus != null ">AND t1.verify_status = #{verifyStatus}</if>
  159. <if test="contractType != null ">AND t1.contract_type = #{contractType}</if>
  160. <if test="serviceType != null ">AND t1.service_type = #{serviceType}</if>
  161. <if test="outputDate != null ">AND t1.output_date = #{outputDate}</if>
  162. <if test="monthNum != null ">AND t1.month_num = #{monthNum}</if>
  163. <if test="companyName != null and companyName != '' ">AND t2.name like concat('%', #{companyName}, '%')</if>
  164. <if test="verifyRemark != null and verifyRemark != ''">AND t1.verify_remark = #{verifyRemark}</if>
  165. <if test="tenantId != null">AND t1.tenant_id = #{tenantId}</if>
  166. <if test="isKeepAccount != null">AND <if test="isKeepAccount == 0">not</if> exists (select 1 from
  167. biz_archive_input_update_detail t5 where t5.deleted = 0 and t5.contract_id = t1.id and t5.task_type_id = 1)
  168. </if>
  169. <if test="isSocialSecurity != null">AND <if test="isSocialSecurity == 0">not</if> exists (select 1 from
  170. biz_archive_input_update_detail t5 where t5.deleted = 0 and t5.contract_id = t1.id and t5.task_type_id = 2)
  171. </if>
  172. <if test="isHousingFund != null">AND <if test="isHousingFund == 0">not</if> exists (select 1 from
  173. biz_archive_input_update_detail t5 where t5.deleted = 0 and t5.contract_id = t1.id and t5.task_type_id = 3)
  174. </if>
  175. <if test="isReturnTax != null">AND <if test="isReturnTax == 0">not</if> exists (select 1 from
  176. biz_archive_input_update_detail t5 where t5.deleted = 0 and t5.contract_id = t1.id and t5.task_type_id = 4)
  177. </if>
  178. <if test="isRegister != null">AND <if test="isRegister == 0">not</if> exists (select 1 from
  179. biz_archive_input_update_detail t5 where t5.deleted = 0 and t5.contract_id = t1.id and t5.task_type_id = 5)
  180. </if>
  181. <if test="isAlter != null">AND <if test="isAlter == 0">not</if> exists (select 1 from
  182. biz_archive_input_update_detail t5 where t5.deleted = 0 and t5.contract_id = t1.id and t5.task_type_id = 6)
  183. </if>
  184. <if test="isLogout != null">AND <if test="isLogout == 0">not</if> exists (select 1 from
  185. biz_archive_input_update_detail t5 where t5.deleted = 0 and t5.contract_id = t1.id and t5.task_type_id = 7)
  186. </if>
  187. <if test="isQualified != null">AND <if test="isQualified == 0">not</if> exists (select 1 from
  188. biz_archive_input_update_detail t5 where t5.deleted = 0 and t5.contract_id = t1.id and t5.task_type_id = 8)
  189. </if>
  190. <if test="isOther != null">AND <if test="isOther == 0">not</if> exists (select 1 from
  191. biz_archive_input_update_detail t5 where t5.deleted = 0 and t5.contract_id = t1.id and t5.task_type_id = 9)
  192. </if>
  193. <if test="customerLabelId != null and customerLabelId.size() > 0">
  194. AND t2.customer_label_id IN
  195. <foreach collection="customerLabelId" index="index" item="item" separator="," open="(" close=")">
  196. #{item,jdbcType=BIGINT}
  197. </foreach>
  198. </if>
  199. </trim>
  200. </select>
  201. <update id="removeByIds">
  202. UPDATE biz_archive_input_update
  203. SET deleted=1
  204. WHERE id in
  205. <foreach collection="ids" item="id" index="index" open="(" separator="," close=")">
  206. #{id}
  207. </foreach>
  208. </update>
  209. <delete id="physicalDelete">
  210. DELETE FROM biz_archive_input_update
  211. <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
  212. <if test="id != null">
  213. id = #{id} AND
  214. </if>
  215. <!-- 删除条件为其他外键可以在这里加 -->
  216. </trim>
  217. </delete>
  218. </mapper>