|
|
|
@ -298,68 +298,29 @@
|
|
|
|
|
t0.quality,
|
|
|
|
|
t0.incomeTime,
|
|
|
|
|
t0.supplierCode,
|
|
|
|
|
t0.supplierName
|
|
|
|
|
t0.supplierName,
|
|
|
|
|
t0.check_Type
|
|
|
|
|
from (
|
|
|
|
|
select t.*,bp.warehouse_cycle,
|
|
|
|
|
case when qct.create_time is not null then DATEDIFF(day, qct.create_time, GETDATE())
|
|
|
|
|
else DATEDIFF(day, t.incomeTime, GETDATE()) end days
|
|
|
|
|
from (
|
|
|
|
|
SELECT
|
|
|
|
|
wms_raw_order_in_sn.po_no AS orderNo,
|
|
|
|
|
wms_raw_order_in_sn.material_code AS materialCode,
|
|
|
|
|
wms_raw_order_in_sn.material_desc AS materialName,
|
|
|
|
|
COUNT(wms_raw_order_in_sn.amount) AS quality,
|
|
|
|
|
wms_raw_order_in_sn.gmt_create incomeTime,
|
|
|
|
|
wms_raw_order_in_sn.wh_code supplierCode,
|
|
|
|
|
base_warehouse.warehouse_name supplierName,
|
|
|
|
|
wms_raw_order_in_sn.user_defined4 unit
|
|
|
|
|
FROM
|
|
|
|
|
wms_raw_order_in_sn
|
|
|
|
|
LEFT JOIN base_warehouse ON base_warehouse.warehouse_code=wms_raw_order_in_sn.wh_code
|
|
|
|
|
WHERE
|
|
|
|
|
wms_raw_order_in_sn.active_flag = '1'
|
|
|
|
|
GROUP BY
|
|
|
|
|
wms_raw_order_in_sn.wh_code,
|
|
|
|
|
wms_raw_order_in_sn.po_no,
|
|
|
|
|
wms_raw_order_in_sn.material_code,
|
|
|
|
|
wms_raw_order_in_sn.material_desc,
|
|
|
|
|
wms_raw_order_in_sn.user_defined4,
|
|
|
|
|
base_warehouse.warehouse_code,
|
|
|
|
|
base_warehouse.warehouse_name,
|
|
|
|
|
wms_raw_order_in_sn.gmt_create
|
|
|
|
|
union all
|
|
|
|
|
SELECT
|
|
|
|
|
wms_fp_storage_news_sn.order_no,
|
|
|
|
|
wms_fp_storage_news_sn.product_name,
|
|
|
|
|
wms_fp_storage_news_sn.product_code,
|
|
|
|
|
SUM ( wms_fp_storage_news_sn.amount ) AS total_amount,
|
|
|
|
|
wms_fp_storage_news_sn.gmt_create,
|
|
|
|
|
wms_fp_storage_news_sn.wh_code ,
|
|
|
|
|
base_warehouse.warehouse_name,
|
|
|
|
|
wms_fp_storage_news_sn.user_defined3
|
|
|
|
|
FROM
|
|
|
|
|
wms_fp_storage_news_sn
|
|
|
|
|
LEFT JOIN base_warehouse ON base_warehouse.warehouse_code=wms_fp_storage_news_sn.wh_code
|
|
|
|
|
WHERE
|
|
|
|
|
wms_fp_storage_news_sn.active_flag = '1'
|
|
|
|
|
GROUP BY
|
|
|
|
|
wms_fp_storage_news_sn.order_no,
|
|
|
|
|
wms_fp_storage_news_sn.product_name,
|
|
|
|
|
wms_fp_storage_news_sn.product_code,
|
|
|
|
|
wms_fp_storage_news_sn.gmt_create,
|
|
|
|
|
wms_fp_storage_news_sn.user_defined3,
|
|
|
|
|
base_warehouse.warehouse_code,
|
|
|
|
|
base_warehouse.warehouse_name,
|
|
|
|
|
wms_fp_storage_news_sn.wh_code
|
|
|
|
|
) t
|
|
|
|
|
left join base_product_attached bp on t.materialCode = concat('0000000',bp.product_code)
|
|
|
|
|
left join (
|
|
|
|
|
select t.order_no orderNo,
|
|
|
|
|
t.material_code materialCode,
|
|
|
|
|
t.material_name materialName,
|
|
|
|
|
t.quality quality,
|
|
|
|
|
t.income_time incomeTime,
|
|
|
|
|
t.supplier_code supplierCode,
|
|
|
|
|
t.supplier_name supplierName,
|
|
|
|
|
t.check_type check_Type,
|
|
|
|
|
bp.warehouse_cycle,
|
|
|
|
|
case when qct.create_time is not null then DATEDIFF(day, qct.create_time, GETDATE())
|
|
|
|
|
else DATEDIFF(day, t.income_time, GETDATE()) end days
|
|
|
|
|
from qc_check_task t
|
|
|
|
|
left join base_product_attached bp on t.material_code = concat('0000000',bp.product_code)
|
|
|
|
|
left join (
|
|
|
|
|
select order_no,material_code,max(create_time) create_time
|
|
|
|
|
from qc_check_task where check_type='checkTypeCC' and del_flag = '0' GROUP BY order_no,material_code
|
|
|
|
|
) qct on qct.order_no = t.orderNo
|
|
|
|
|
and t.materialCode = qct.material_code
|
|
|
|
|
where bp.warehouse_cycle is not null
|
|
|
|
|
)t0
|
|
|
|
|
) qct on qct.order_no = t.order_no
|
|
|
|
|
and t.material_code = qct.material_code
|
|
|
|
|
where bp.warehouse_cycle is not null and t.check_type in('checkTypeLL','checkTypeCP') and t.del_flag = '0'
|
|
|
|
|
)t0
|
|
|
|
|
where t0.days >= t0.warehouse_cycle
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|