SefCarCalculateInforMapper.xml 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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="com.jkcredit.invoice.mapper.calculateInfor.SelfCarCalculateInforMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.jkcredit.invoice.model.entity.Calculate.SelfCarCalculateInfor">
  6. <id column="id" property="id"/>
  7. <result column="customId" property="customId"/>
  8. <result column="companyNum" property="companyNum"/>
  9. <result column="tradeId" property="tradeId"/>
  10. <result column="fee" property="fee"/>
  11. <result column="calculateTime" property="calculateTime"/>
  12. <result column="ctype" property="ctype"/>
  13. <result column="invoiceMkTime" property="invoiceMkTime"/>
  14. <result column="companyReferencenum" property="companyReferencenum"/>
  15. <result column="companyName" property="companyName"/>
  16. <result column="companyLongName" property="companyLongName"/>
  17. </resultMap>
  18. <sql id="baseSql">
  19. id,
  20. customId,
  21. companyNum,
  22. etcNum,
  23. fee,
  24. calTime,
  25. invoiceMkTime,
  26. companyReferencenum,
  27. companyName,
  28. companyLongName
  29. </sql>
  30. <select id="selectAllByPage" resultMap="BaseResultMap">
  31. select
  32. <include refid="baseSql" />
  33. from t_SelfCalculateInfor
  34. where 1 = 1
  35. <if test="calculateInfor.customId != null and calculateInfor.customId != ''">
  36. and BINARY customId = #{calculateInfor.customId}
  37. </if>
  38. <if test="calculateInfor.companyReferencenum != null and calculateInfor.companyReferencenum != ''">
  39. and BINARY companyReferencenum =#{calculateInfor.companyReferencenum}
  40. </if>
  41. <if test="calculateInfor.companyName != null and calculateInfor.companyName != ''">
  42. and BINARY companyName LIKE CONCAT('%',#{calculateInfor.companyName},'%')
  43. </if>
  44. <if test="calculateInfor.companyLongName != null and calculateInfor.companyLongName != ''">
  45. and BINARY companyLongName LIKE CONCAT('%',#{calculateInfor.companyLongName},'%')
  46. </if>
  47. <if test="calculateInfor.etcNum != null and calculateInfor.etcNum != ''">
  48. and BINARY etcNum = #{calculateInfor.etcNum}
  49. </if>
  50. <if test="calculateInfor.calTime != null and calculateInfor.calTime != ''">
  51. and BINARY calTime BETWEEN #{calculateInfor.calTimeStart} and #{calculateInfor.calTimeEnd}
  52. </if>
  53. order by id DESC
  54. </select>
  55. <select id="selectByEtcAndTime" resultMap="BaseResultMap" parameterType="com.jkcredit.invoice.model.entity.Calculate.SelfCarCalculateInfor">
  56. select
  57. <include refid="baseSql" />
  58. from t_SelfCalculateInfor where calTime = #{calTime,jdbcType=VARCHAR} and BINARY etcNum = #{etcNum,jdbcType=VARCHAR}
  59. </select>
  60. <insert id="insert" parameterType="com.jkcredit.invoice.model.entity.Calculate.SelfCarCalculateInfor" >
  61. insert into t_SelfCalculateInfor (
  62. customId,
  63. companyNum,
  64. etcNum,
  65. fee,
  66. calTime,invoiceMkTime,companyReferencenum,companyName,companyLongName
  67. )
  68. values ( #{customId,jdbcType=VARCHAR}, #{companyNum,jdbcType=VARCHAR},
  69. #{etcNum,jdbcType=VARCHAR}, #{fee,jdbcType=DOUBLE},#{calTime,jdbcType=VARCHAR},#{invoiceMkTime,jdbcType=VARCHAR},#{companyReferencenum,jdbcType=VARCHAR},#{companyName,jdbcType=VARCHAR},#{companyLongName,jdbcType=VARCHAR}
  70. )
  71. </insert>
  72. <resultMap id="staticResultMap" type="java.util.Map">
  73. <result column="customId" property="customId"/>
  74. <result column="companyNum" property="companyNum"/>
  75. <result column="companyReferencenum" property="companyReferencenum"/>
  76. <result column="etcNum" property="etcNum"/>
  77. <result column="tradeIdNum" property="tradeIdNum"/>
  78. <result column="feeNum" property="feeNum"/>
  79. </resultMap>
  80. <select id="findSelfcarCalculateInfoSta" resultMap="staticResultMap">
  81. select k.*,
  82. (
  83. select count(1) from (select DISTINCT f.etcNum from t_SelfCalculateInfor f where f.companyNum = companyNum
  84. <if test="etcNum != null and etcNum != ''">
  85. and BINARY f.etcNum = #{etcNum}
  86. </if>
  87. <if test="calTime != null and calTime != ''">
  88. and f.calTime BETWEEN #{calTimeStart} and #{calTimeEnd}
  89. </if>
  90. ) g
  91. ) etcNum,
  92. (select count(1) from t_SellCarTrade t where t.companyNum = k.companyNum
  93. and t.cardId in (select DISTINCT f.etcNum from t_SelfCalculateInfor f where f.companyNum = k.companyNum
  94. <if test="etcNum != null and etcNum != ''">
  95. and BINARY f.etcNum = #{etcNum}
  96. </if>
  97. <if test="calTime != null and calTime != ''">
  98. and f.calTime BETWEEN #{calTimeStart} and #{calTimeEnd}
  99. </if>
  100. )
  101. <if test="calTime != null and calTime != ''">
  102. and t.exTime BETWEEN #{calTimeStart} and #{calTimeEnd}
  103. </if>
  104. ) tradeIdNum
  105. from (
  106. select
  107. customId,
  108. companyNum,
  109. companyReferencenum,
  110. count(1) feeNum
  111. from t_SelfCalculateInfor h
  112. <where>
  113. <if test="customId != null and customId != ''">
  114. and BINARY customId = #{customId}
  115. </if>
  116. <if test="companyReferencenum != null and companyReferencenum != ''">
  117. and BINARY companyReferencenum =#{companyReferencenum}
  118. </if>
  119. <if test="etcNum != null and etcNum != ''">
  120. and BINARY etcNum = #{etcNum}
  121. </if>
  122. <if test="calTime != null and calTime != ''">
  123. and BINARY calTime BETWEEN #{calTimeStart} and #{calTimeEnd}
  124. </if>
  125. </where>
  126. GROUP by customId,companyNum,companyReferencenum) k
  127. </select>
  128. <select id="selectEtcNum" resultMap="BaseResultMap">
  129. select
  130. <include refid="baseSql" />
  131. from t_SelfCalculateInfor
  132. </select>
  133. <select id="selectAllByPage" resultMap="BaseResultMap">
  134. select
  135. <include refid="baseSql" />
  136. from t_SelfCalculateInfor
  137. </select>
  138. </mapper>