TbBusinessMapper.xml 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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.pj.project.tb_business.TbBusinessMapper">
  4. <update id="unBindCar">
  5. update tb_business set card_no='',china_car_no='',business_car_id=null where id=#{id}
  6. </update>
  7. <!-- 查集合 - 根据条件(参数为空时代表忽略指定条件) [G] -->
  8. <select id="getList" resultType="com.pj.project.tb_business.TbBusiness">
  9. select * from tb_business
  10. <where>
  11. <if test=' this.has("id") '>and id = #{id}</if>
  12. <if test=' this.has("customerId") '>and customer_id = #{customerId}</if>
  13. <if test=' this.has("customerName") '>and customer_name like concat('%', #{customerName} ,'%')</if>
  14. <if test=' this.has("owner") '>and owner like concat('%', #{owner} ,'%')</if>
  15. <if test=' this.has("no") '>and no = #{no}</if>
  16. <if test=' this.has("cardNo") '>and card_no like concat('%', #{cardNo} ,'%')</if>
  17. <if test=' this.has("cardSize") '>and card_size = #{cardSize}</if>
  18. <if test=' this.has("netWeight") '>and net_weight = #{netWeight}</if>
  19. <if test=' this.has("goodsName") '>and goods_name = #{goodsName}</if>
  20. <if test=' this.has("goodsCode") '>and goods_code = #{goodsCode}</if>
  21. <if test=' this.has("driverName") '>and driver_name like concat('%', #{driverName} ,'%')</if>
  22. <if test=' this.has("driverId") '>and driver_id = #{driverId}</if>
  23. <if test=' this.has("driverPhone") '>and driver_phone = #{driverPhone}</if>
  24. <if test=' this.has("driverIdCard") '>and driver_id_card like concat('%', #{driverIdCard} ,'%')</if>
  25. <if test=' this.has("expectInDay") '>and expect_in_day = #{expectInDay}</if>
  26. <if test=' this.has("realInDay") '>and real_in_day = #{realInDay}</if>
  27. <if test=' this.has("realInTime") '>and real_in_time = #{realInTime}</if>
  28. <if test=' this.has("payStatus") '>and pay_status = #{payStatus}</if>
  29. <if test=' this.has("payTime") '>and pay_time = #{payTime}</if>
  30. <if test=' this.has("payType") '>and pay_type = #{payType}</if>
  31. <if test=' this.has("outDayTime") '>and out_day_time = #{outDayTime}</if>
  32. <if test=' this.has("partMoney") '>and part_money = #{partMoney}</if>
  33. <if test=' this.has("partTime") '>and part_time = #{partTime}</if>
  34. <if test=' this.has("createTime") '>and date_format(create_time,'%Y-%m-%d') = #{createTime}</if>
  35. <if test=' this.has("businessType") '>and business_type = #{businessType}</if>
  36. <if test=' this.has("businessCarId") '>and business_car_id = #{businessCarId}</if>
  37. <if test=' this.has("createByCustomerId") '>and create_by_customer_id = #{createByCustomerId}</if>
  38. <if test=' this.has("carNo") '>and (card_no like concat('%', #{carNo},'%') or china_car_no like concat('%', #{carNo},'%'))</if>
  39. <if test='adminConfirmInput !=null and adminConfirmInput>-1'>and admin_confirm_input = #{adminConfirmInput}</if>
  40. <if test='isCar==0'>
  41. and declare_no is not null
  42. </if>
  43. <if test='isCar==1'>
  44. and (declare_no is null or declare_no='')
  45. </if>
  46. <if test=' this.has("current") '>
  47. <if test=' current == 3 '>and real_in_time is not null and out_day_time is not null</if>
  48. <if test=' current == 2 '>and real_in_time is not null and out_day_time is null</if>
  49. <if test=' current == 1 '>and real_in_time is null and out_day_time is null</if>
  50. </if>
  51. </where>
  52. order by
  53. <choose>
  54. <when test='sortType == 1'>id desc</when>
  55. <when test='sortType == 2'>customer_id desc</when>
  56. <when test='sortType == 3'>customer_name desc</when>
  57. <when test='sortType == 4'>no desc</when>
  58. <when test='sortType == 5'>card_no desc</when>
  59. <when test='sortType == 6'>card_size desc</when>
  60. <when test='sortType == 7'>net_weight desc</when>
  61. <when test='sortType == 8'>goods_name desc</when>
  62. <when test='sortType == 9'>goods_code desc</when>
  63. <when test='sortType == 10'>driver_name desc</when>
  64. <when test='sortType == 11'>driver_id desc</when>
  65. <when test='sortType == 12'>driver_phone desc</when>
  66. <when test='sortType == 13'>driver_id_card desc</when>
  67. <when test='sortType == 14'>expect_in_day desc</when>
  68. <when test='sortType == 15'>real_in_day desc</when>
  69. <when test='sortType == 16'>real_in_time desc</when>
  70. <when test='sortType == 17'>pay_status desc</when>
  71. <when test='sortType == 18'>pay_time desc</when>
  72. <when test='sortType == 19'>pay_type desc</when>
  73. <when test='sortType == 20'>out_day_time desc</when>
  74. <when test='sortType == 21'>part_money desc</when>
  75. <when test='sortType == 22'>part_time desc</when>
  76. <otherwise>id desc</otherwise>
  77. </choose>
  78. </select>
  79. <select id="getCarDisincleList" resultType="com.pj.project.tb_business.CarDisincle">
  80. SELECT
  81. a.id,
  82. b.id as businessCarId,
  83. a.`no`,a.operate_time,
  84. a.item_price,a.goods_name,a.admin_confirm_input,b.car_no,
  85. b.base_part_money,a.total_money,a.pay_money,a.create_time,
  86. b.real_in_time,b.real_out_time,b.car_no ,a.net_weight,a.card_size,a.pay_status,a.item_type_name
  87. from tb_business a,tb_business_car b
  88. WHERE a.business_car_id=b.id and (a.declare_no='' or a.declare_no is null)
  89. <if test="cardNo !='' and cardNo !=null">
  90. and b.car_no like concat('%',#{cardNo},'%')
  91. </if>
  92. <if test="no !='' and no !=null">
  93. and a.no like concat('%',#{no},'%')
  94. </if>
  95. <if test="adminConfirmInput !='-1'">
  96. and a.admin_confirm_input=#{adminConfirmInput}
  97. </if>
  98. <if test="customerId !=null and customerId !=''">
  99. and a.customer_id=#{customerId}
  100. </if>
  101. <if test="businessCarId !=null and businessCarId !=''">
  102. and a.business_car_id=#{businessCarId}
  103. </if>
  104. <if test="carNo !=null and carNo !=''">
  105. and b.car_no like concat ('%',#{carNo},'%')
  106. </if>
  107. ORDER BY a.create_time desc
  108. </select>
  109. <select id="checkCarBusinessType" resultType="java.lang.Integer">
  110. SELECT
  111. count(a.id)
  112. FROM
  113. tb_business_car a,
  114. tb_business b
  115. WHERE
  116. a.id = b.business_car_id
  117. AND a.car_no =#{carNo}
  118. and b.item_type_id=#{typeId}
  119. <if test="before==1">
  120. AND DATE_FORMAT( b.operate_time, '%Y-%m-%d %H:%i:%s' ) &lt; #{operateTime}
  121. </if>
  122. <if test="before==0">
  123. AND DATE_FORMAT( b.operate_time, '%Y-%m-%d %H:%i:%s' ) &gt; #{operateTime}
  124. </if>
  125. </select>
  126. <select id="checkCarBusinessTypeByTime" resultType="java.lang.Integer">
  127. SELECT
  128. count(b.id)
  129. FROM
  130. tb_business_car a,
  131. tb_business b
  132. WHERE
  133. a.id = b.business_car_id
  134. AND a.car_no =#{carNo}
  135. and b.item_type_id=#{typeId}
  136. AND DATE_FORMAT( b.operate_time, '%Y-%m-%d %H:%i:%s' ) &gt; #{timeStart}
  137. and DATE_FORMAT( b.operate_time, '%Y-%m-%d %H:%i:%s' ) &lt; #{timeEnd}
  138. <if test="businessId!=null and businessId !=''">
  139. and b.id !=#{businessId}
  140. </if>
  141. </select>
  142. <resultMap id="otherBusinessMap" type="com.pj.project.tb_business.TbBusiness">
  143. <result property="id" column="id"/>
  144. <result property="cardNo" column="card_no"/>
  145. <result property="chinaCarNo" column="china_car_no"/>
  146. <result property="no" column="no"/>
  147. <result property="createTime" column="create_time"/>
  148. <result property="customerName" column="customer_name"/>
  149. <result property="goodsName" column="goods_name"/>
  150. <result property="adminConfirmInput" column="admin_confirm_input"/>
  151. <result property="itemPrice" column="item_price"/>
  152. <result property="payMoney" column="pay_money"/>
  153. <result property="operateTime" column="operate_time"/>
  154. <collection property="items" ofType="com.pj.project.tb_item.TbItem" select="getItems" column="id"/>
  155. </resultMap>
  156. <select id="getOtherBusiness" resultType="com.pj.project.tb_business.TbBusiness">
  157. select * from tb_business
  158. <trim prefix="where" prefixOverrides="and||or">
  159. <if test="customerId !=null and customerId !=''">
  160. and customer_id=#{customerId}
  161. </if>
  162. <if test="carNo !=null and carNo !=''">
  163. and (card_no like concat('%',#{carNo},'%') or china_car_no like concat('%',#{carNo},'%'))
  164. </if>
  165. </trim>
  166. order by create_time desc
  167. </select>
  168. <select id="getItems" resultType="com.pj.project.tb_item.TbItem">
  169. select * from tb_item where business_id=#{id}
  170. </select>
  171. <select id="findOtherBusinessByCarId" resultType="com.pj.project.tb_business.TbBusiness">
  172. select distinct a.*
  173. from tb_business a,relation_business_car b
  174. where a.id=b.business_id
  175. and b.business_car_id=#{businessCarId}
  176. </select>
  177. </mapper>