charging_pile/common/src/main/resources/mapper/MaintenanceOrderMapper.xml

93 lines
4.1 KiB
XML

<?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="com.hcy.common.mapper.order.MaintenanceOrderMapper">
<select id="list" resultType="com.hcy.common.dto.order.MaintenanceOrderDto">
SELECT
lmo.*,
lf.`name` as faultName,
lc.client_name as clientName,
lc.short_name as shortName,
le.number as equipmentNo,
le.name as equipmentName,
le.detailed_address as detailedAddress,
lsaa.nickname as creatorName,
lcc.`name` as clientCreatorName,
lu.username as receiverName,
le.province_id as equipmentProvinceId,
le.district_id as equipmentDistrictId,
le.city_id as equipmentCityId,
le.longitude,
le.latitude
FROM
la_maintenance_order AS lmo
LEFT JOIN la_client AS lc ON lc.id = lmo.client_id
LEFT JOIN la_equipment AS le ON le.id = lmo.equipment_id
LEFT JOIN la_fault AS lf On lf.id = lmo.fault_id
LEFT JOIN la_system_auth_admin AS lsaa ON lsaa.id = lmo.creator_id
LEFT JOIN la_user AS lu ON lu.id = lmo.receiver_id
LEFT JOIN la_client_contacts AS lcc ON lcc.user_id = lmo.creator_id
<where>
lmo.is_delete = 0
<if test="param.orderNo != null and param.orderNo != ''">
and lmo.order_no like concat('%',#{param.orderNo},'%')
</if>
<if test="param.orderSource != null">
and lmo.order_source = #{param.orderSource}
</if>
<if test="param.clientName != null and param.clientName != ''">
and lc.client_name like concat('%',#{param.clientName},'%')
</if>
<if test="param.creatorName != null and param.creatorName != ''">
and (lsaa.username like concat('%',#{param.creatorName},'%') or lcc.name like concat('%',#{param.creatorName},'%'))
</if>
<if test="param.receiverName != null and param.receiverName != ''">
and lu.username like concat('%',#{param.receiverName},'%')
</if>
<if test="param.orderStatus != null">
and find_in_set(lmo.order_status,#{param.orderStatus})
</if>
<if test="param.receiverId != null">
and lmo.receiver_id = #{param.receiverId}
</if>
<if test="param.clientId != null">
and lmo.client_id = #{param.clientId}
</if>
<if test="param.orderStatusIds != null and param.orderStatusIds != ''">
and find_in_set(lmo.order_status,#{param.orderStatusIds})
</if>
<if test="param.likeWork != null and param.likeWork != ''">
and (le.number like concat('%',#{param.likeWork},'%')
or lmo.order_no like concat('%',#{param.likeWork},'%')
or lc.client_name like concat('%',#{param.likeWork},'%')
or le.name like concat('%',#{param.likeWork},'%'))
</if>
<if test="param.createTimeStart != null and param.createTimeStart != ''">
and lmo.create_time &gt;= #{param.createTimeStart}
</if>
<if test="param.createTimeEnd != null and param.createTimeEnd != ''">
and lmo.create_time &lt;= #{param.createTimeEnd}
</if>
</where>
order by create_time desc
</select>
<select id="selectPendingOrderCount" resultType="Integer">
SELECT
COUNT( order_status )
FROM
la_maintenance_order as lmo
WHERE
is_delete = 0
<if test="param.receiverId != null">
and lmo.receiver_id = #{param.receiverId}
</if>
<if test="param.clientId != null">
and lmo.client_id = #{param.clientId}
</if>
<if test="param.orderStatusIds != null and param.orderStatusIds != ''">
and find_in_set(lmo.order_status,#{param.orderStatusIds})
</if>
</select>
</mapper>