Files
nanguangszwlback/mhd_wms/src/main/resources/mapper/deliveTask/DeliveTaskMapper.xml
T

407 lines
18 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.wms.domain.deliveTask.repository.mapper.DeliveTaskMapper">
<resultMap type="com.mhd.wms.domain.deliveTask.repository.po.DeliveTaskPO" id="DeliveTaskResult">
<result property="deliverTaskId" column="deliver_task_id" />
<result property="taskNumber" column="task_number" />
<result property="trackingNumber" column="tracking_number" />
<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="warehouseCode" column="warehouse_code" />
<result property="warehouseName" column="warehouse_name" />
<result property="taskType" column="task_type" />
<result property="taskStatus" column="task_status" />
<result property="taskDistribution" column="task_distribution" />
<result property="taskDistributionTime" column="task_distribution_time" />
<result property="taskDistributionId" column="task_distribution_id" />
<result property="taskDistributionName" column="task_distribution_name" />
<result property="operatorsBy" column="operators_by" />
<result property="operatorsName" column="operators_name" />
<result property="remark" column="remark" />
<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" />
<result property="reassignTime" column="reassign_time" />
<result property="reassignById" column="reassign_by_id" />
<result property="reassignByName" column="reassign_by_name" />
</resultMap>
<resultMap type="com.mhd.wms.domain.deliveTask.repository.po.DeliveTaskSumPO" id="DeliveTaskResultSum">
<result property="receivedQuantity" column="receivedQuantity" />
<result property="listingQuantity" column="listingQuantity" />
<result property="pickQuantity" column="pickQuantity" />
<result property="recheckQuantity" column="recheckQuantity" />
<result property="displacementQuantity" column="displacementQuantity" />
<result property="stockQuantity" column="stockQuantity" />
<result property="handoverQuantity" column="handoverQuantity" />
</resultMap>
<resultMap type="com.mhd.wms.domain.deliveTask.repository.po.DeliveTaskPO" id="DeliveTaskResultTabSum">
<result property="designateSum" column="designateSum" />
<result property="taskSum" column="taskSum" />
</resultMap>
<sql id="selectDeliveTaskPo">
select deliver_task_id, task_number, tracking_number, organization_id, organization_name, top_organization_id, warehouse_id, warehouse_code, warehouse_name, task_type, task_status, task_distribution, task_distribution_time, task_distribution_id, task_distribution_name, operators_by, operators_name, remark, create_time, create_by, create_by_name, update_time, update_by, update_by_name, del_flag, reassign_time, reassign_by_id, reassign_by_name from delive_task
</sql>
<!-- taskStatus=0 未接收:历史数据 task_status 可能为 NULL,与 0 等价 -->
<sql id="deliveTaskStatusFilter">
<if test="taskStatus != null and taskStatus == 0">
and (task_status = 0 OR task_status IS NULL)
</if>
<if test="taskStatus != null and taskStatus != 0">
and task_status = #{taskStatus}
</if>
</sql>
<!-- 任务大厅 tabType=2:未指派作业人(按 operators_name 判断,与现场查询口径一致) -->
<sql id="deliveTaskHallUnassignedFilter">
and (operators_name IS NULL OR operators_name = '')
</sql>
<sql id="selectDeliveTaskPo1">
<where>
del_flag = 1
<if test="taskNumber != null and taskNumber != ''">
and task_number = #{taskNumber}
</if>
<if test="trackingNumber != null and trackingNumber != ''">
and tracking_number = #{trackingNumber}
</if>
<if test="organizationId != null ">
and organization_id = #{organizationId}
</if>
<if test="organizationIdList != null and organizationIdList.size() > 0">
and organization_id in
<foreach collection="organizationIdList" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="organizationName != null and organizationName != ''">
and organization_name like concat('%', #{organizationName}, '%')
</if>
<if test="topOrganizationId != null ">
and top_organization_id = #{topOrganizationId}
</if>
<if test="warehouseId != null ">
and warehouse_id = #{warehouseId}
</if>
<if test="warehouseCode != null and warehouseCode != ''">
and warehouse_code = #{warehouseCode}
</if>
<if test="warehouseName != null and warehouseName != ''">
and warehouse_name like concat('%', #{warehouseName}, '%')
</if>
<!-- taskType: 0-无 1-收货 2-上架 3-拣货 4-复核 5-移位 6-盘点 7-交接 -->
<if test="taskType != null and taskType != 0 ">
and task_type = #{taskType}
</if>
<!-- taskType=7 交接作业单时,按 handoverQueryType 过滤: 1-列表(未交接) 2-历史(已交接),不传默认1 -->
<if test="taskType != null and taskType == 7 and (handoverQueryType == null or handoverQueryType == 1)">
and EXISTS (SELECT 1 FROM handover_task_order hto WHERE hto.task_number = delive_task.tracking_number AND hto.del_flag = 1 AND hto.status = 1)
</if>
<if test="taskType != null and taskType == 7 and handoverQueryType == 2">
and EXISTS (SELECT 1 FROM handover_task_order hto WHERE hto.task_number = delive_task.tracking_number AND hto.del_flag = 1 AND hto.status = 2)
</if>
<include refid="deliveTaskStatusFilter"/>
<if test="taskDistribution != null ">
and task_distribution = #{taskDistribution}
</if>
<if test="taskDistributionTime != null ">
and task_distribution_time = #{taskDistributionTime}
</if>
<if test="taskDistributionId != null ">
and task_distribution_id = #{taskDistributionId}
</if>
<if test="taskDistributionName != null and taskDistributionName != ''">
and task_distribution_name like concat('%', #{taskDistributionName}, '%')
</if>
<if test="tabType != null and tabType==1">
and operators_by = #{operatorsBy}
</if>
<if test="tabType != null and tabType==2">
and operators_by IS NULL
</if>
<if test="tabType == null and operatorsBy != null">
and operators_by = #{operatorsBy}
</if>
<if test="operatorsName != null and operatorsName != ''">
and operators_name like concat('%', #{operatorsName}, '%')
</if>
<if test="reassignTime != null ">
and reassign_time = #{reassignTime}
</if>
<if test="reassignById != null ">
and reassign_by_id = #{reassignById}
</if>
<if test="reassignByName != null and reassignByName != ''">
and reassign_by_name like concat('%', #{reassignByName}, '%')
</if>
</where>
</sql>
<!-- PDA 下发任务列表:del_flag、组织、仓库、tabType(1=指派给我/2=任务大厅未领取) 等 -->
<sql id="selectDeliveTaskPoApp1">
<where>
del_flag = 1
<if test="taskNumber != null and taskNumber != ''">
and task_number = #{taskNumber}
</if>
<if test="trackingNumber != null and trackingNumber != ''">
and tracking_number = #{trackingNumber}
</if>
<if test="organizationId != null ">
and organization_id = #{organizationId}
</if>
<if test="organizationIdList != null and organizationIdList.size() > 0">
and organization_id in
<foreach collection="organizationIdList" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="organizationName != null and organizationName != ''">
and organization_name like concat('%', #{organizationName}, '%')
</if>
<if test="topOrganizationId != null ">
and top_organization_id = #{topOrganizationId}
</if>
<if test="warehouseId != null ">
and warehouse_id = #{warehouseId}
</if>
<if test="warehouseCode != null and warehouseCode != ''">
and warehouse_code = #{warehouseCode}
</if>
<if test="warehouseName != null and warehouseName != ''">
and warehouse_name like concat('%', #{warehouseName}, '%')
</if>
<if test="taskType != null and taskType != 0 ">
and task_type = #{taskType}
</if>
<if test="taskType != null and taskType == 7 and (handoverQueryType == null or handoverQueryType == 1)">
and EXISTS (SELECT 1 FROM handover_task_order hto WHERE hto.task_number = delive_task.tracking_number AND hto.del_flag = 1 AND hto.status = 1)
</if>
<if test="taskType != null and taskType == 7 and handoverQueryType == 2">
and EXISTS (SELECT 1 FROM handover_task_order hto WHERE hto.task_number = delive_task.tracking_number AND hto.del_flag = 1 AND hto.status = 2)
</if>
<include refid="deliveTaskStatusFilter"/>
<if test="taskDistribution != null ">
and task_distribution = #{taskDistribution}
</if>
<if test="taskDistributionTime != null ">
and task_distribution_time = #{taskDistributionTime}
</if>
<if test="taskDistributionId != null ">
and task_distribution_id = #{taskDistributionId}
</if>
<if test="taskDistributionName != null and taskDistributionName != ''">
and task_distribution_name like concat('%', #{taskDistributionName}, '%')
</if>
<if test="tabType != null and tabType==1">
and operators_by = #{operatorsBy}
</if>
<!-- 任务大厅 tabType=2:未领取;出库交接 taskType=7 不按 operators_name / PC已处理 过滤 -->
<if test="tabType != null and tabType==2">
<if test="taskType == null or taskType != 7">
<include refid="deliveTaskHallUnassignedFilter"/>
</if>
</if>
<if test="operatorsName != null and operatorsName != ''">
and operators_name like concat('%', #{operatorsName}, '%')
</if>
<if test="reassignTime != null ">
and reassign_time = #{reassignTime}
</if>
<if test="reassignById != null ">
and reassign_by_id = #{reassignById}
</if>
<if test="reassignByName != null and reassignByName != ''">
and reassign_by_name like concat('%', #{reassignByName}, '%')
</if>
</where>
</sql>
<sql id="selectDeliveTaskPo2">
<if test="organizationId != null ">
and organization_id = #{organizationId}
</if>
<if test="organizationIdList != null and organizationIdList.size() > 0">
and organization_id in
<foreach collection="organizationIdList" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="taskNumber != null and taskNumber != ''">
and task_number = #{taskNumber}
</if>
<if test="trackingNumber != null and trackingNumber != ''">
and tracking_number = #{trackingNumber}
</if>
<if test="topOrganizationId != null ">
and top_organization_id = #{topOrganizationId}
</if>
<if test="warehouseId != null ">
and warehouse_id = #{warehouseId}
</if>
<if test="warehouseCode != null and warehouseCode != ''">
and warehouse_code = #{warehouseCode}
</if>
<if test="warehouseName != null and warehouseName != ''">
and warehouse_name like concat('%', #{warehouseName}, '%')
</if>
<if test="taskType != null ">
and task_type = #{taskType}
</if>
<!-- taskType=7 交接作业单时,按 handoverQueryType 过滤: 1-列表(未交接) 2-历史(已交接),不传默认1 -->
<if test="taskType != null and taskType == 7 and (handoverQueryType == null or handoverQueryType == 1)">
and EXISTS (SELECT 1 FROM handover_task_order hto WHERE hto.task_number = delive_task.tracking_number AND hto.del_flag = 1 AND hto.status = 1)
</if>
<if test="taskType != null and taskType == 7 and handoverQueryType == 2">
and EXISTS (SELECT 1 FROM handover_task_order hto WHERE hto.task_number = delive_task.tracking_number AND hto.del_flag = 1 AND hto.status = 2)
</if>
<include refid="deliveTaskStatusFilter"/>
<if test="taskDistribution != null ">
and task_distribution = #{taskDistribution}
</if>
<if test="taskDistributionTime != null ">
and task_distribution_time = #{taskDistributionTime}
</if>
<if test="taskDistributionId != null ">
and task_distribution_id = #{taskDistributionId}
</if>
<if test="taskDistributionName != null and taskDistributionName != ''">
and task_distribution_name like concat('%', #{taskDistributionName}, '%')
</if>
<if test="reassignTime != null ">
and reassign_time = #{reassignTime}
</if>
<if test="reassignById != null ">
and reassign_by_id = #{reassignById}
</if>
<if test="reassignByName != null and reassignByName != ''">
and reassign_by_name like concat('%', #{reassignByName}, '%')
</if>
</sql>
<select id="queryList" parameterType="com.mhd.wms.domain.deliveTask.repository.todo.DeliveTaskDO" resultMap="DeliveTaskResult">
<include refid="selectDeliveTaskPo"/>
<include refid="selectDeliveTaskPo1"/>
order by create_time desc
</select>
<select id="queryListApp" parameterType="com.mhd.wms.domain.deliveTask.repository.todo.DeliveTaskDO" resultMap="DeliveTaskResult">
<include refid="selectDeliveTaskPo"/>
<include refid="selectDeliveTaskPoApp1"/>
order by create_time desc
</select>
<select id="workbenchQuery" parameterType="java.lang.Long" resultMap="DeliveTaskResultSum">
SELECT
(
SELECT
COUNT(1)
FROM
stock_receipt_order
WHERE
del_flag = 1
AND status &lt; 3
and operators_by = #{operatorsBy}
) receivedQuantity,
(
SELECT
COUNT(1)
FROM
stock_shelf_order
WHERE
del_flag = 1
AND status &lt; 3
and operators_by = #{operatorsBy}
) listingQuantity,
(
SELECT
COUNT(1)
FROM
stock_out_task_order
WHERE
del_flag = 1
AND status &lt; 3
and operators_by = #{operatorsBy}
) pickQuantity,
(
SELECT
COUNT(1)
FROM
stock_out_order
WHERE
del_flag = 1
AND review = 1
AND check_status &lt; 3
and check_operators_by = #{operatorsBy}
) recheckQuantity,
(
SELECT
COUNT(1)
FROM
shift_manage
WHERE
del_flag = 1
AND audit_status = 3
AND shift_status &lt; 4
and operators_by = #{operatorsBy}
) displacementQuantity,
(
SELECT
COUNT(1)
FROM
investigation_manage
WHERE
del_flag = 1
AND audit_status = 3
AND investigation_status &lt; 4
and operators_by = #{operatorsBy}
) stockQuantity,
(
SELECT
COUNT(1)
FROM
handover_task_order
WHERE
del_flag = 1
AND task_distribution = 1
AND status = 1
AND operators_by = #{operatorsBy}
) handoverQuantity
</select>
<select id="querySum" parameterType="com.mhd.wms.domain.deliveTask.repository.todo.DeliveTaskDO" resultMap="DeliveTaskResultTabSum">
SELECT
(
SELECT
COUNT(1)
FROM
delive_task
WHERE
del_flag = 1
AND operators_by = #{operatorsBy}
<include refid="selectDeliveTaskPo2"/>
) designateSum,
(
SELECT
COUNT(1)
FROM
delive_task
WHERE
del_flag = 1
<include refid="deliveTaskHallUnassignedFilter"/>
<include refid="selectDeliveTaskPo2"/>
) taskSum
</select>
</mapper>