Files
nanguangszwlback/mhd-modules/mhd-system/src/main/resources/mapper/basic/lease/LeaseMapper.xml
T
2026-02-09 16:53:46 +08:00

132 lines
5.9 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.mhd.basic.domain.lease.repository.mapper.LeaseMapper">
<resultMap type="com.mhd.basic.domain.lease.repository.po.LeasePO" id="LeaseResult">
<!-- 租赁相关字段 -->
<result property="id" column="id" />
<result property="organizationId" column="organization_id" />
<result property="organizationName" column="organization_name" />
<result property="topOrganizationId" column="top_organization_id" />
<result property="warehouseId" column="warehouse_id" />
<result property="warehouseName" column="warehouse_name" />
<result property="shipperId" column="shipper_id" />
<result property="cargoOwnerName" column="cargo_owner_name" />
<result property="leaseType" column="lease_type" />
<result property="leaseArea" column="lease_area" />
<result property="startDate" column="start_date" />
<result property="endDate" column="end_date" />
<result property="remark" column="remark" />
<!-- 继承自BaseVOEntity的字段 -->
<result property="createTime" column="create_time" />
<result property="createBy" column="create_by" />
<result property="createByName" column="create_by_name" />
<result property="updateTime" column="update_time" />
<result property="updateBy" column="update_by" />
<result property="updateByName" column="update_by_name" />
<result property="delFlag" column="del_flag" />
</resultMap>
<sql id="selectLeasePo">
select
a.id,
a.organization_id,
a.organization_name,
a.top_organization_id,
a.warehouse_id,
COALESCE(w.warehouse_name, a.warehouse_name) as warehouse_name,
a.shipper_id,
a.cargo_owner_name,
a.lease_type,
a.lease_area,
a.start_date,
a.end_date,
a.remark,
a.create_time,
a.create_by,
a.create_by_name,
a.update_time,
a.update_by,
a.update_by_name,
a.del_flag
from lease a
LEFT JOIN warehouse w ON a.warehouse_id = w.warehouse_id AND w.del_flag = 1
</sql>
<sql id="selectLeasePo1">
<where>
<!-- 租赁查询条件 -->
<if test="organizationId != null ">
and a.organization_id = #{organizationId}
</if>
<if test="topOrganizationId != null ">
and a.top_organization_id = #{topOrganizationId}
</if>
<if test="organizationName != null and organizationName != ''">
and a.organization_name like concat('%', #{organizationName}, '%')
</if>
<if test="warehouseId != null ">
and a.warehouse_id = #{warehouseId}
</if>
<if test="warehouseName != null and warehouseName != ''">
and (w.warehouse_name like concat('%', #{warehouseName}, '%') or a.warehouse_name like concat('%', #{warehouseName}, '%'))
</if>
<if test="cargoOwnerName != null and cargoOwnerName != ''">
and a.cargo_owner_name like concat('%', #{cargoOwnerName}, '%')
</if>
<if test="leaseType != null and leaseType != ''">
and a.lease_type = #{leaseType}
</if>
<if test="createTime != null ">
and a.create_time = #{createTime}
</if>
<if test="leaseArea != null ">
and a.lease_area = #{leaseArea}
</if>
<if test="remark != null and remark != ''">
and a.remark like concat('%', #{remark}, '%')
</if>
<!-- 创建和更新相关条件 -->
<if test="createByName != null and createByName != ''">
and a.create_by_name like concat('%', #{createByName}, '%')
</if>
<if test="updateByName != null and updateByName != ''">
and a.update_by_name like concat('%', #{updateByName}, '%')
</if>
<if test="createTimeStart != null and createTimeStart != ''">
and date_format(a.create_time,'%Y-%m-%d') &gt;= #{createTimeStart}
</if>
<if test="createTimeEnd != null and createTimeEnd != ''">
and date_format(a.create_time,'%Y-%m-%d') &lt;= #{createTimeEnd}
</if>
<if test="updateTimeStart != null and updateTimeStart != ''">
and date_format(a.update_time,'%Y-%m-%d') &gt;= #{updateTimeStart}
</if>
<if test="updateTimeEnd != null and updateTimeEnd != ''">
and date_format(a.update_time,'%Y-%m-%d') &lt;= #{updateTimeEnd}
</if>
<!-- 时间范围查询(如果需要) -->
<if test="startDate != null and endDate != null">
and a.start_date &gt;= #{startDate} and a.start_date &lt;= #{endDate}
</if>
<if test="time != null">
AND a.start_date &lt;= #{time}
AND a.end_date &gt;= #{time}
</if>
<!-- 删除标记 -->
<choose>
<when test="delFlag != null"> and a.del_flag = #{delFlag} </when>
<otherwise> and a.del_flag = 1 </otherwise>
</choose>
</where>
</sql>
<select id="queryList" parameterType="com.mhd.basic.domain.lease.repository.po.LeasePO" resultMap="LeaseResult">
<include refid="selectLeasePo"/>
<include refid="selectLeasePo1"/>
ORDER BY a.create_time DESC
</select>
</mapper>