You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
175 lines
8.9 KiB
175 lines
8.9 KiB
<?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.gaotao.modules.report.dao.InboundNotificationReportMapper">
|
|
|
|
<!-- 查询收货入库任务报表数据(分页) -->
|
|
<select id="searchInboundNotificationReport" resultType="com.gaotao.modules.report.entity.InboundNotificationReportData">
|
|
SELECT
|
|
h.site,
|
|
h.bu_no AS buNo,
|
|
h.order_no AS orderNo,
|
|
h.order_type AS orderType,
|
|
h.order_status AS orderStatus,
|
|
CASE
|
|
WHEN ISNULL(d.required_qty, 0) = 0 THEN '0%'
|
|
ELSE CONCAT(CAST(ROUND(ISNULL(d.actual_in_qty, 0) * 100.0 / d.required_qty, 1) AS VARCHAR), '%')
|
|
END AS completionRate,
|
|
h.supplier_id AS supplierId,
|
|
s.SupplierName AS supplierName,
|
|
h.related_order_no AS relatedOrderNo,
|
|
h.related_order_line_no AS relatedOrderLineNo,
|
|
h.required_inbound_date AS requiredInboundDate,
|
|
h.remarks,
|
|
h.erp_order_no AS erpOrderNo,
|
|
h.erp_order_line_no AS erpOrderLineNo,
|
|
h.erp_order_date AS erpOrderDate,
|
|
h.created_by AS createdBy,
|
|
h.created_date AS createdDate,
|
|
h.updated_by AS updatedBy,
|
|
h.updated_date AS updatedDate,
|
|
h.assigned_by AS assignedBy,
|
|
h.assigned_date AS assignedDate,
|
|
h.closed_by AS closedBy,
|
|
h.closed_date AS closedDate,
|
|
h.close_flag AS closeFlag,
|
|
h.in_warehouse AS inWarehouse,
|
|
wh.WareHouseName AS inWarehouseName,
|
|
d.part_no AS detailPartNo,
|
|
d.part_desc AS detailPartDesc,
|
|
d.unit,
|
|
um.umName,
|
|
d.required_qty AS requiredQty,
|
|
d.order_qty AS orderQty,
|
|
d.actual_in_qty AS actualInQty,
|
|
d.in_warehouse AS detailInWarehouse,
|
|
dwh.WareHouseName AS detailInWarehouseName,
|
|
d.in_batch_no AS inBatchNo,
|
|
d.related_order_no AS detailRelatedOrderNo,
|
|
d.related_order_line_no AS detailRelatedOrderLineNo,
|
|
d.roll_no AS rollNo,
|
|
h.department_no AS departmentNo,
|
|
dep.department_desc AS departmentName
|
|
FROM inbound_notification_head h WITH(NOLOCK)
|
|
LEFT JOIN Supplier s WITH(NOLOCK) ON h.site = s.site AND h.supplier_id = s.SupplierID
|
|
LEFT JOIN WareHouse wh WITH(NOLOCK) ON h.site = wh.site AND h.bu_no = wh.bu_no AND h.in_warehouse = wh.WareHouseID
|
|
LEFT JOIN inbound_notification_detail d WITH(NOLOCK) ON h.site = d.site AND h.bu_no = d.bu_no AND h.order_no = d.order_no
|
|
LEFT JOIN WareHouse dwh WITH(NOLOCK) ON d.site = dwh.site AND d.bu_no = dwh.bu_no AND d.in_warehouse = dwh.WareHouseID
|
|
LEFT JOIN um WITH(NOLOCK) ON d.site = um.site AND d.unit = um.UMID
|
|
LEFT JOIN erp_department dep WITH(NOLOCK) ON h.department_no = dep.department_no
|
|
<where>
|
|
h.site IN (SELECT site FROM AccessSite WHERE UPPER(userID) = UPPER(#{userName}))
|
|
AND h.bu_no IN (SELECT bu_no FROM AccessBu WHERE UPPER(username) = UPPER(#{userName}))
|
|
<if test="query.site != null and query.site != ''">
|
|
AND h.site = #{query.site}
|
|
</if>
|
|
<if test="query.orderNo != null and query.orderNo != ''">
|
|
AND h.order_no LIKE '%' + #{query.orderNo} + '%'
|
|
</if>
|
|
<if test="query.orderType != null and query.orderType != ''">
|
|
AND h.order_type = #{query.orderType}
|
|
</if>
|
|
<if test="query.orderStatus != null and query.orderStatus != ''">
|
|
AND h.order_status = #{query.orderStatus}
|
|
</if>
|
|
<if test="query.orderStatus == null or query.orderStatus == ''">
|
|
AND h.order_status IN ('草稿', '编辑中', '待入库', '已入库', '已关闭')
|
|
</if>
|
|
<if test="query.supplierId != null and query.supplierId != ''">
|
|
AND h.supplier_id LIKE '%' + #{query.supplierId} + '%'
|
|
</if>
|
|
<if test="query.supplierName != null and query.supplierName != ''">
|
|
AND s.SupplierName LIKE '%' + #{query.supplierName} + '%'
|
|
</if>
|
|
<if test="query.partNo != null and query.partNo != ''">
|
|
AND d.part_no LIKE '%' + #{query.partNo} + '%'
|
|
</if>
|
|
<if test="query.partDesc != null and query.partDesc != ''">
|
|
AND d.part_desc LIKE '%' + #{query.partDesc} + '%'
|
|
</if>
|
|
<if test="query.startDate != null">
|
|
AND h.required_inbound_date >= #{query.startDate}
|
|
</if>
|
|
<if test="query.endDate != null">
|
|
AND h.required_inbound_date <= #{query.endDate}
|
|
</if>
|
|
<if test="query.queryRelatedOrderNo != null and query.queryRelatedOrderNo != ''">
|
|
AND d.related_order_no LIKE '%' + #{query.queryRelatedOrderNo} + '%'
|
|
</if>
|
|
<if test="query.queryRelatedOrderLineNo != null and query.queryRelatedOrderLineNo != ''">
|
|
AND d.related_order_line_no LIKE '%' + #{query.queryRelatedOrderLineNo} + '%'
|
|
</if>
|
|
<if test="query.rollNo != null and query.rollNo != ''">
|
|
AND d.roll_no LIKE '%' + #{query.rollNo} + '%'
|
|
</if>
|
|
<if test="query.departmentNo != null and query.departmentNo != ''">
|
|
AND h.department_no = #{query.departmentNo}
|
|
</if>
|
|
</where>
|
|
ORDER BY h.created_date DESC, h.order_no, d.part_no
|
|
OFFSET #{offset} ROWS FETCH NEXT #{limit} ROWS ONLY
|
|
</select>
|
|
|
|
<!-- 查询收货入库任务报表数据总数 -->
|
|
<select id="countInboundNotificationReport" resultType="int">
|
|
SELECT COUNT(1)
|
|
FROM inbound_notification_head h WITH(NOLOCK)
|
|
LEFT JOIN Supplier s WITH(NOLOCK) ON h.site = s.site AND h.supplier_id = s.SupplierID
|
|
LEFT JOIN inbound_notification_detail d WITH(NOLOCK) ON h.site = d.site AND h.bu_no = d.bu_no AND h.order_no = d.order_no
|
|
<where>
|
|
h.site IN (SELECT site FROM AccessSite WHERE UPPER(userID) = UPPER(#{userName}))
|
|
AND h.bu_no IN (SELECT bu_no FROM AccessBu WHERE UPPER(username) = UPPER(#{userName}))
|
|
<if test="query.site != null and query.site != ''">
|
|
AND h.site = #{query.site}
|
|
</if>
|
|
<if test="query.orderNo != null and query.orderNo != ''">
|
|
AND h.order_no LIKE '%' + #{query.orderNo} + '%'
|
|
</if>
|
|
<if test="query.orderType != null and query.orderType != ''">
|
|
AND h.order_type = #{query.orderType}
|
|
</if>
|
|
<if test="query.orderStatus != null and query.orderStatus != ''">
|
|
AND h.order_status = #{query.orderStatus}
|
|
</if>
|
|
<if test="query.orderStatus == null or query.orderStatus == ''">
|
|
AND h.order_status IN ('草稿', '编辑中', '待入库', '已入库', '已关闭')
|
|
</if>
|
|
<if test="query.supplierId != null and query.supplierId != ''">
|
|
AND h.supplier_id LIKE '%' + #{query.supplierId} + '%'
|
|
</if>
|
|
<if test="query.supplierName != null and query.supplierName != ''">
|
|
AND s.SupplierName LIKE '%' + #{query.supplierName} + '%'
|
|
</if>
|
|
<if test="query.partNo != null and query.partNo != ''">
|
|
AND d.part_no LIKE '%' + #{query.partNo} + '%'
|
|
</if>
|
|
<if test="query.partDesc != null and query.partDesc != ''">
|
|
AND d.part_desc LIKE '%' + #{query.partDesc} + '%'
|
|
</if>
|
|
<if test="query.startDate != null">
|
|
AND h.required_inbound_date >= #{query.startDate}
|
|
</if>
|
|
<if test="query.endDate != null">
|
|
AND h.required_inbound_date <= #{query.endDate}
|
|
</if>
|
|
<if test="query.queryRelatedOrderNo != null and query.queryRelatedOrderNo != ''">
|
|
AND d.related_order_no LIKE '%' + #{query.queryRelatedOrderNo} + '%'
|
|
</if>
|
|
<if test="query.queryRelatedOrderLineNo != null and query.queryRelatedOrderLineNo != ''">
|
|
AND d.related_order_line_no LIKE '%' + #{query.queryRelatedOrderLineNo} + '%'
|
|
</if>
|
|
<if test="query.rollNo != null and query.rollNo != ''">
|
|
AND d.roll_no LIKE '%' + #{query.rollNo} + '%'
|
|
</if>
|
|
<if test="query.departmentNo != null and query.departmentNo != ''">
|
|
AND h.department_no = #{query.departmentNo}
|
|
</if>
|
|
</where>
|
|
</select>
|
|
|
|
<!-- 获取用户可访问的site列表 -->
|
|
<select id="getAccessSiteList" resultType="java.lang.String">
|
|
SELECT site FROM AccessSite WHERE UPPER(userID) = UPPER(#{userName}) ORDER BY site
|
|
</select>
|
|
|
|
</mapper>
|