| | |
| | | group by batch_no, product_model_id, model, unit, product_name, product_id |
| | | </select> |
| | | <select id="stockInventoryPage" resultType="com.ruoyi.stock.dto.StockInRecordDto"> |
| | | select sir.*,si.qualitity as current_stock, |
| | | select t.id, |
| | | t.inbound_batches, |
| | | t.outbound_batches, |
| | | t.batch_no, |
| | | t.stock_in_num, |
| | | t.stock_out_num, |
| | | t.record_type, |
| | | t.record_id, |
| | | t.product_model_id, |
| | | t.remark, |
| | | t.direction, |
| | | t.out_date, |
| | | t.create_time, |
| | | t.create_user, |
| | | t.type, |
| | | si.current_stock, |
| | | pm.model, |
| | | pm.unit, |
| | | p.product_name, |
| | | su.nick_name as create_by |
| | | from |
| | | stock_in_record sir |
| | | from ( |
| | | select sir.id, |
| | | sir.inbound_batches, |
| | | null as outbound_batches, |
| | | sir.batch_no, |
| | | sir.stock_in_num, |
| | | null as stock_out_num, |
| | | sir.record_type, |
| | | sir.record_id, |
| | | sir.product_model_id, |
| | | sir.remark, |
| | | 'in' as direction, |
| | | null as out_date, |
| | | sir.create_time, |
| | | sir.create_user, |
| | | sir.type |
| | | from stock_in_record sir |
| | | <where> |
| | | <if test="ew.reportDate != null"> |
| | | and sir.create_time >= #{ew.reportDate} |
| | | and sir.create_time < DATE_ADD(#{ew.reportDate}, INTERVAL 1 DAY) |
| | | </if> |
| | | <if test="ew.startMonth != null"> |
| | | and sir.create_time >= #{ew.startMonth} |
| | | </if> |
| | | <if test="ew.endMonth != null"> |
| | | and sir.create_time < DATE_ADD(#{ew.endMonth}, INTERVAL 1 DAY) |
| | | </if> |
| | | <if test="ew.startDate != null"> |
| | | and sir.create_time >= #{ew.startDate} |
| | | </if> |
| | | <if test="ew.endDate != null"> |
| | | and sir.create_time < DATE_ADD(#{ew.endDate}, INTERVAL 1 DAY) |
| | | </if> |
| | | </where> |
| | | union all |
| | | select sor.id, |
| | | null as inbound_batches, |
| | | sor.outbound_batches, |
| | | sor.batch_no, |
| | | null as stock_in_num, |
| | | sor.stock_out_num, |
| | | sor.record_type, |
| | | sor.record_id, |
| | | sor.product_model_id, |
| | | sor.remark, |
| | | 'out' as direction, |
| | | sor.out_date, |
| | | sor.create_time, |
| | | sor.create_user, |
| | | sor.type |
| | | from stock_out_record sor |
| | | <where> |
| | | <if test="ew.reportDate != null"> |
| | | and sor.create_time >= #{ew.reportDate} |
| | | and sor.create_time < DATE_ADD(#{ew.reportDate}, INTERVAL 1 DAY) |
| | | </if> |
| | | <if test="ew.startMonth != null"> |
| | | and sor.create_time >= #{ew.startMonth} |
| | | </if> |
| | | <if test="ew.endMonth != null"> |
| | | and sor.create_time < DATE_ADD(#{ew.endMonth}, INTERVAL 1 DAY) |
| | | </if> |
| | | <if test="ew.startDate != null"> |
| | | and sor.create_time >= #{ew.startDate} |
| | | </if> |
| | | <if test="ew.endDate != null"> |
| | | and sor.create_time < DATE_ADD(#{ew.endDate}, INTERVAL 1 DAY) |
| | | </if> |
| | | </where> |
| | | ) t |
| | | left join ( |
| | | select product_model_id, sum(qualitity) as qualitity |
| | | select product_model_id, sum(qualitity) as current_stock |
| | | from stock_inventory |
| | | group by product_model_id |
| | | ) si on sir.product_model_id = si.product_model_id |
| | | left join product_model pm on sir.product_model_id = pm.id |
| | | ) si on t.product_model_id = si.product_model_id |
| | | left join product_model pm on t.product_model_id = pm.id |
| | | left join product p on pm.product_id = p.id |
| | | left join sys_user su on sir.create_user = su.user_id |
| | | <where> |
| | | <if test="ew.reportDate != null"> |
| | | and sir.create_time >= #{ew.reportDate} |
| | | and sir.create_time < DATE_ADD(#{ew.reportDate}, INTERVAL 1 DAY) |
| | | </if> |
| | | <if test="ew.startMonth != null"> |
| | | and sir.create_time >= #{ew.startMonth} |
| | | </if> |
| | | <if test="ew.endMonth != null"> |
| | | and sir.create_time <= #{ew.endMonth} |
| | | </if> |
| | | </where> |
| | | order by sir.id desc |
| | | left join sys_user su on t.create_user = su.user_id |
| | | order by t.create_time desc, t.id desc |
| | | </select> |
| | | |
| | | <select id="stockInAndOutRecord" resultType="com.ruoyi.stock.dto.StockInventoryDto"> |
| | | SELECT |
| | | combined_data.product_model_id, |
| | | pm.model, |
| | | pm.unit, |
| | | p.product_name, |
| | |
| | | and stock_in_record.create_time >= #{ew.startMonth} |
| | | </if> |
| | | <if test="ew.endMonth != null"> |
| | | and stock_in_record.create_time <= #{ew.endMonth} |
| | | and stock_in_record.create_time < DATE_ADD(#{ew.endMonth}, INTERVAL 1 DAY) |
| | | </if> |
| | | <if test="ew.startDate != null"> |
| | | and stock_in_record.create_time >= #{ew.startDate} |
| | | </if> |
| | | <if test="ew.endDate != null"> |
| | | and stock_in_record.create_time < DATE_ADD(#{ew.endDate}, INTERVAL 1 DAY) |
| | | </if> |
| | | </where> |
| | | GROUP BY product_model_id |
| | |
| | | and stock_out_record.create_time >= #{ew.startMonth} |
| | | </if> |
| | | <if test="ew.endMonth != null"> |
| | | and stock_out_record.create_time <= #{ew.endMonth} |
| | | and stock_out_record.create_time < DATE_ADD(#{ew.endMonth}, INTERVAL 1 DAY) |
| | | </if> |
| | | <if test="ew.startDate != null"> |
| | | and stock_out_record.create_time >= #{ew.startDate} |
| | | </if> |
| | | <if test="ew.endDate != null"> |
| | | and stock_out_record.create_time < DATE_ADD(#{ew.endDate}, INTERVAL 1 DAY) |
| | | </if> |
| | | </where> |
| | | GROUP BY product_model_id |
| | |
| | | </if> |
| | | </where> |
| | | GROUP BY |
| | | combined_data.product_model_id, |
| | | pm.model, |
| | | pm.unit, |
| | | p.product_name |