|
|
|
|
@ -26,6 +26,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
|
|
MAX(b.min_stock_amount) min_stock_amount,
|
|
|
|
|
MAX(b.max_stock_amount) max_stock_amount,
|
|
|
|
|
MAX(c.warehouse_code) warehouse_code,
|
|
|
|
|
MAX(c.warehouse_name) warehouse_name,
|
|
|
|
|
MAX(b.material_code) material_code,
|
|
|
|
|
MAX(b.material_name) material_name,
|
|
|
|
|
MAX(x.lock_state) lock_state,
|
|
|
|
|
@ -103,4 +104,275 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
|
|
where store_place_code= #{locationCode}
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<!-- 库存台账查询 - 入库记录 -->
|
|
|
|
|
<select id="selectInstockLedgerRecords" resultType="org.dromara.wms.domain.vo.WmsInventoryLedgerVo">
|
|
|
|
|
SELECT
|
|
|
|
|
ir.material_id,
|
|
|
|
|
ir.batch_code,
|
|
|
|
|
ir.location_code,
|
|
|
|
|
ir.instock_qty as changeQty,
|
|
|
|
|
ir.instock_code as relatedCode,
|
|
|
|
|
ir.create_time as changeDate,
|
|
|
|
|
ir.create_by as operatorName,
|
|
|
|
|
'1' as changeType,
|
|
|
|
|
'入库' as changeTypeName,
|
|
|
|
|
bmi.material_code,
|
|
|
|
|
bmi.material_name,
|
|
|
|
|
bmi.material_spec,
|
|
|
|
|
bmi.material_unit,
|
|
|
|
|
wbw.warehouse_code,
|
|
|
|
|
wbw.warehouse_name,
|
|
|
|
|
wbw.warehouse_id,
|
|
|
|
|
bmc.material_category_name,
|
|
|
|
|
bmi.material_category_id
|
|
|
|
|
FROM wms_instock_record ir
|
|
|
|
|
LEFT JOIN base_material_info_copy1 bmi ON ir.material_id = bmi.material_id
|
|
|
|
|
LEFT JOIN wms_base_warehouse wbw ON ir.warehouse_id = wbw.warehouse_id
|
|
|
|
|
LEFT JOIN base_material_category bmc ON bmi.material_category_id = bmc.material_category_id
|
|
|
|
|
<where>
|
|
|
|
|
<if test="bo.materialCode != null and bo.materialCode != ''">
|
|
|
|
|
AND bmi.material_code LIKE CONCAT('%', #{bo.materialCode}, '%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="bo.materialName != null and bo.materialName != ''">
|
|
|
|
|
AND bmi.material_name LIKE CONCAT('%', #{bo.materialName}, '%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="bo.batchCode != null and bo.batchCode != ''">
|
|
|
|
|
AND ir.batch_code LIKE CONCAT('%', #{bo.batchCode}, '%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="bo.warehouseId != null">
|
|
|
|
|
AND ir.warehouse_id = #{bo.warehouseId}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="bo.locationCode != null and bo.locationCode != ''">
|
|
|
|
|
AND ir.location_code LIKE CONCAT('%', #{bo.locationCode}, '%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="bo.materialCategoryId != null">
|
|
|
|
|
AND bmi.material_category_id = #{bo.materialCategoryId}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="bo.startDate != null">
|
|
|
|
|
AND ir.create_time >= #{bo.startDate}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="bo.endDate != null">
|
|
|
|
|
AND ir.create_time <= #{bo.endDate}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="bo.changeType != null and bo.changeType != ''">
|
|
|
|
|
AND '1' = #{bo.changeType}
|
|
|
|
|
</if>
|
|
|
|
|
</where>
|
|
|
|
|
ORDER BY ir.create_time ASC
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<!-- 库存台账查询 - 出库记录 -->
|
|
|
|
|
<select id="selectOutstockLedgerRecords" resultType="org.dromara.wms.domain.vo.WmsInventoryLedgerVo">
|
|
|
|
|
SELECT
|
|
|
|
|
ors.material_id,
|
|
|
|
|
ors.batch_code,
|
|
|
|
|
ors.location_code,
|
|
|
|
|
-ors.outstock_qty as changeQty,
|
|
|
|
|
ors.outstock_code as relatedCode,
|
|
|
|
|
ors.create_time as changeDate,
|
|
|
|
|
ors.create_by as operatorName,
|
|
|
|
|
'2' as changeType,
|
|
|
|
|
'出库' as changeTypeName,
|
|
|
|
|
bmi.material_code,
|
|
|
|
|
bmi.material_name,
|
|
|
|
|
bmi.material_spec,
|
|
|
|
|
bmi.material_unit,
|
|
|
|
|
wbw.warehouse_code,
|
|
|
|
|
wbw.warehouse_name,
|
|
|
|
|
woo.warehouse_id,
|
|
|
|
|
bmc.material_category_name,
|
|
|
|
|
bmi.material_category_id
|
|
|
|
|
FROM wms_outstock_record ors
|
|
|
|
|
LEFT JOIN wms_outstock_order woo ON ors.outstock_id = woo.outstock_id
|
|
|
|
|
LEFT JOIN base_material_info_copy1 bmi ON ors.material_id = bmi.material_id
|
|
|
|
|
LEFT JOIN wms_base_warehouse wbw ON woo.warehouse_id = wbw.warehouse_id
|
|
|
|
|
LEFT JOIN base_material_category bmc ON bmi.material_category_id = bmc.material_category_id
|
|
|
|
|
<where>
|
|
|
|
|
<if test="bo.materialCode != null and bo.materialCode != ''">
|
|
|
|
|
AND bmi.material_code LIKE CONCAT('%', #{bo.materialCode}, '%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="bo.materialName != null and bo.materialName != ''">
|
|
|
|
|
AND bmi.material_name LIKE CONCAT('%', #{bo.materialName}, '%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="bo.batchCode != null and bo.batchCode != ''">
|
|
|
|
|
AND ors.batch_code LIKE CONCAT('%', #{bo.batchCode}, '%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="bo.warehouseId != null">
|
|
|
|
|
AND woo.warehouse_id = #{bo.warehouseId}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="bo.locationCode != null and bo.locationCode != ''">
|
|
|
|
|
AND ors.location_code LIKE CONCAT('%', #{bo.locationCode}, '%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="bo.materialCategoryId != null">
|
|
|
|
|
AND bmi.material_category_id = #{bo.materialCategoryId}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="bo.startDate != null">
|
|
|
|
|
AND ors.create_time >= #{bo.startDate}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="bo.endDate != null">
|
|
|
|
|
AND ors.create_time <= #{bo.endDate}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="bo.changeType != null and bo.changeType != ''">
|
|
|
|
|
AND '2' = #{bo.changeType}
|
|
|
|
|
</if>
|
|
|
|
|
</where>
|
|
|
|
|
ORDER BY ors.create_time ASC
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<!-- 库存台账查询 - 盘点调账记录 -->
|
|
|
|
|
<select id="selectInventoryCheckLedgerRecords" resultType="org.dromara.wms.domain.vo.WmsInventoryLedgerVo">
|
|
|
|
|
SELECT
|
|
|
|
|
icr.material_id,
|
|
|
|
|
icr.batch_code,
|
|
|
|
|
icr.location_code,
|
|
|
|
|
(icr.check_qty - icr.inventory_qty) as changeQty,
|
|
|
|
|
icr.check_code as relatedCode,
|
|
|
|
|
icr.create_time as changeDate,
|
|
|
|
|
icr.create_by as operatorName,
|
|
|
|
|
'5' as changeType,
|
|
|
|
|
'盘点调账' as changeTypeName,
|
|
|
|
|
icr.material_code,
|
|
|
|
|
icr.material_name,
|
|
|
|
|
bmi.material_spec,
|
|
|
|
|
bmi.material_unit,
|
|
|
|
|
'' as warehouse_code,
|
|
|
|
|
'' as warehouse_name,
|
|
|
|
|
NULL as warehouse_id
|
|
|
|
|
FROM wms_inventory_check_record icr
|
|
|
|
|
LEFT JOIN base_material_info_copy1 bmi ON icr.material_id = bmi.material_id
|
|
|
|
|
<where>
|
|
|
|
|
AND icr.is_adjust = '1'
|
|
|
|
|
<if test="bo.materialCode != null and bo.materialCode != ''">
|
|
|
|
|
AND icr.material_code LIKE CONCAT('%', #{bo.materialCode}, '%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="bo.materialName != null and bo.materialName != ''">
|
|
|
|
|
AND icr.material_name LIKE CONCAT('%', #{bo.materialName}, '%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="bo.batchCode != null and bo.batchCode != ''">
|
|
|
|
|
AND icr.batch_code LIKE CONCAT('%', #{bo.batchCode}, '%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="bo.locationCode != null and bo.locationCode != ''">
|
|
|
|
|
AND icr.location_code LIKE CONCAT('%', #{bo.locationCode}, '%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="bo.materialCategoryId != null">
|
|
|
|
|
AND icr.material_category_id = #{bo.materialCategoryId}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="bo.startDate != null">
|
|
|
|
|
AND icr.create_time >= #{bo.startDate}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="bo.endDate != null">
|
|
|
|
|
AND icr.create_time <= #{bo.endDate}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="bo.changeType != null and bo.changeType != ''">
|
|
|
|
|
AND '5' = #{bo.changeType}
|
|
|
|
|
</if>
|
|
|
|
|
</where>
|
|
|
|
|
ORDER BY icr.create_time ASC
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<!-- 库存台账查询 - 退库记录 -->
|
|
|
|
|
<select id="selectReturnOrderLedgerRecords" resultType="org.dromara.wms.domain.vo.WmsInventoryLedgerVo">
|
|
|
|
|
SELECT
|
|
|
|
|
ro.material_id,
|
|
|
|
|
ro.batch_code,
|
|
|
|
|
ro.return_location_code as location_code,
|
|
|
|
|
-ro.return_amount as changeQty,
|
|
|
|
|
CONCAT('RO', ro.ro_id) as relatedCode,
|
|
|
|
|
ro.create_time as changeDate,
|
|
|
|
|
ro.create_by as operatorName,
|
|
|
|
|
'4' as changeType,
|
|
|
|
|
'退库' as changeTypeName,
|
|
|
|
|
bmi.material_code,
|
|
|
|
|
bmi.material_name,
|
|
|
|
|
bmi.material_spec,
|
|
|
|
|
bmi.material_unit,
|
|
|
|
|
wbw.warehouse_code,
|
|
|
|
|
wbw.warehouse_name,
|
|
|
|
|
ro.warehouse_id,
|
|
|
|
|
bmc.material_category_name,
|
|
|
|
|
bmi.material_category_id
|
|
|
|
|
FROM wms_return_order ro
|
|
|
|
|
LEFT JOIN base_material_info_copy1 bmi ON ro.material_id = bmi.material_id
|
|
|
|
|
LEFT JOIN wms_base_warehouse wbw ON ro.warehouse_id = wbw.warehouse_id
|
|
|
|
|
LEFT JOIN base_material_category bmc ON bmi.material_category_id = bmc.material_category_id
|
|
|
|
|
<where>
|
|
|
|
|
AND ro.order_status = '2'
|
|
|
|
|
<if test="bo.materialCode != null and bo.materialCode != ''">
|
|
|
|
|
AND bmi.material_code LIKE CONCAT('%', #{bo.materialCode}, '%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="bo.materialName != null and bo.materialName != ''">
|
|
|
|
|
AND bmi.material_name LIKE CONCAT('%', #{bo.materialName}, '%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="bo.batchCode != null and bo.batchCode != ''">
|
|
|
|
|
AND ro.batch_code LIKE CONCAT('%', #{bo.batchCode}, '%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="bo.warehouseId != null">
|
|
|
|
|
AND ro.warehouse_id = #{bo.warehouseId}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="bo.materialCategoryId != null">
|
|
|
|
|
AND bmi.material_category_id = #{bo.materialCategoryId}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="bo.startDate != null">
|
|
|
|
|
AND ro.create_time >= #{bo.startDate}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="bo.endDate != null">
|
|
|
|
|
AND ro.create_time <= #{bo.endDate}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="bo.changeType != null and bo.changeType != ''">
|
|
|
|
|
AND '4' = #{bo.changeType}
|
|
|
|
|
</if>
|
|
|
|
|
</where>
|
|
|
|
|
ORDER BY ro.create_time ASC
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<!-- 库存台账查询 - 调拨记录 -->
|
|
|
|
|
<select id="selectTransferLedgerRecords" resultType="org.dromara.wms.domain.vo.WmsInventoryLedgerVo">
|
|
|
|
|
SELECT
|
|
|
|
|
ht.material_id,
|
|
|
|
|
ht.card_no as batch_code,
|
|
|
|
|
ht.store_place_code as location_code,
|
|
|
|
|
0 as changeQty,
|
|
|
|
|
CONCAT('TF', ht.transfer_id) as relatedCode,
|
|
|
|
|
ht.create_time as changeDate,
|
|
|
|
|
ht.create_by as operatorName,
|
|
|
|
|
'3' as changeType,
|
|
|
|
|
'调拨' as changeTypeName,
|
|
|
|
|
bmi.material_code,
|
|
|
|
|
bmi.material_name,
|
|
|
|
|
bmi.material_spec,
|
|
|
|
|
bmi.material_unit,
|
|
|
|
|
'' as warehouse_code,
|
|
|
|
|
'' as warehouse_name,
|
|
|
|
|
NULL as warehouse_id
|
|
|
|
|
FROM wms_hpp_transfer ht
|
|
|
|
|
LEFT JOIN base_material_info_copy1 bmi ON ht.material_id = bmi.material_id
|
|
|
|
|
<where>
|
|
|
|
|
<if test="bo.materialCode != null and bo.materialCode != ''">
|
|
|
|
|
AND bmi.material_code LIKE CONCAT('%', #{bo.materialCode}, '%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="bo.materialName != null and bo.materialName != ''">
|
|
|
|
|
AND bmi.material_name LIKE CONCAT('%', #{bo.materialName}, '%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="bo.batchCode != null and bo.batchCode != ''">
|
|
|
|
|
AND ht.card_no LIKE CONCAT('%', #{bo.batchCode}, '%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="bo.locationCode != null and bo.locationCode != ''">
|
|
|
|
|
AND ht.store_place_code LIKE CONCAT('%', #{bo.locationCode}, '%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="bo.materialCategoryId != null">
|
|
|
|
|
AND bmi.material_category_id = #{bo.materialCategoryId}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="bo.startDate != null">
|
|
|
|
|
AND ht.create_time >= #{bo.startDate}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="bo.endDate != null">
|
|
|
|
|
AND ht.create_time <= #{bo.endDate}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="bo.changeType != null and bo.changeType != ''">
|
|
|
|
|
AND '3' = #{bo.changeType}
|
|
|
|
|
</if>
|
|
|
|
|
</where>
|
|
|
|
|
ORDER BY ht.create_time ASC
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
</mapper>
|
|
|
|
|
|