<?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.fjhx.wms.mapper.stock.StockJournalDetailsMapper">
    <select id="getPage" resultType="com.fjhx.wms.entity.stock.vo.StockJournalDetailsVo">
        SELECT sjd.id,
               sj.op_type,
               sj.type,
               sj.`code`,
               sj.warehouse_id,
               w.`name` warehouseName,
               sjd.product_id,
               sjd.quantity,
               sjd.create_time,
               sjd.create_user,
               sj.business_id,
               sjd.stock_journal_id,
               IF(sj.type in(1,2),(select wo.`code` from bytesailing_mes.work_order wo where sj.work_order_id = wo.id and wo.del_flag=0),'')  as workOrderCode
        FROM stock_journal_details sjd
                 LEFT JOIN stock_journal sj ON sjd.stock_journal_id = sj.id
                 LEFT JOIN warehouse w ON sj.warehouse_id = w.id
            ${ew.customSqlSegment}
    </select>

</mapper>
