技术数据仓库查询修改

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>
@@ -51,119 +51,133 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="selectStorageLocationPo">
select storage_location_id, organization_id, organization_name, top_organization_id, warehouse_id, warehouse_code, warehouse_name, storage_section_id, storage_code, storage_name, storage_location_code, storage_location_name, storage_location_classify, storage_location_classify_name, storage_location_type, storage_location_type_name, mixing_strategy, mixing_strategy_name, storage_location_group_id, storage_location_group_code, storage_location_group_name, weight_limit, volume_limit, location_size, location_length, location_width, location_height, coordinate, coordinate_area, coordinate_column, coordinate_row, coordinate_layer, remark, opening_up, nullify, status, create_time, create_by, create_by_name, update_time, update_by, update_by_name, del_flag from storage_location
select a.storage_location_id, a.organization_id, a.organization_name, a.top_organization_id, a.warehouse_id,
COALESCE(w.warehouse_code, a.warehouse_code) as warehouse_code,
COALESCE(w.warehouse_name, a.warehouse_name) as warehouse_name,
a.storage_section_id, a.storage_code, a.storage_name, a.storage_location_code, a.storage_location_name,
a.storage_location_classify, a.storage_location_classify_name, a.storage_location_type, a.storage_location_type_name,
a.mixing_strategy, a.mixing_strategy_name, a.storage_location_group_id, a.storage_location_group_code, a.storage_location_group_name,
a.weight_limit, a.volume_limit, a.location_size, a.location_length, a.location_width, a.location_height,
a.coordinate, a.coordinate_area, a.coordinate_column, a.coordinate_row, a.coordinate_layer, a.remark,
a.opening_up, a.nullify, a.status, a.create_time, a.create_by, a.create_by_name, a.update_time, a.update_by, a.update_by_name, a.del_flag
from storage_location a
LEFT JOIN warehouse w ON a.warehouse_id = w.warehouse_id AND w.del_flag = 1
</sql>
<sql id="selectStorageLocationPo1">
<where>
<if test="organizationId != null ">
and organization_id = #{organizationId}
and a.organization_id = #{organizationId}
</if>
<if test="organizationName != null and organizationName != ''">
and organization_name like concat('%', #{organizationName}, '%')
and a.organization_name like concat('%', #{organizationName}, '%')
</if>
<if test="topOrganizationId != null ">
and top_organization_id = #{topOrganizationId}
and a.top_organization_id = #{topOrganizationId}
</if>
<if test="warehouseId != null ">
and warehouse_id = #{warehouseId}
and a.warehouse_id = #{warehouseId}
</if>
<if test="warehouseCode != null and warehouseCode != ''">
and warehouse_code = #{warehouseCode}
and (w.warehouse_code like concat('%', #{warehouseCode}, '%') or a.warehouse_code like concat('%', #{warehouseCode}, '%'))
</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="storageSectionId != null ">
and storage_section_id = #{storageSectionId}
and a.storage_section_id = #{storageSectionId}
</if>
<if test="storageCode != null and storageCode != ''">
and storage_code = #{storageCode}
and a.storage_code = #{storageCode}
</if>
<if test="storageName != null and storageName != ''">
and storage_name like concat('%', #{storageName}, '%')
and a.storage_name like concat('%', #{storageName}, '%')
</if>
<if test="storageLocationCode != null and storageLocationCode != ''">
and storage_location_code = #{storageLocationCode}
and a.storage_location_code = #{storageLocationCode}
</if>
<if test="storageLocationName != null and storageLocationName != ''">
and storage_location_name like concat('%', #{storageLocationName}, '%')
and a.storage_location_name like concat('%', #{storageLocationName}, '%')
</if>
<if test="storageLocationClassify != null and storageLocationClassify != ''">
and storage_location_classify = #{storageLocationClassify}
and a.storage_location_classify = #{storageLocationClassify}
</if>
<if test="storageLocationClassifyName != null and storageLocationClassifyName != ''">
and storage_location_classify_name like concat('%', #{storageLocationClassifyName}, '%')
and a.storage_location_classify_name like concat('%', #{storageLocationClassifyName}, '%')
</if>
<if test="storageLocationType != null and storageLocationType != ''">
and storage_location_type = #{storageLocationType}
and a.storage_location_type = #{storageLocationType}
</if>
<if test="storageLocationTypeName != null and storageLocationTypeName != ''">
and storage_location_type_name like concat('%', #{storageLocationTypeName}, '%')
and a.storage_location_type_name like concat('%', #{storageLocationTypeName}, '%')
</if>
<if test="mixingStrategy != null and mixingStrategy != ''">
and mixing_strategy = #{mixingStrategy}
and a.mixing_strategy = #{mixingStrategy}
</if>
<if test="mixingStrategyName != null and mixingStrategyName != ''">
and mixing_strategy_name like concat('%', #{mixingStrategyName}, '%')
and a.mixing_strategy_name like concat('%', #{mixingStrategyName}, '%')
</if>
<if test="storageLocationGroupId != null ">
and storage_location_group_id = #{storageLocationGroupId}
and a.storage_location_group_id = #{storageLocationGroupId}
</if>
<if test="storageLocationGroupCode != null and storageLocationGroupCode != ''">
and storage_location_group_code = #{storageLocationGroupCode}
and a.storage_location_group_code = #{storageLocationGroupCode}
</if>
<if test="storageLocationGroupName != null and storageLocationGroupName != ''">
and storage_location_group_name like concat('%', #{storageLocationGroupName}, '%')
and a.storage_location_group_name like concat('%', #{storageLocationGroupName}, '%')
</if>
<if test="weightLimit != null ">
and weight_limit = #{weightLimit}
and a.weight_limit = #{weightLimit}
</if>
<if test="volumeLimit != null ">
and volume_limit = #{volumeLimit}
and a.volume_limit = #{volumeLimit}
</if>
<if test="locationSize != null and locationSize != ''">
and location_size = #{locationSize}
and a.location_size = #{locationSize}
</if>
<if test="locationLength != null ">
and location_length = #{locationLength}
and a.location_length = #{locationLength}
</if>
<if test="locationWidth != null ">
and location_width = #{locationWidth}
and a.location_width = #{locationWidth}
</if>
<if test="locationHeight != null ">
and location_height = #{locationHeight}
and a.location_height = #{locationHeight}
</if>
<if test="coordinate != null and coordinate != ''">
and coordinate = #{coordinate}
and a.coordinate = #{coordinate}
</if>
<if test="coordinateArea != null and coordinateArea != ''">
and coordinate_area = #{coordinateArea}
and a.coordinate_area = #{coordinateArea}
</if>
<if test="coordinateColumn != null and coordinateColumn != ''">
and coordinate_column = #{coordinateColumn}
and a.coordinate_column = #{coordinateColumn}
</if>
<if test="coordinateRow != null and coordinateRow != ''">
and coordinate_row = #{coordinateRow}
and a.coordinate_row = #{coordinateRow}
</if>
<if test="coordinateLayer != null and coordinateLayer != ''">
and coordinate_layer = #{coordinateLayer}
and a.coordinate_layer = #{coordinateLayer}
</if>
<if test="openingUp != null ">
and opening_up = #{openingUp}
and a.opening_up = #{openingUp}
</if>
<if test="nullify != null ">
and nullify = #{nullify}
and a.nullify = #{nullify}
</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="remark != null and remark != ''">
and remark like concat('%',#{remark},'%')
and a.remark like concat('%',#{remark},'%')
</if>
<choose>
<when test="delFlag != null"> and a.del_flag = #{delFlag} </when>
<otherwise> and a.del_flag = 1 </otherwise>
</choose>
</where>
</sql>
@@ -172,9 +186,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectStorageLocationPo1"/>
</select>
<select id="getStorageLocationCount" parameterType="com.mhd.basic.domain.storageLocation.repository.todo.StorageLocationDO" resultMap="StorageLocationResult">
<select id="getStorageLocationCount" parameterType="com.mhd.basic.domain.storageLocation.repository.todo.StorageLocationDO" resultType="java.lang.Long">
SELECT count(1)
from storage_locationfrom
from storage_location a
LEFT JOIN warehouse w ON a.warehouse_id = w.warehouse_id AND w.del_flag = 1
<include refid="selectStorageLocationPo1"/>
</select>
</mapper>
@@ -31,62 +31,72 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="selectStorageLocationGroupPo">
select storage_location_group_id, organization_id, organization_name, top_organization_id, warehouse_id, warehouse_code, warehouse_name, storage_section_id, storage_code, storage_name, storage_location_group_code, storage_location_group_name, remark, number, opening_up, nullify, create_time, create_by, create_by_name, update_time, update_by, update_by_name, del_flag from storage_location_group
select a.storage_location_group_id, a.organization_id, a.organization_name, a.top_organization_id, a.warehouse_id,
COALESCE(w.warehouse_code, a.warehouse_code) as warehouse_code,
COALESCE(w.warehouse_name, a.warehouse_name) as warehouse_name,
a.storage_section_id, a.storage_code, a.storage_name, a.storage_location_group_code, a.storage_location_group_name,
a.remark, a.number, a.opening_up, a.nullify, a.create_time, a.create_by, a.create_by_name, a.update_time, a.update_by, a.update_by_name, a.del_flag
from storage_location_group a
LEFT JOIN warehouse w ON a.warehouse_id = w.warehouse_id AND w.del_flag = 1
</sql>
<sql id="selectStorageLocationGroupPo1">
<where>
<if test="organizationId != null ">
and organization_id = #{organizationId}
and a.organization_id = #{organizationId}
</if>
<if test="organizationName != null and organizationName != ''">
and organization_name like concat('%', #{organizationName}, '%')
and a.organization_name like concat('%', #{organizationName}, '%')
</if>
<if test="topOrganizationId != null ">
and top_organization_id = #{topOrganizationId}
and a.top_organization_id = #{topOrganizationId}
</if>
<if test="warehouseId != null ">
and warehouse_id = #{warehouseId}
and a.warehouse_id = #{warehouseId}
</if>
<if test="warehouseCode != null and warehouseCode != ''">
and warehouse_code = #{warehouseCode}
and (w.warehouse_code like concat('%', #{warehouseCode}, '%') or a.warehouse_code like concat('%', #{warehouseCode}, '%'))
</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="storageSectionId != null ">
and storage_section_id = #{storageSectionId}
and a.storage_section_id = #{storageSectionId}
</if>
<if test="storageCode != null and storageCode != ''">
and storage_code = #{storageCode}
and a.storage_code = #{storageCode}
</if>
<if test="storageName != null and storageName != ''">
and storage_name like concat('%', #{storageName}, '%')
and a.storage_name like concat('%', #{storageName}, '%')
</if>
<if test="storageLocationGroupCode != null and storageLocationGroupCode != ''">
and storage_location_group_code = #{storageLocationGroupCode}
and a.storage_location_group_code = #{storageLocationGroupCode}
</if>
<if test="storageLocationGroupName != null and storageLocationGroupName != ''">
and storage_location_group_name like concat('%', #{storageLocationGroupName}, '%')
and a.storage_location_group_name like concat('%', #{storageLocationGroupName}, '%')
</if>
<if test="openingUp != null ">
and opening_up = #{openingUp}
and a.opening_up = #{openingUp}
</if>
<if test="nullify != null ">
and nullify = #{nullify}
and a.nullify = #{nullify}
</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="number != null">
and number = #{number}
and a.number = #{number}
</if>
<if test="remark != null and remark != ''">
and remark like concat('%',#{remark},'%')
and a.remark like concat('%',#{remark},'%')
</if>
<choose>
<when test="delFlag != null"> and a.del_flag = #{delFlag} </when>
<otherwise> and a.del_flag = 1 </otherwise>
</choose>
</where>
</sql>
@@ -31,59 +31,69 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="selectStorageSectionPo">
select storage_section_id, organization_id, organization_name, top_organization_id, warehouse_id, warehouse_code, warehouse_name, storage_code, storage_name, storage_type, storage_type_name, storage_region, remark, opening_up, nullify, create_time, create_by, create_by_name, update_time, update_by, update_by_name, del_flag from storage_section
select a.storage_section_id, a.organization_id, a.organization_name, a.top_organization_id, a.warehouse_id,
COALESCE(w.warehouse_code, a.warehouse_code) as warehouse_code,
COALESCE(w.warehouse_name, a.warehouse_name) as warehouse_name,
a.storage_code, a.storage_name, a.storage_type, a.storage_type_name, a.storage_region, a.remark, a.opening_up, a.nullify,
a.create_time, a.create_by, a.create_by_name, a.update_time, a.update_by, a.update_by_name, a.del_flag
from storage_section a
LEFT JOIN warehouse w ON a.warehouse_id = w.warehouse_id AND w.del_flag = 1
</sql>
<sql id="selectStorageSectionPo1">
<where>
<if test="organizationId != null ">
and organization_id = #{organizationId}
and a.organization_id = #{organizationId}
</if>
<if test="organizationName != null and organizationName != ''">
and organization_name like concat('%', #{organizationName}, '%')
and a.organization_name like concat('%', #{organizationName}, '%')
</if>
<if test="topOrganizationId != null ">
and top_organization_id = #{topOrganizationId}
and a.top_organization_id = #{topOrganizationId}
</if>
<if test="warehouseId != null ">
and warehouse_id = #{warehouseId}
and a.warehouse_id = #{warehouseId}
</if>
<if test="warehouseCode != null and warehouseCode != ''">
and warehouse_code = #{warehouseCode}
and (w.warehouse_code like concat('%', #{warehouseCode}, '%') or a.warehouse_code like concat('%', #{warehouseCode}, '%'))
</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="storageCode != null and storageCode != ''">
and storage_code = #{storageCode}
and a.storage_code = #{storageCode}
</if>
<if test="storageName != null and storageName != ''">
and storage_name like concat('%', #{storageName}, '%')
and a.storage_name like concat('%', #{storageName}, '%')
</if>
<if test="storageType != null and storageType != ''">
and storage_type = #{storageType}
and a.storage_type = #{storageType}
</if>
<if test="storageTypeName != null and storageTypeName != ''">
and storage_type_name like concat('%', #{storageTypeName}, '%')
and a.storage_type_name like concat('%', #{storageTypeName}, '%')
</if>
<if test="storageRegion != null ">
and storage_region = #{storageRegion}
and a.storage_region = #{storageRegion}
</if>
<if test="openingUp != null ">
and opening_up = #{openingUp}
and a.opening_up = #{openingUp}
</if>
<if test="nullify != null ">
and nullify = #{nullify}
and a.nullify = #{nullify}
</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="remark != null and remark != ''">
and remark like concat('%',#{remark},'%')
and a.remark like concat('%',#{remark},'%')
</if>
<choose>
<when test="delFlag != null"> and a.del_flag = #{delFlag} </when>
<otherwise> and a.del_flag = 1 </otherwise>
</choose>
</where>
</sql>