You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
153 lines
5.5 KiB
153 lines
5.5 KiB
<?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.gaotao.modules.check.mapper.CountAdjustmentMapper">
|
|
|
|
<!-- rqrq - 统计需要系统处理的异常结果数量 -->
|
|
<select id="countSystemHandleRecords" resultType="int">
|
|
SELECT COUNT(1)
|
|
FROM count_result
|
|
WHERE site = #{site}
|
|
AND count_no = #{countNo}
|
|
AND handle_flag = 'N'
|
|
AND handle_type = 'SYSTEM'
|
|
AND count_result != 'SURPLUS'
|
|
AND count_result != 'OK'
|
|
</select>
|
|
|
|
<!-- rqrq - 查询待系统处理的标签明细(排除SURPLUS类型)-->
|
|
<select id="querySystemHandleLabels" resultType="CountAdjustmentLabelItem">
|
|
SELECT
|
|
r.id AS countResultId,
|
|
r.count_no AS countNo,
|
|
r.count_result AS countResult,
|
|
r.diff_qty AS diffQty,
|
|
r.site AS site,
|
|
r.unit_id AS unitId,
|
|
r.pallet_id AS palletId,
|
|
h.part_no AS partNo,
|
|
h.qty AS qty,
|
|
h.batch_no AS batchNo,
|
|
h.location_id AS locationId,
|
|
h.warehouse_id AS warehouseId,
|
|
h.wdr AS wdr,
|
|
h.expired_date AS expiredDate,
|
|
h.eng_chg_level AS engChgLevel
|
|
FROM count_result r
|
|
LEFT JOIN handling_unit h ON r.site = h.site AND r.unit_id = h.unit_id
|
|
WHERE r.site = #{site}
|
|
AND r.count_no = #{countNo}
|
|
AND r.handle_flag = 'N'
|
|
AND r.handle_type = 'SYSTEM'
|
|
AND r.count_result != 'SURPLUS'
|
|
AND r.count_result != 'OK'
|
|
ORDER BY r.id
|
|
</select>
|
|
|
|
<!-- rqrq - 插入事务明细 -->
|
|
<insert id="insertTransDetail">
|
|
INSERT INTO trans_detail (
|
|
site, trans_no, item_no, part_no, trans_qty,
|
|
batch_no, location_id, direction, wdr_no, eng_chg_level
|
|
) VALUES (
|
|
#{site}, #{transNo}, #{itemNo}, #{partNo}, #{transQty},
|
|
#{batchNo}, #{locationId}, #{direction}, #{wdrNo}, #{engChgLevel}
|
|
)
|
|
</insert>
|
|
|
|
<!-- rqrq - 插入事务子明细(sub_no是标签号,seq_no是序号,direction是+/-)-->
|
|
<insert id="insertTransDetailSub">
|
|
INSERT INTO trans_detail_sub (
|
|
site, trans_no, item_no, seq_no, sub_no, sub_qty, direction,
|
|
part_no, batch_no, location_id, eng_chg_level, order_ref1, order_ref3, order_ref4
|
|
) VALUES (
|
|
#{site}, #{transNo}, #{itemNo}, #{seqNo}, #{subNo}, #{subQty}, #{direction},
|
|
#{partNo}, #{batchNo}, #{locationId}, #{engChgLevel}, #{orderRef1}, #{orderRef3}, #{orderRef4}
|
|
)
|
|
</insert>
|
|
|
|
<!-- rqrq - 更新标签数量 -->
|
|
<update id="updateHandlingUnitQty">
|
|
UPDATE handling_unit
|
|
SET qty = #{qty},
|
|
in_stock_flag = #{inStockFlag},
|
|
modified_by = #{username},
|
|
modified_date = GETDATE()
|
|
WHERE site = #{site}
|
|
AND unit_id = #{unitId}
|
|
</update>
|
|
|
|
<!-- rqrq - 更新盘点结果处理标记 -->
|
|
<update id="updateCountResultHandleFlag">
|
|
UPDATE count_result
|
|
SET handle_flag = 'Y'
|
|
|
|
WHERE id = #{countResultId}
|
|
</update>
|
|
|
|
<!-- rqrq - 查询盘盈盘亏事务头和明细 -->
|
|
<select id="queryAdjustmentTransList" resultType="CountAdjustmentTransData">
|
|
SELECT
|
|
h.site,
|
|
h.trans_no AS transNo,
|
|
h.trans_date AS transDate,
|
|
h.trans_type_db AS transTypeDb,
|
|
CASE h.trans_type_db
|
|
WHEN 'PK' THEN '盘亏'
|
|
WHEN 'PY' THEN '盘盈'
|
|
ELSE h.trans_type_db
|
|
END AS transTypeDesc,
|
|
h.warehouse_id AS warehouseId,
|
|
h.order_ref1 AS orderRef1,
|
|
h.remark,
|
|
h.user_name AS userName,
|
|
d.item_no AS itemNo,
|
|
d.part_no AS partNo,
|
|
d.trans_qty AS transQty,
|
|
d.batch_no AS batchNo,
|
|
d.location_id AS locationId,
|
|
d.direction,
|
|
CASE d.direction
|
|
WHEN '+' THEN '入库'
|
|
WHEN '-' THEN '出库'
|
|
ELSE d.direction
|
|
END AS directionDesc,
|
|
d.wdr_no AS wdrNo,
|
|
d.eng_chg_level AS engChgLevel
|
|
FROM trans_header h
|
|
INNER JOIN trans_detail d ON h.site = d.site AND h.trans_no = d.trans_no
|
|
WHERE h.site = #{site}
|
|
AND h.order_ref1 = #{countNo}
|
|
AND h.trans_type_db IN ('PK', 'PY')
|
|
ORDER BY h.trans_no, d.item_no
|
|
</select>
|
|
|
|
<!-- rqrq - 查询事务子明细(sub_no就是标签号unit_id) -->
|
|
<select id="queryAdjustmentTransSubList" resultType="CountAdjustmentTransSubData">
|
|
SELECT
|
|
site,
|
|
trans_no AS transNo,
|
|
item_no AS itemNo,
|
|
seq_no AS seqNo,
|
|
sub_no AS subNo,
|
|
sub_qty AS subQty,
|
|
direction,
|
|
CASE direction
|
|
WHEN '+' THEN '入库'
|
|
WHEN '-' THEN '出库'
|
|
ELSE direction
|
|
END AS directionDesc,
|
|
part_no AS partNo,
|
|
batch_no AS batchNo,
|
|
location_id AS locationId,
|
|
eng_chg_level AS engChgLevel,
|
|
order_ref1 AS palletId,
|
|
order_ref3 AS wdr,
|
|
order_ref4 AS warehouseId
|
|
FROM trans_detail_sub
|
|
WHERE site = #{site}
|
|
AND trans_no = #{transNo}
|
|
ORDER BY item_no, seq_no
|
|
</select>
|
|
|
|
</mapper>
|
|
|