| | |
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.ruoyi.sales.mapper.ShippingInfoMapper"> |
| | | |
| | | <!-- |
| | | 发货台账列表 = 发货单(shipping_info) UNION ALL 销售类油品出库(stock_out_record)。 |
| | | 两分支列顺序必须严格一致(共 31 列),列名以分支 A 为准。 |
| | | 注意:数据权限拦截器只给第一个 from 的表加条件,分支 B 需在本 XML 里自行补同等过滤。 |
| | | --> |
| | | <select id="listPage" resultType="com.ruoyi.sales.dto.ShippingInfoDto"> |
| | | SELECT |
| | | s.id, |
| | |
| | | p.product_name, |
| | | sl.customer_name, |
| | | spd.totalQuantity, |
| | | sor.outboundBatches |
| | | sor.outboundBatches, |
| | | 'shipping' as source, |
| | | NULL as stockOutRecordId, |
| | | NULL as outCategory, |
| | | NULL as tankNo, |
| | | NULL as oilProduct, |
| | | NULL as oilDepotName, |
| | | NULL as driverName, |
| | | NULL as contactPerson, |
| | | NULL as contactPhone, |
| | | NULL as outBatchNo |
| | | FROM shipping_info s |
| | | LEFT JOIN (select shipping_info_id,sum(quantity) totalQuantity from shipping_product_detail GROUP BY shipping_info_id) spd ON spd.shipping_info_id = s.id |
| | | LEFT JOIN sales_ledger sl ON s.sales_ledger_id = sl.id |
| | |
| | | <if test="req.expressNumber != null and req.expressNumber != ''"> |
| | | AND s.express_number LIKE CONCAT('%',#{req.expressNumber},'%') |
| | | </if> |
| | | UNION ALL |
| | | SELECT |
| | | o.id, |
| | | NULL as sales_ledger_id, |
| | | o.out_date as shipping_date, |
| | | o.truck_plate_no as shipping_car_number, |
| | | NULL as express_number, |
| | | NULL as express_company, |
| | | o.outbound_batches as shipping_no, |
| | | NULL as type, |
| | | '已发货' as status, |
| | | o.create_time, |
| | | o.update_time, |
| | | o.create_user, |
| | | o.update_user, |
| | | NULL as tenant_id, |
| | | NULL as sales_contract_no, |
| | | pm2.model as specification_model, |
| | | pm2.unit, |
| | | p2.product_name, |
| | | o.customer_name, |
| | | o.stock_out_num as totalQuantity, |
| | | o.outbound_batches as outboundBatches, |
| | | 'oilOut' as source, |
| | | o.id as stockOutRecordId, |
| | | o.out_category as outCategory, |
| | | o.tank_no as tankNo, |
| | | o.oil_product as oilProduct, |
| | | o.oil_depot_name as oilDepotName, |
| | | o.driver_name as driverName, |
| | | o.contact_person as contactPerson, |
| | | o.contact_phone as contactPhone, |
| | | o.batch_no as outBatchNo |
| | | FROM stock_out_record o |
| | | left join product_model pm2 on pm2.id = o.product_model_id |
| | | left join product p2 on p2.id = pm2.product_id |
| | | WHERE o.out_category = '销售' AND o.approval_status = 1 |
| | | <!-- 油品出库没有合同号/快递单,按这两项筛选时不应返回任何油品行 --> |
| | | <if test="req.salesContractNo != null and req.salesContractNo != ''"> |
| | | AND 1=0 |
| | | </if> |
| | | <if test="req.expressNumber != null and req.expressNumber != ''"> |
| | | AND 1=0 |
| | | </if> |
| | | <if test="req.shippingCarNumber != null and req.shippingCarNumber != ''"> |
| | | AND o.truck_plate_no LIKE CONCAT('%',#{req.shippingCarNumber},'%') |
| | | </if> |
| | | <if test="req.shippingNo != null and req.shippingNo != ''"> |
| | | AND o.outbound_batches LIKE CONCAT('%',#{req.shippingNo},'%') |
| | | </if> |
| | | <if test="req.createUser != null"> |
| | | AND o.create_user = #{req.createUser} |
| | | </if> |
| | | <if test="req.deptId != null"> |
| | | AND o.dept_id = #{req.deptId} |
| | | </if> |
| | | <if test="req.deptIds != null and req.deptIds.length > 0"> |
| | | AND o.dept_id IN |
| | | <foreach collection="req.deptIds" item="deptId" open="(" separator="," close=")"> |
| | | #{deptId} |
| | | </foreach> |
| | | </if> |
| | | order by create_time DESC |
| | | </select> |
| | | <select id="listAll" resultType="com.ruoyi.sales.pojo.ShippingInfo"> |