| | |
| | | ) t |
| | | </select> |
| | | |
| | | <!-- 统计月结时间范围内的物料出入库数量(合并入库出库) --> |
| | | <select id="statisticsMaterialInOut" resultType="com.zy.asrs.entity.result.MaterialInOutStatDTO"> |
| | | <!-- 统计月结时间范围内的物料出入库数量(从入库表查询) --> |
| | | <select id="statisticsMaterialInOutFromPakin" resultType="com.zy.asrs.entity.result.MaterialInOutRawDTO"> |
| | | SELECT |
| | | matnr, |
| | | MAX(maktx) as maktx, |
| | | batch, |
| | | brand, |
| | | SUM(in_qty) as inQty, |
| | | SUM(out_qty) as outQty |
| | | FROM ( |
| | | SELECT |
| | | od.matnr, |
| | | MAX(od.maktx) as maktx, |
| | | ISNULL(od.batch, '') as batch, |
| | | ISNULL(od.brand, '') as brand, |
| | | SUM(od.qty) as in_qty, |
| | | 0 as out_qty |
| | | FROM man_order_log_pakin o |
| | | INNER JOIN man_order_detl_log_pakin od ON o.id = od.order_id |
| | | WHERE o.status = 1 |
| | | AND CONVERT(date, o.order_time) >= #{startDate} |
| | | AND o.order_time <= #{endDate} |
| | | AND o.move_status = 2 |
| | | AND (o.monthly_settle_id IS NULL OR o.monthly_settle_id = 0) |
| | | GROUP BY od.matnr, od.batch, od.brand |
| | | UNION ALL |
| | | SELECT |
| | | od.matnr, |
| | | MAX(od.maktx) as maktx, |
| | | ISNULL(od.batch, '') as batch, |
| | | ISNULL(od.brand, '') as brand, |
| | | 0 as in_qty, |
| | | SUM(od.qty) as out_qty |
| | | FROM man_order_log_pakout o |
| | | INNER JOIN man_order_detl_log_pakout od ON o.id = od.order_id |
| | | WHERE o.status = 1 |
| | | AND CONVERT(date, o.order_time) >= #{startDate} |
| | | AND o.order_time <= #{endDate} |
| | | AND o.move_status = 2 |
| | | AND (o.monthly_settle_id IS NULL OR o.monthly_settle_id = 0) |
| | | GROUP BY od.matnr, od.batch, od.brand |
| | | ) t |
| | | GROUP BY matnr, batch, brand |
| | | od.matnr, |
| | | od.maktx, |
| | | od.batch, |
| | | od.brand, |
| | | SUM(od.qty) as qty, |
| | | COALESCE(od.pakin_pakout_status, o.pakin_pakout_status) as pakinPakoutStatus |
| | | FROM man_order_log_pakin o |
| | | INNER JOIN man_order_detl_log_pakin od ON o.id = od.order_id |
| | | WHERE o.status = 1 |
| | | AND CONVERT(date, o.order_time) >= #{startDate} |
| | | AND o.order_time <= #{endDate} |
| | | AND o.move_status = 2 |
| | | AND (o.monthly_settle_id IS NULL OR o.monthly_settle_id = 0) |
| | | AND COALESCE(od.pakin_pakout_status, o.pakin_pakout_status) IN (1, 2) |
| | | GROUP BY od.matnr, od.maktx, od.batch, od.brand, COALESCE(od.pakin_pakout_status, o.pakin_pakout_status) |
| | | </select> |
| | | |
| | | <!-- 统计月结时间范围内的物料出入库数量(从出库表查询) --> |
| | | <select id="statisticsMaterialInOutFromPakout" resultType="com.zy.asrs.entity.result.MaterialInOutRawDTO"> |
| | | SELECT |
| | | od.matnr, |
| | | od.maktx, |
| | | od.batch, |
| | | od.brand, |
| | | SUM(od.qty) as qty, |
| | | COALESCE(od.pakin_pakout_status, o.pakin_pakout_status) as pakinPakoutStatus |
| | | FROM man_order_log_pakout o |
| | | INNER JOIN man_order_detl_log_pakout od ON o.id = od.order_id |
| | | WHERE o.status = 1 |
| | | AND CONVERT(date, o.order_time) >= #{startDate} |
| | | AND o.order_time <= #{endDate} |
| | | AND o.move_status = 2 |
| | | AND (o.monthly_settle_id IS NULL OR o.monthly_settle_id = 0) |
| | | AND COALESCE(od.pakin_pakout_status, o.pakin_pakout_status) IN (1, 2) |
| | | GROUP BY od.matnr, od.maktx, od.batch, od.brand, COALESCE(od.pakin_pakout_status, o.pakin_pakout_status) |
| | | </select> |
| | | |
| | | <!-- 获取上一个月结的物料期末库存 --> |
| | | <select id="getPreviousSettleEndingQty" resultType="com.zy.asrs.entity.result.PreviousSettleEndingQtyDTO"> |
| | | SELECT |
| | | matnr, |
| | | batch, |
| | | brand, |
| | | ISNULL(batch, '') as batch, |
| | | ISNULL(brand, '') as brand, |
| | | ISNULL(maktx, '') as maktx, |
| | | ending_qty as endingQty |
| | | FROM man_monthly_settle_detail |
| | | WHERE settle_id = #{previousSettleId} |
| | | AND is_deleted = 0 |
| | | </select> |
| | | |
| | | <!-- 更新入库订单的月结信息 --> |