| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="cn.start.tz.module.pressure2.dal.mysql.appointmentconfirmorder.AppointmentConfirmOrderMapper">
- <!--
- 一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
- 无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
- 代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
- 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
- -->
- <select id="selectByEquipIdAndCheckTypeBoiler"
- resultType="cn.start.tz.module.pressure2.dal.dataobject.appointmentconfirmorder.AppointmentConfirmOrderDO">
- SELECT DISTINCT
- aco.*
- FROM pressure_appointment_confirm_order aco
- LEFT JOIN PRESSURE2_BOILER_APPOINTMENT_CONFIRM_ORDER_ITEM acoi ON acoi.order_id = aco.id
- WHERE aco.deleted = 0
- AND acoi.deleted = 0
- AND acoi.equip_id = #{equipId}
- AND aco.check_type = #{checkType}
- ORDER BY aco.create_time DESC
- LIMIT 1
- </select>
- <select id="selectByEquipIdAndCheckTypePipe"
- resultType="cn.start.tz.module.pressure2.dal.dataobject.appointmentconfirmorder.AppointmentConfirmOrderDO">
- SELECT DISTINCT
- aco.*
- FROM pressure_appointment_confirm_order aco
- LEFT JOIN PRESSURE2_PIPE_APPOINTMENT_CONFIRM_ORDER_ITEM acoi ON acoi.order_id = aco.id
- WHERE aco.deleted = 0
- AND acoi.deleted = 0
- AND acoi.equip_id = #{equipId}
- AND aco.check_type = #{checkType}
- ORDER BY aco.create_time DESC
- LIMIT 1
- </select>
- <select id="selectPage" resultType="cn.start.tz.module.pressure2.controller.admin.appointmentconfirmorder.vo.AppointmentConfirmOrderRespVO">
- SELECT * FROM (
- SELECT aco.*,
- COALESCE(ebs.create_time, eps.create_time) AS scheduling_time,
- aco.equip_num_boiler AS equip_num
- FROM pressure_appointment_confirm_order aco
- LEFT JOIN pressure2_boiler_appointment_confirm_order_item baci ON baci.order_id = aco.id AND baci.deleted = 0
- LEFT JOIN pressure2_equip_boiler eb ON eb.id = baci.equip_id AND eb.deleted = 0
- LEFT JOIN pressure2_equip_boiler_scheduling ebs ON ebs.id = aco.scheduling_id AND ebs.deleted = 0
- LEFT JOIN pressure2_pipe_appointment_confirm_order_item paci ON paci.order_id = aco.id AND paci.deleted = 0
- LEFT JOIN pressure2_pipe_appointment_confirm_order_item_detail pacid ON pacid.order_id = aco.id AND pacid.deleted = 0
- LEFT JOIN pressure2_equip_pipe ep ON ep.id = paci.equip_id AND ep.deleted = 0
- LEFT JOIN pressure2_equip_pipe_detail epd ON epd.id = pacid.equip_id AND epd.deleted = 0
- LEFT JOIN pressure2_equip_pipe_scheduling eps ON eps.id = aco.scheduling_id AND eps.deleted = 0
- <where>
- aco.deleted = 0
- <if test="reqVO.unitCode != null and reqVO.unitCode != ''">AND aco.unit_code = #{reqVO.unitCode}</if>
- <if test="reqVO.unitName != null and reqVO.unitName != ''">AND aco.unit_name LIKE CONCAT('%', #{reqVO.unitName}, '%')</if>
- <if test="reqVO.unitAddress != null and reqVO.unitAddress != ''">AND aco.unit_address LIKE CONCAT('%', #{reqVO.unitAddress}, '%')</if>
- <if test="reqVO.appointmentNo != null and reqVO.appointmentNo != ''">AND aco.appointment_no LIKE CONCAT('%', #{reqVO.appointmentNo}, '%')</if>
- <if test="reqVO.checkType != null">AND aco.check_type = #{reqVO.checkType}</if>
- <if test="reqVO.equipType != null">AND aco.equip_type = #{reqVO.equipType}</if>
- <if test="reqVO.equipStreet != null">AND aco.equip_street = #{reqVO.equipStreet}</if>
- <if test="reqVO.equipDistrict != null">AND aco.equip_district = #{reqVO.equipDistrict}</if>
- <if test="reqVO.appointmentDate != null and reqVO.appointmentDate.length >= 2">
- AND aco.appointment_date BETWEEN #{reqVO.appointmentDate[0]} AND #{reqVO.appointmentDate[1]}
- </if>
- <if test="reqVO.warningDay != null and reqVO.warningDay.length >= 2">
- 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]}
- </if>
- <if test="reqVO.unitContact != null and reqVO.unitContact != ''">AND aco.unit_contact = #{reqVO.unitContact}</if>
- <if test="reqVO.unitPhone != null and reqVO.unitPhone != ''">AND aco.unit_phone = #{reqVO.unitPhone}</if>
- <if test="reqVO.createTime != null and reqVO.createTime.length >= 2">
- AND aco.create_time BETWEEN #{reqVO.createTime[0]} AND #{reqVO.createTime[1]}
- </if>
- <if test="reqVO.mobile != null and reqVO.mobile != ''">AND aco.mobile = #{reqVO.mobile}</if>
- <if test="reqVO.zipCode != null and reqVO.zipCode != ''">AND aco.zip_code = #{reqVO.zipCode}</if>
- <if test="reqVO.remark != null and reqVO.remark != ''">AND aco.remark = #{reqVO.remark}</if>
- <if test="reqVO.email != null and reqVO.email != ''">AND aco.email = #{reqVO.email}</if>
- <if test="reqVO.deptId != null and reqVO.deptId != ''">AND aco.dept_id = #{reqVO.deptId}</if>
- <if test="reqVO.operator != null and reqVO.operator != ''">AND aco.operator = #{reqVO.operator}</if>
- <if test="reqVO.isAttach != null">AND aco.is_attach = #{reqVO.isAttach}</if>
- <if test="reqVO.sendType != null">AND aco.send_type = #{reqVO.sendType}</if>
- <if test="reqVO.vehicle != null">AND aco.vehicle = #{reqVO.vehicle}</if>
- <if test="reqVO.feeType != null">AND aco.fee_type = #{reqVO.feeType}</if>
- <if test="reqVO.acceptType != null">AND aco.accept_type = #{reqVO.acceptType}</if>
- <if test="reqVO.actualAmount != null">AND aco.actual_amount = #{reqVO.actualAmount}</if>
- <if test="reqVO.serviceAmount != null">AND aco.service_amount = #{reqVO.serviceAmount}</if>
- <if test="reqVO.shouldAmount != null">AND aco.should_amount = #{reqVO.shouldAmount}</if>
- <if test="reqVO.reduceFee != null">AND aco.reduce_fee = #{reqVO.reduceFee}</if>
- <if test="reqVO.equipMainType != null">AND aco.equip_main_type = #{reqVO.equipMainType}</if>
- <if test="reqVO.useUnitSocialCreditCode != null and reqVO.useUnitSocialCreditCode != ''">AND aco.use_unit_social_credit_code = #{reqVO.useUnitSocialCreditCode}</if>
- <if test="reqVO.useUnitName != null and reqVO.useUnitName != ''">AND aco.use_unit_name LIKE CONCAT('%', #{reqVO.useUnitName}, '%')</if>
- <if test="reqVO.createAcceptOrder != null">AND aco.create_accept_order = #{reqVO.createAcceptOrder}</if>
- <if test="reqVO.equipCode != null and reqVO.equipCode != ''">
- AND (eb.equip_code LIKE CONCAT('%', #{reqVO.equipCode}, '%') OR epd.pipe_reg_code LIKE CONCAT('%', #{reqVO.equipCode}, '%'))
- </if>
- <if test="reqVO.contactPhone != null and reqVO.contactPhone != ''">
- AND (eb.contact_phone = #{reqVO.contactPhone} OR ep.contact_phone = #{reqVO.contactPhone})
- </if>
- <if test="reqVO.status != null and reqVO.status.size() > 0">
- AND aco.status IN
- <foreach collection="reqVO.status" item="item" open="(" separator="," close=")">#{item}</foreach>
- </if>
- <if test="reqVO.notStatus != null">AND aco.status != #{reqVO.notStatus}</if>
- <if test="reqVO.ids != null and reqVO.ids.size() > 0">
- AND aco.id IN
- <foreach collection="reqVO.ids" item="item" open="(" separator="," close=")">#{item}</foreach>
- </if>
- </where>
- GROUP BY aco.id
- <if test="reqVO.equipNum != null">
- HAVING COUNT(baci.equip_id) = #{reqVO.equipNum}
- </if>
- ORDER BY aco.create_time DESC
- ) tmp
- OFFSET ${(reqVO.pageNo - 1) * reqVO.pageSize} ROWS FETCH NEXT #{reqVO.pageSize} ROWS ONLY
- </select>
- <select id="selectPageCount" resultType="java.lang.Long">
- SELECT COUNT(1) FROM (
- SELECT aco.id
- FROM pressure_appointment_confirm_order aco
- LEFT JOIN pressure2_boiler_appointment_confirm_order_item baci ON baci.order_id = aco.id AND baci.deleted = 0
- LEFT JOIN pressure2_equip_boiler eb ON eb.id = baci.equip_id AND eb.deleted = 0
- LEFT JOIN pressure2_equip_boiler_scheduling ebs ON ebs.id = aco.scheduling_id AND ebs.deleted = 0
- LEFT JOIN pressure2_pipe_appointment_confirm_order_item paci ON paci.order_id = aco.id AND paci.deleted = 0
- LEFT JOIN pressure2_pipe_appointment_confirm_order_item_detail pacid ON pacid.order_id = aco.id AND pacid.deleted = 0
- LEFT JOIN pressure2_equip_pipe ep ON ep.id = paci.equip_id AND ep.deleted = 0
- LEFT JOIN pressure2_equip_pipe_detail epd ON epd.id = pacid.equip_id AND epd.deleted = 0
- LEFT JOIN pressure2_equip_pipe_scheduling eps ON eps.id = aco.scheduling_id AND eps.deleted = 0
- <where>
- aco.deleted = 0
- <if test="reqVO.unitCode != null and reqVO.unitCode != ''">AND aco.unit_code = #{reqVO.unitCode}</if>
- <if test="reqVO.unitName != null and reqVO.unitName != ''">AND aco.unit_name LIKE CONCAT('%', #{reqVO.unitName}, '%')</if>
- <if test="reqVO.unitAddress != null and reqVO.unitAddress != ''">AND aco.unit_address LIKE CONCAT('%', #{reqVO.unitAddress}, '%')</if>
- <if test="reqVO.appointmentNo != null and reqVO.appointmentNo != ''">AND aco.appointment_no LIKE CONCAT('%', #{reqVO.appointmentNo}, '%')</if>
- <if test="reqVO.checkType != null">AND aco.check_type = #{reqVO.checkType}</if>
- <if test="reqVO.equipType != null">AND aco.equip_type = #{reqVO.equipType}</if>
- <if test="reqVO.equipStreet != null">AND aco.equip_street = #{reqVO.equipStreet}</if>
- <if test="reqVO.equipDistrict != null">AND aco.equip_district = #{reqVO.equipDistrict}</if>
- <if test="reqVO.appointmentDate != null and reqVO.appointmentDate.length >= 2">
- AND aco.appointment_date BETWEEN #{reqVO.appointmentDate[0]} AND #{reqVO.appointmentDate[1]}
- </if>
- <if test="reqVO.warningDay != null and reqVO.warningDay.length >= 2">
- 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]}
- </if>
- <if test="reqVO.unitContact != null and reqVO.unitContact != ''">AND aco.unit_contact = #{reqVO.unitContact}</if>
- <if test="reqVO.unitPhone != null and reqVO.unitPhone != ''">AND aco.unit_phone = #{reqVO.unitPhone}</if>
- <if test="reqVO.createTime != null and reqVO.createTime.length >= 2">
- AND aco.create_time BETWEEN #{reqVO.createTime[0]} AND #{reqVO.createTime[1]}
- </if>
- <if test="reqVO.mobile != null and reqVO.mobile != ''">AND aco.mobile = #{reqVO.mobile}</if>
- <if test="reqVO.zipCode != null and reqVO.zipCode != ''">AND aco.zip_code = #{reqVO.zipCode}</if>
- <if test="reqVO.remark != null and reqVO.remark != ''">AND aco.remark = #{reqVO.remark}</if>
- <if test="reqVO.email != null and reqVO.email != ''">AND aco.email = #{reqVO.email}</if>
- <if test="reqVO.deptId != null and reqVO.deptId != ''">AND aco.dept_id = #{reqVO.deptId}</if>
- <if test="reqVO.operator != null and reqVO.operator != ''">AND aco.operator = #{reqVO.operator}</if>
- <if test="reqVO.isAttach != null">AND aco.is_attach = #{reqVO.isAttach}</if>
- <if test="reqVO.sendType != null">AND aco.send_type = #{reqVO.sendType}</if>
- <if test="reqVO.vehicle != null">AND aco.vehicle = #{reqVO.vehicle}</if>
- <if test="reqVO.feeType != null">AND aco.fee_type = #{reqVO.feeType}</if>
- <if test="reqVO.acceptType != null">AND aco.accept_type = #{reqVO.acceptType}</if>
- <if test="reqVO.actualAmount != null">AND aco.actual_amount = #{reqVO.actualAmount}</if>
- <if test="reqVO.serviceAmount != null">AND aco.service_amount = #{reqVO.serviceAmount}</if>
- <if test="reqVO.shouldAmount != null">AND aco.should_amount = #{reqVO.shouldAmount}</if>
- <if test="reqVO.reduceFee != null">AND aco.reduce_fee = #{reqVO.reduceFee}</if>
- <if test="reqVO.equipMainType != null">AND aco.equip_main_type = #{reqVO.equipMainType}</if>
- <if test="reqVO.useUnitSocialCreditCode != null and reqVO.useUnitSocialCreditCode != ''">AND aco.use_unit_social_credit_code = #{reqVO.useUnitSocialCreditCode}</if>
- <if test="reqVO.useUnitName != null and reqVO.useUnitName != ''">AND aco.use_unit_name LIKE CONCAT('%', #{reqVO.useUnitName}, '%')</if>
- <if test="reqVO.createAcceptOrder != null">AND aco.create_accept_order = #{reqVO.createAcceptOrder}</if>
- <if test="reqVO.equipCode != null and reqVO.equipCode != ''">
- AND (eb.equip_code LIKE CONCAT('%', #{reqVO.equipCode}, '%') OR epd.pipe_reg_code LIKE CONCAT('%', #{reqVO.equipCode}, '%'))
- </if>
- <if test="reqVO.contactPhone != null and reqVO.contactPhone != ''">
- AND (eb.contact_phone = #{reqVO.contactPhone} OR ep.contact_phone = #{reqVO.contactPhone})
- </if>
- <if test="reqVO.status != null and reqVO.status.size() > 0">
- AND aco.status IN
- <foreach collection="reqVO.status" item="item" open="(" separator="," close=")">#{item}</foreach>
- </if>
- <if test="reqVO.notStatus != null">AND aco.status != #{reqVO.notStatus}</if>
- <if test="reqVO.ids != null and reqVO.ids.size() > 0">
- AND aco.id IN
- <foreach collection="reqVO.ids" item="item" open="(" separator="," close=")">#{item}</foreach>
- </if>
- </where>
- GROUP BY aco.id
- <if test="reqVO.equipNum != null">
- HAVING COUNT(baci.equip_id) = #{reqVO.equipNum}
- </if>
- ) cnt
- </select>
- </mapper>
|