AppointmentConfirmOrderMapper.xml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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.start.tz.module.pressure2.dal.mysql.appointmentconfirmorder.AppointmentConfirmOrderMapper">
  4. <!--
  5. 一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
  6. 无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
  7. 代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
  8. 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
  9. -->
  10. <select id="selectByEquipIdAndCheckTypeBoiler"
  11. resultType="cn.start.tz.module.pressure2.dal.dataobject.appointmentconfirmorder.AppointmentConfirmOrderDO">
  12. SELECT DISTINCT
  13. aco.*
  14. FROM pressure_appointment_confirm_order aco
  15. LEFT JOIN PRESSURE2_BOILER_APPOINTMENT_CONFIRM_ORDER_ITEM acoi ON acoi.order_id = aco.id
  16. WHERE aco.deleted = 0
  17. AND acoi.deleted = 0
  18. AND acoi.equip_id = #{equipId}
  19. AND aco.check_type = #{checkType}
  20. ORDER BY aco.create_time DESC
  21. LIMIT 1
  22. </select>
  23. <select id="selectByEquipIdAndCheckTypePipe"
  24. resultType="cn.start.tz.module.pressure2.dal.dataobject.appointmentconfirmorder.AppointmentConfirmOrderDO">
  25. SELECT DISTINCT
  26. aco.*
  27. FROM pressure_appointment_confirm_order aco
  28. LEFT JOIN PRESSURE2_PIPE_APPOINTMENT_CONFIRM_ORDER_ITEM acoi ON acoi.order_id = aco.id
  29. WHERE aco.deleted = 0
  30. AND acoi.deleted = 0
  31. AND acoi.equip_id = #{equipId}
  32. AND aco.check_type = #{checkType}
  33. ORDER BY aco.create_time DESC
  34. LIMIT 1
  35. </select>
  36. <select id="selectPage" resultType="cn.start.tz.module.pressure2.controller.admin.appointmentconfirmorder.vo.AppointmentConfirmOrderRespVO">
  37. SELECT * FROM (
  38. SELECT aco.*,
  39. COALESCE(ebs.create_time, eps.create_time) AS scheduling_time,
  40. aco.equip_num_boiler AS equip_num
  41. FROM pressure_appointment_confirm_order aco
  42. LEFT JOIN pressure2_boiler_appointment_confirm_order_item baci ON baci.order_id = aco.id AND baci.deleted = 0
  43. LEFT JOIN pressure2_equip_boiler eb ON eb.id = baci.equip_id AND eb.deleted = 0
  44. LEFT JOIN pressure2_equip_boiler_scheduling ebs ON ebs.id = aco.scheduling_id AND ebs.deleted = 0
  45. LEFT JOIN pressure2_pipe_appointment_confirm_order_item paci ON paci.order_id = aco.id AND paci.deleted = 0
  46. LEFT JOIN pressure2_pipe_appointment_confirm_order_item_detail pacid ON pacid.order_id = aco.id AND pacid.deleted = 0
  47. LEFT JOIN pressure2_equip_pipe ep ON ep.id = paci.equip_id AND ep.deleted = 0
  48. LEFT JOIN pressure2_equip_pipe_detail epd ON epd.id = pacid.equip_id AND epd.deleted = 0
  49. LEFT JOIN pressure2_equip_pipe_scheduling eps ON eps.id = aco.scheduling_id AND eps.deleted = 0
  50. <where>
  51. aco.deleted = 0
  52. <if test="reqVO.unitCode != null and reqVO.unitCode != ''">AND aco.unit_code = #{reqVO.unitCode}</if>
  53. <if test="reqVO.unitName != null and reqVO.unitName != ''">AND aco.unit_name LIKE CONCAT('%', #{reqVO.unitName}, '%')</if>
  54. <if test="reqVO.unitAddress != null and reqVO.unitAddress != ''">AND aco.unit_address LIKE CONCAT('%', #{reqVO.unitAddress}, '%')</if>
  55. <if test="reqVO.appointmentNo != null and reqVO.appointmentNo != ''">AND aco.appointment_no LIKE CONCAT('%', #{reqVO.appointmentNo}, '%')</if>
  56. <if test="reqVO.checkType != null">AND aco.check_type = #{reqVO.checkType}</if>
  57. <if test="reqVO.equipType != null">AND aco.equip_type = #{reqVO.equipType}</if>
  58. <if test="reqVO.equipStreet != null">AND aco.equip_street = #{reqVO.equipStreet}</if>
  59. <if test="reqVO.equipDistrict != null">AND aco.equip_district = #{reqVO.equipDistrict}</if>
  60. <if test="reqVO.appointmentDate != null and reqVO.appointmentDate.length >= 2">
  61. AND aco.appointment_date BETWEEN #{reqVO.appointmentDate[0]} AND #{reqVO.appointmentDate[1]}
  62. </if>
  63. <if test="reqVO.warningDay != null and reqVO.warningDay.length >= 2">
  64. AND (CASE WHEN aco.appointment_date - aco.warning_date > 0 THEN aco.appointment_date - aco.warning_date ELSE 0 END) BETWEEN #{reqVO.warningDay[0]} AND #{reqVO.warningDay[1]}
  65. </if>
  66. <if test="reqVO.unitContact != null and reqVO.unitContact != ''">AND aco.unit_contact = #{reqVO.unitContact}</if>
  67. <if test="reqVO.unitPhone != null and reqVO.unitPhone != ''">AND aco.unit_phone = #{reqVO.unitPhone}</if>
  68. <if test="reqVO.createTime != null and reqVO.createTime.length >= 2">
  69. AND aco.create_time BETWEEN #{reqVO.createTime[0]} AND #{reqVO.createTime[1]}
  70. </if>
  71. <if test="reqVO.mobile != null and reqVO.mobile != ''">AND aco.mobile = #{reqVO.mobile}</if>
  72. <if test="reqVO.zipCode != null and reqVO.zipCode != ''">AND aco.zip_code = #{reqVO.zipCode}</if>
  73. <if test="reqVO.remark != null and reqVO.remark != ''">AND aco.remark = #{reqVO.remark}</if>
  74. <if test="reqVO.email != null and reqVO.email != ''">AND aco.email = #{reqVO.email}</if>
  75. <if test="reqVO.deptId != null and reqVO.deptId != ''">AND aco.dept_id = #{reqVO.deptId}</if>
  76. <if test="reqVO.operator != null and reqVO.operator != ''">AND aco.operator = #{reqVO.operator}</if>
  77. <if test="reqVO.isAttach != null">AND aco.is_attach = #{reqVO.isAttach}</if>
  78. <if test="reqVO.sendType != null">AND aco.send_type = #{reqVO.sendType}</if>
  79. <if test="reqVO.vehicle != null">AND aco.vehicle = #{reqVO.vehicle}</if>
  80. <if test="reqVO.feeType != null">AND aco.fee_type = #{reqVO.feeType}</if>
  81. <if test="reqVO.acceptType != null">AND aco.accept_type = #{reqVO.acceptType}</if>
  82. <if test="reqVO.actualAmount != null">AND aco.actual_amount = #{reqVO.actualAmount}</if>
  83. <if test="reqVO.serviceAmount != null">AND aco.service_amount = #{reqVO.serviceAmount}</if>
  84. <if test="reqVO.shouldAmount != null">AND aco.should_amount = #{reqVO.shouldAmount}</if>
  85. <if test="reqVO.reduceFee != null">AND aco.reduce_fee = #{reqVO.reduceFee}</if>
  86. <if test="reqVO.equipMainType != null">AND aco.equip_main_type = #{reqVO.equipMainType}</if>
  87. <if test="reqVO.useUnitSocialCreditCode != null and reqVO.useUnitSocialCreditCode != ''">AND aco.use_unit_social_credit_code = #{reqVO.useUnitSocialCreditCode}</if>
  88. <if test="reqVO.useUnitName != null and reqVO.useUnitName != ''">AND aco.use_unit_name LIKE CONCAT('%', #{reqVO.useUnitName}, '%')</if>
  89. <if test="reqVO.createAcceptOrder != null">AND aco.create_accept_order = #{reqVO.createAcceptOrder}</if>
  90. <if test="reqVO.equipCode != null and reqVO.equipCode != ''">
  91. AND (eb.equip_code LIKE CONCAT('%', #{reqVO.equipCode}, '%') OR epd.pipe_reg_code LIKE CONCAT('%', #{reqVO.equipCode}, '%'))
  92. </if>
  93. <if test="reqVO.contactPhone != null and reqVO.contactPhone != ''">
  94. AND (eb.contact_phone = #{reqVO.contactPhone} OR ep.contact_phone = #{reqVO.contactPhone})
  95. </if>
  96. <if test="reqVO.status != null and reqVO.status.size() > 0">
  97. AND aco.status IN
  98. <foreach collection="reqVO.status" item="item" open="(" separator="," close=")">#{item}</foreach>
  99. </if>
  100. <if test="reqVO.notStatus != null">AND aco.status != #{reqVO.notStatus}</if>
  101. <if test="reqVO.ids != null and reqVO.ids.size() > 0">
  102. AND aco.id IN
  103. <foreach collection="reqVO.ids" item="item" open="(" separator="," close=")">#{item}</foreach>
  104. </if>
  105. </where>
  106. GROUP BY aco.id
  107. <if test="reqVO.equipNum != null">
  108. HAVING COUNT(baci.equip_id) = #{reqVO.equipNum}
  109. </if>
  110. ORDER BY aco.create_time DESC
  111. ) tmp
  112. OFFSET ${(reqVO.pageNo - 1) * reqVO.pageSize} ROWS FETCH NEXT #{reqVO.pageSize} ROWS ONLY
  113. </select>
  114. <select id="selectPageCount" resultType="java.lang.Long">
  115. SELECT COUNT(1) FROM (
  116. SELECT aco.id
  117. FROM pressure_appointment_confirm_order aco
  118. LEFT JOIN pressure2_boiler_appointment_confirm_order_item baci ON baci.order_id = aco.id AND baci.deleted = 0
  119. LEFT JOIN pressure2_equip_boiler eb ON eb.id = baci.equip_id AND eb.deleted = 0
  120. LEFT JOIN pressure2_equip_boiler_scheduling ebs ON ebs.id = aco.scheduling_id AND ebs.deleted = 0
  121. LEFT JOIN pressure2_pipe_appointment_confirm_order_item paci ON paci.order_id = aco.id AND paci.deleted = 0
  122. LEFT JOIN pressure2_pipe_appointment_confirm_order_item_detail pacid ON pacid.order_id = aco.id AND pacid.deleted = 0
  123. LEFT JOIN pressure2_equip_pipe ep ON ep.id = paci.equip_id AND ep.deleted = 0
  124. LEFT JOIN pressure2_equip_pipe_detail epd ON epd.id = pacid.equip_id AND epd.deleted = 0
  125. LEFT JOIN pressure2_equip_pipe_scheduling eps ON eps.id = aco.scheduling_id AND eps.deleted = 0
  126. <where>
  127. aco.deleted = 0
  128. <if test="reqVO.unitCode != null and reqVO.unitCode != ''">AND aco.unit_code = #{reqVO.unitCode}</if>
  129. <if test="reqVO.unitName != null and reqVO.unitName != ''">AND aco.unit_name LIKE CONCAT('%', #{reqVO.unitName}, '%')</if>
  130. <if test="reqVO.unitAddress != null and reqVO.unitAddress != ''">AND aco.unit_address LIKE CONCAT('%', #{reqVO.unitAddress}, '%')</if>
  131. <if test="reqVO.appointmentNo != null and reqVO.appointmentNo != ''">AND aco.appointment_no LIKE CONCAT('%', #{reqVO.appointmentNo}, '%')</if>
  132. <if test="reqVO.checkType != null">AND aco.check_type = #{reqVO.checkType}</if>
  133. <if test="reqVO.equipType != null">AND aco.equip_type = #{reqVO.equipType}</if>
  134. <if test="reqVO.equipStreet != null">AND aco.equip_street = #{reqVO.equipStreet}</if>
  135. <if test="reqVO.equipDistrict != null">AND aco.equip_district = #{reqVO.equipDistrict}</if>
  136. <if test="reqVO.appointmentDate != null and reqVO.appointmentDate.length >= 2">
  137. AND aco.appointment_date BETWEEN #{reqVO.appointmentDate[0]} AND #{reqVO.appointmentDate[1]}
  138. </if>
  139. <if test="reqVO.warningDay != null and reqVO.warningDay.length >= 2">
  140. AND (CASE WHEN aco.appointment_date - aco.warning_date > 0 THEN aco.appointment_date - aco.warning_date ELSE 0 END) BETWEEN #{reqVO.warningDay[0]} AND #{reqVO.warningDay[1]}
  141. </if>
  142. <if test="reqVO.unitContact != null and reqVO.unitContact != ''">AND aco.unit_contact = #{reqVO.unitContact}</if>
  143. <if test="reqVO.unitPhone != null and reqVO.unitPhone != ''">AND aco.unit_phone = #{reqVO.unitPhone}</if>
  144. <if test="reqVO.createTime != null and reqVO.createTime.length >= 2">
  145. AND aco.create_time BETWEEN #{reqVO.createTime[0]} AND #{reqVO.createTime[1]}
  146. </if>
  147. <if test="reqVO.mobile != null and reqVO.mobile != ''">AND aco.mobile = #{reqVO.mobile}</if>
  148. <if test="reqVO.zipCode != null and reqVO.zipCode != ''">AND aco.zip_code = #{reqVO.zipCode}</if>
  149. <if test="reqVO.remark != null and reqVO.remark != ''">AND aco.remark = #{reqVO.remark}</if>
  150. <if test="reqVO.email != null and reqVO.email != ''">AND aco.email = #{reqVO.email}</if>
  151. <if test="reqVO.deptId != null and reqVO.deptId != ''">AND aco.dept_id = #{reqVO.deptId}</if>
  152. <if test="reqVO.operator != null and reqVO.operator != ''">AND aco.operator = #{reqVO.operator}</if>
  153. <if test="reqVO.isAttach != null">AND aco.is_attach = #{reqVO.isAttach}</if>
  154. <if test="reqVO.sendType != null">AND aco.send_type = #{reqVO.sendType}</if>
  155. <if test="reqVO.vehicle != null">AND aco.vehicle = #{reqVO.vehicle}</if>
  156. <if test="reqVO.feeType != null">AND aco.fee_type = #{reqVO.feeType}</if>
  157. <if test="reqVO.acceptType != null">AND aco.accept_type = #{reqVO.acceptType}</if>
  158. <if test="reqVO.actualAmount != null">AND aco.actual_amount = #{reqVO.actualAmount}</if>
  159. <if test="reqVO.serviceAmount != null">AND aco.service_amount = #{reqVO.serviceAmount}</if>
  160. <if test="reqVO.shouldAmount != null">AND aco.should_amount = #{reqVO.shouldAmount}</if>
  161. <if test="reqVO.reduceFee != null">AND aco.reduce_fee = #{reqVO.reduceFee}</if>
  162. <if test="reqVO.equipMainType != null">AND aco.equip_main_type = #{reqVO.equipMainType}</if>
  163. <if test="reqVO.useUnitSocialCreditCode != null and reqVO.useUnitSocialCreditCode != ''">AND aco.use_unit_social_credit_code = #{reqVO.useUnitSocialCreditCode}</if>
  164. <if test="reqVO.useUnitName != null and reqVO.useUnitName != ''">AND aco.use_unit_name LIKE CONCAT('%', #{reqVO.useUnitName}, '%')</if>
  165. <if test="reqVO.createAcceptOrder != null">AND aco.create_accept_order = #{reqVO.createAcceptOrder}</if>
  166. <if test="reqVO.equipCode != null and reqVO.equipCode != ''">
  167. AND (eb.equip_code LIKE CONCAT('%', #{reqVO.equipCode}, '%') OR epd.pipe_reg_code LIKE CONCAT('%', #{reqVO.equipCode}, '%'))
  168. </if>
  169. <if test="reqVO.contactPhone != null and reqVO.contactPhone != ''">
  170. AND (eb.contact_phone = #{reqVO.contactPhone} OR ep.contact_phone = #{reqVO.contactPhone})
  171. </if>
  172. <if test="reqVO.status != null and reqVO.status.size() > 0">
  173. AND aco.status IN
  174. <foreach collection="reqVO.status" item="item" open="(" separator="," close=")">#{item}</foreach>
  175. </if>
  176. <if test="reqVO.notStatus != null">AND aco.status != #{reqVO.notStatus}</if>
  177. <if test="reqVO.ids != null and reqVO.ids.size() > 0">
  178. AND aco.id IN
  179. <foreach collection="reqVO.ids" item="item" open="(" separator="," close=")">#{item}</foreach>
  180. </if>
  181. </where>
  182. GROUP BY aco.id
  183. <if test="reqVO.equipNum != null">
  184. HAVING COUNT(baci.equip_id) = #{reqVO.equipNum}
  185. </if>
  186. ) cnt
  187. </select>
  188. </mapper>