技术数据仓库查询修改

This commit is contained in:
秦鸿展
2026-02-07 13:52:49 +08:00
parent fe1aadd8ac
commit 52a34779ec
4 changed files with 153 additions and 117 deletions
@@ -29,93 +29,94 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="selectLeasePo">
select
id,
organization_id,
organization_name,
top_organization_id,
warehouse_id,
warehouse_name,
shipper_id,
cargo_owner_name,
lease_type,
lease_area,
start_date,
end_date,
remark,
create_time,
create_by,
create_by_name,
update_time,
update_by,
update_by_name,
del_flag
from lease
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 organization_id = #{organizationId}
and a.organization_id = #{organizationId}
</if>
<if test="topOrganizationId != null ">
and top_organization_id = #{topOrganizationId}
and a.top_organization_id = #{topOrganizationId}
</if>
<if test="organizationName != null and organizationName != ''">
and organization_name like concat('%', #{organizationName}, '%')
and a.organization_name like concat('%', #{organizationName}, '%')
</if>
<if test="warehouseId != null ">
and warehouse_id = #{warehouseId}
and a.warehouse_id = #{warehouseId}
</if>
<if test="warehouseName != null and warehouseName != ''">
and warehouse_name like concat('%', #{warehouseName}, '%')
and (w.warehouse_name like concat('%', #{warehouseName}, '%') or a.warehouse_name like concat('%', #{warehouseName}, '%'))
</if>
<if test="cargoOwnerName != null and cargoOwnerName != ''">
and cargo_owner_name like concat('%', #{cargoOwnerName}, '%')
and a.cargo_owner_name like concat('%', #{cargoOwnerName}, '%')
</if>
<if test="leaseType != null and leaseType != ''">
and lease_type = #{leaseType}
and a.lease_type = #{leaseType}
</if>
<if test="createTime != null ">
and create_time = #{createTime}
and a.create_time = #{createTime}
</if>
<if test="leaseArea != null ">
and lease_area = #{leaseArea}
and a.lease_area = #{leaseArea}
</if>
<if test="remark != null and remark != ''">
and remark like concat('%', #{remark}, '%')
and a.remark like concat('%', #{remark}, '%')
</if>
<!-- 创建和更新相关条件 -->
<if test="createByName != null and createByName != ''">
and create_by_name like concat('%', #{createByName}, '%')
and a.create_by_name like concat('%', #{createByName}, '%')
</if>
<if test="updateByName != null and updateByName != ''">
and update_by_name like concat('%', #{updateByName}, '%')
and a.update_by_name like concat('%', #{updateByName}, '%')
</if>
<if test="createTimeStart != null and createTimeStart != ''">
and date_format(create_time,'%Y-%m-%d') &gt;= #{createTimeStart}
and date_format(a.create_time,'%Y-%m-%d') &gt;= #{createTimeStart}
</if>
<if test="createTimeEnd != null and createTimeEnd != ''">
and date_format(create_time,'%Y-%m-%d') &lt;= #{createTimeEnd}
and date_format(a.create_time,'%Y-%m-%d') &lt;= #{createTimeEnd}
</if>
<if test="updateTimeStart != null and updateTimeStart != ''">
and date_format(update_time,'%Y-%m-%d') &gt;= #{updateTimeStart}
and date_format(a.update_time,'%Y-%m-%d') &gt;= #{updateTimeStart}
</if>
<if test="updateTimeEnd != null and updateTimeEnd != ''">
and date_format(update_time,'%Y-%m-%d') &lt;= #{updateTimeEnd}
and date_format(a.update_time,'%Y-%m-%d') &lt;= #{updateTimeEnd}
</if>
<!-- 时间范围查询(如果需要) -->
<if test="startDate != null and endDate != null">
and start_date &gt;= #{startDate} and start_date &lt;= #{endDate}
and a.start_date &gt;= #{startDate} and a.start_date &lt;= #{endDate}
</if>
<if test="time != null">
AND start_date &lt;= #{time}
AND end_date &gt;= #{time}
AND a.start_date &lt;= #{time}
AND a.end_date &gt;= #{time}
</if>
<!-- 删除标记 -->
<choose>
<when test="delFlag != null"> and del_flag = #{delFlag} </when>
<otherwise> and del_flag = 1 </otherwise>
<when test="delFlag != null"> and a.del_flag = #{delFlag} </when>
<otherwise> and a.del_flag = 1 </otherwise>
</choose>
</where>
</sql>
@@ -123,6 +124,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="queryList" parameterType="com.mhd.basic.domain.lease.repository.po.LeasePO" resultMap="LeaseResult">
<include refid="selectLeasePo"/>
<include refid="selectLeasePo1"/>
ORDER BY create_time DESC
ORDER BY a.create_time DESC
</select>
</mapper>