Browse Source

修改sql

java8
赵宏斌 4 weeks ago
parent
commit
7b5a91c7a7
  1. 24
      src/main/resources/mapper/pms/InventoryStockMapper.xml

24
src/main/resources/mapper/pms/InventoryStockMapper.xml

@ -260,10 +260,28 @@
LEFT JOIN resource B ON ewc.site = b.site AND d.objectid = b.resource_id
LEFT JOIN view_Supplier v ON ps.site = V.Site AND ps.supplier_id = V.SupplierID
WHERE ps.coreFlag = 'Y'
<if test="query.site != null and query.site != ''">
and ewc.site = #{query.site}
</if>
<if test="query.buNo != null and query.buNo != ''">
and ewc.bu_no = #{query.buNo}
</if>
<if test="query.partNo != null and query.partNo != ''">
and ewc.partNo = #{query.partNo}
</if>
<if test="query.partDescription != null and query.partDescription != ''">
and ps.part_description like '%'+ #{query.partDescription} +'%'
</if>
)
SELECT OrderNo, site, bu_no, partno, part_description, oldSerialNo, newSerialNo,
created_date, spec, umid, remark, created_by, fault_reason, resource_id, resourceDesc,location_id,est_use_qty,lifespan,SupplierName
SELECT
OrderNo, site, bu_no, partno, part_description, oldSerialNo, newSerialNo,
created_date, spec, umid, remark, created_by, fault_reason, resource_id, resourceDesc,
location_id, est_use_qty, lifespan, SupplierName
FROM (
SELECT *,
ROW_NUMBER() OVER (PARTITION BY site,bu_no,partno,oldSerialNo ORDER BY created_date ASC) AS rn2
FROM ranked_records
WHERE rn > 1;
) AS subquery
WHERE rn > 1 and rn2 = 1;
</select>
</mapper>
Loading…
Cancel
Save