BizHousingFundConfirmMapper.xml 4.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="cn.ezhizao.project.business.housingFund.mapper.BizHousingFundConfirmMapper">
  4. <!-- 基础的返回map 多表复杂的 自行组合 -->
  5. <resultMap id="BaseResultMap" type="cn.ezhizao.project.business.housingFund.domain.BizHousingFundConfirm">
  6. <id column="id" jdbcType="BIGINT" property="id"/>
  7. <result column="id" jdbcType="BIGINT" property="id"/>
  8. <result column="company_id" jdbcType="BIGINT" property="companyId"/>
  9. </resultMap>
  10. <!--带条件的List查询-->
  11. <select id="getList" resultMap="BaseResultMap">
  12. <include refid="getListSql"/>
  13. </select>
  14. <!--带条件的List查询 数据总条数-->
  15. <select id="getTotal" resultType="java.lang.Integer">
  16. SELECT COUNT(1) FROM (<include refid="getListSql"/>) AS C
  17. </select>
  18. <sql id="getListSql">
  19. SELECT t1.*, t2.name as company_name,
  20. (select concat(frtd.year, '-', frtd.month) from biz_housing_fund_confirm_detail frtd where
  21. frtd.housing_fund_confirm_id = t1.id order by year desc, month desc limit 1) currentDate, t2.tax_type,
  22. t3.account_name as from_company_name
  23. FROM biz_housing_fund_confirm t1
  24. left join biz_company t2 on t2.id = t1.company_id
  25. left join biz_tenant t3 on t3.id = t1.tenant_id
  26. <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
  27. t1.deleted = 0 AND
  28. <if test="id != null ">
  29. t1.id = #{id} AND
  30. </if>
  31. <if test="companyId != null ">
  32. t1.company_id = #{companyId} AND
  33. </if>
  34. <if test="accountSetsId != null ">
  35. t1.account_sets_id = #{accountSetsId} AND
  36. </if>
  37. <if test="keyword != null and keyword != ''">
  38. (t2.name like concat('%', #{keyword}, '%') or t2.code like concat('%', #{keyword}, '%')) AND
  39. </if>
  40. <if test="taxType != null and taxType != ''">
  41. t2.tax_type = #{taxType} AND
  42. </if>
  43. <if test="fromCompanyName != null and fromCompanyName != ''">
  44. (t3.account_name like concat('%', #{fromCompanyName}, '%')) AND
  45. </if>
  46. <if test="currentEmployeeId != null ">
  47. t1.current_employee_id = #{currentEmployeeId} AND
  48. </if>
  49. <if test="employeeIds != null and employeeIds != '' ">
  50. t1.employee_ids = #{employeeIds} AND
  51. </if>
  52. <if test="createTime != null ">
  53. t1.create_time = #{createTime} AND
  54. </if>
  55. <if test="creatorId != null ">
  56. t1.creator_id = #{creatorId} AND
  57. </if>
  58. <if test="updateTime != null ">
  59. t1.update_time = #{updateTime} AND
  60. </if>
  61. <if test="updaterId != null ">
  62. t1.updater_id = #{updaterId} AND
  63. </if>
  64. <if test="deleted != null ">
  65. t1.deleted = #{deleted} AND
  66. </if>
  67. <if test="version != null ">
  68. t1.version = #{version} AND
  69. </if>
  70. <if test="month != null and year != null">
  71. <if test="tenantId != null">
  72. exists (select 1 from biz_entrust eb
  73. where eb.deleted = 0
  74. and (eb.to_tenant_id = #{tenantId} or eb.from_tenant_id = #{tenantId})
  75. and date_format(eb.current_month, '%Y%m') = concat(#{year}, #{month})
  76. and eb.work_order_id = t1.work_order_id
  77. ) AND
  78. </if>
  79. <if test="status != null and status != 0">
  80. exists (select 1 from biz_housing_fund_confirm_detail fsd where fsd.biz_housing_fund_confirm_id = t1.id and
  81. fsd.month = #{month} and fsd.year = #{year} and fsd.status = #{status}) AND
  82. </if>
  83. <if test="status != null and status == 0">
  84. not exists (select 1 from biz_housing_fund_confirm_detail fsd where fsd.biz_housing_fund_confirm_id = t1.id and
  85. fsd.month = #{month} and fsd.year = #{year}) AND
  86. </if>
  87. </if>
  88. </trim>
  89. </sql>
  90. </mapper>