O
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.
 
 
 
 
 
 

58 lines
2.5 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.xujie.sys.modules.pms.mapper.PurchaseOrderMapper">
<select id="queryPurchaseOrder" resultType="com.xujie.sys.modules.pms.entity.PurchaseOrder">
select po.id,
po.site,
po.bu_no,
po.part_no,
po.inventory_stock_id,
po.qty,
po.status,
po.create_by,
po.create_time,
po.purchase_order_no,
po.quantity_of_arrival,
ps.part_description,
ps.umid,
dbo.get_bu_desc(po.site, po.bu_no) as bu_desc
from purchase_order po
left join part_spare ps on po.site = ps.site and po.part_no = ps.part_no and po.bu_no = ps.bu_no
left join accessBu ab on po.site = ab.site and po.bu_no = ab.bu_no and ab.username = #{params.createBy}
<where>
ab.username is not null
<if test="params.site != null and params.site != ''">
and po.site = #{params.site}
</if>
<if test="params.partNo != null and params.partNo != ''">
and po.part_no like '%'+ #{params.partNo} +'%'
</if>
<if test="params.partDescription != null and params.partDescription != ''">
and ps.part_description like '%'+ #{params.partDescription} + '%'
</if>
<if test="params.buNo != null and params.buNo != ''">
and po.bu_no = #{params.buNo}
</if>
<if test="params.status != null and params.status != ''">
and po.status = #{params.status}
</if>
<if test="params.startDate != null">
and po.create_time >= #{params.startDate}
</if>
<if test="params.endDate != null">
and po.create_time <![CDATA[<=]]> #{params.endDate}
</if>
</where>
order by po.id desc
</select>
<select id="queryPurchaseOrderNo" resultType="java.lang.String">
SELECT 'P' + CONVERT(CHAR(8), GETDATE(), 112) +
RIGHT('00000' + CAST(ISNULL(MAX(CAST(SUBSTRING(purchase_order_no, 10, 5) AS INT)), 0) + 1 AS VARCHAR(5)),5)
AS purchase_order_no
FROM dbo.purchase_order
WHERE purchase_order_no LIKE 'P' + CONVERT(CHAR(8), GETDATE(), 112) + '%'
</select>
</mapper>