<?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.ruoyi.stock.mapper.StockOutRecordMapper">
|
|
<!-- 通用查询映射结果 -->
|
<resultMap id="BaseResultMap" type="com.ruoyi.stock.pojo.StockOutRecord">
|
<id column="id" property="id" />
|
<result column="outbound_batches" property="outboundBatches" />
|
<result column="stock_out_num" property="stockOutNum" />
|
<result column="record_id" property="recordId" />
|
<result column="record_type" property="recordType" />
|
<result column="product_model_id" property="productModelId" />
|
<result column="remark" property="remark" />
|
<result column="create_time" property="createTime" />
|
<result column="update_time" property="updateTime" />
|
<result column="create_user" property="createUser" />
|
<result column="update_user" property="updateUser" />
|
</resultMap>
|
|
<select id="listPage" resultType="com.ruoyi.stock.dto.StockOutRecordDto">
|
WITH RECURSIVE product_tree AS (
|
SELECT id
|
FROM product
|
WHERE id = #{params.topParentProductId}
|
|
UNION ALL
|
|
SELECT p.id
|
FROM product p
|
INNER JOIN product_tree pt ON p.parent_id = pt.id
|
)
|
SELECT
|
sor.*,
|
p.product_name as productName,
|
pm.model,
|
pm.unit,
|
u.nick_name as createBy
|
FROM stock_out_record as sor
|
LEFT JOIN product_model as pm on sor.product_model_id = pm.id
|
LEFT JOIN product as p on pm.product_id = p.id
|
LEFT JOIN sys_user as u on sor.create_user = u.user_id
|
<where>
|
<if test="params.timeStr != null and params.timeStr != ''">
|
and sor.create_time like concat('%',#{params.timeStr},'%')
|
</if>
|
<if test="params.productName != null and params.productName != ''">
|
and p.product_name like concat('%',#{params.productName},'%')
|
</if>
|
<if test="params.type != null and params.type != ''">
|
and sor.type = #{params.type}
|
</if>
|
<if test="params.recordType != null and params.recordType != ''">
|
and sor.record_type = #{params.recordType}
|
</if>
|
<if test="params.topParentProductId != null and params.topParentProductId > 0">
|
and p.id in (select id from product_tree)
|
</if>
|
</where>
|
order by sor.id desc
|
</select>
|
<select id="listStockOutRecordExportData" resultType="com.ruoyi.stock.execl.StockOutRecordExportData">
|
SELECT
|
sor.*,
|
p.product_name as productName,
|
pm.model,
|
pm.unit,
|
u.nick_name as createBy
|
FROM stock_out_record as sor
|
LEFT JOIN product_model as pm on sor.product_model_id = pm.id
|
LEFT JOIN product as p on pm.product_id = p.id
|
LEFT JOIN sys_user as u on sor.create_user = u.user_id
|
<where>
|
<if test="params.timeStr != null and params.timeStr != ''">
|
and sor.create_time like concat('%',#{params.timeStr},'%')
|
</if>
|
<if test="params.productName != null and params.productName != ''">
|
and p.product_name like concat('%',#{params.productName},'%')
|
</if>
|
<if test="params.type != null and params.type != ''">
|
and sor.type = #{params.type}
|
</if>
|
<if test="params.recordType != null and params.recordType != ''">
|
and sor.record_type = #{params.recordType}
|
</if>
|
</where>
|
order by sor.id desc
|
</select>
|
|
<select id="listPageAccountSales" resultType="com.ruoyi.account.bean.vo.SalesOutboundVo">
|
SELECT
|
sor.id,
|
sor.outbound_batches,
|
sl.customer_name,
|
s.shipping_date,
|
p.product_name,
|
pm.model as specification_model,
|
sor.stock_out_num * slp.tax_inclusive_unit_price as outboundAmount,
|
s.shipping_no,
|
sl.sales_contract_no
|
FROM stock_out_record sor
|
left join shipping_info s on sor.record_id = s.id
|
LEFT JOIN sales_ledger sl ON s.sales_ledger_id = sl.id
|
LEFT JOIN sales_ledger_product slp ON s.sales_ledger_product_id = slp.id and slp.type = 1
|
left join product_model pm on slp.product_model_id = pm.id
|
left join product p on pm.product_id = p.id
|
WHERE s.status='已发货' and sor.record_type='13'
|
<if test="req.outboundBatches != null and req.outboundBatches != ''">
|
AND sor.outbound_batches LIKE CONCAT('%',#{req.outboundBatches},'%')
|
</if>
|
<if test="req.customerName != null and req.customerName != ''">
|
AND sl.customer_name LIKE CONCAT('%',#{req.customerName},'%')
|
</if>
|
<if test="req.startDate != null and req.endDate != null">
|
AND s.shipping_date BETWEEN #{startDate} AND #{endDate}
|
</if>
|
order by sor.id DESC
|
</select>
|
</mapper>
|