添加bigdecimal序列号
添加移库单向列表
This commit is contained in:
@@ -4,6 +4,11 @@
|
||||
|
||||
<mapper namespace="com.zg.project.inventory.AutoInventory.mapper.InventoryMatchScanMapper">
|
||||
|
||||
<!--
|
||||
批量插入盘点匹配扫描记录
|
||||
用于将一批扫描记录批量插入到库存匹配扫描表中
|
||||
@param list 扫描记录列表,包含任务ID、设备ID、物资编码、时间、扫描类型和状态
|
||||
-->
|
||||
<insert id="insertBatch">
|
||||
INSERT INTO inventory_match_scan (task_id, device_id, pcode, tme, scan_type, status)
|
||||
VALUES
|
||||
@@ -12,16 +17,33 @@
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<!--
|
||||
查询所有盘点匹配扫描记录
|
||||
获取库存匹配扫描表中的所有记录
|
||||
@return InventoryMatchScan 扫描记录实体列表
|
||||
-->
|
||||
<select id="getAll" resultType="com.zg.project.inventory.domain.entity.InventoryMatchScan">
|
||||
SELECT * FROM inventory_match_scan
|
||||
</select>
|
||||
|
||||
<!--
|
||||
查询所有库存匹配扫描记录并关联SOD表
|
||||
左连接SOD表,获取与扫描记录匹配的物资信息,仅返回剩余数量大于0的记录
|
||||
@return Sod 物资信息实体列表
|
||||
-->
|
||||
<select id="getAllSod" resultType="com.zg.project.inventory.domain.entity.Sod">
|
||||
SELECT * FROM inventory_match_scan i
|
||||
LEFT JOIN sod s ON i.pcde = s.fycde_1
|
||||
WHERE s.rmn > 0
|
||||
</select>
|
||||
|
||||
<!--
|
||||
按任务统计物资编码数量
|
||||
根据任务名称和状态筛选扫描记录,关联SOD表统计每个物资编码的出现次数,仅统计剩余数量大于0的物资
|
||||
@param taskName 任务名称(模糊查询,可选)
|
||||
@param status 扫描状态(可选)
|
||||
@return PcdeCountVO 物资编码统计信息,包含物资编码和出现次数
|
||||
-->
|
||||
<select id="getPcdeCountByTask" resultType="com.zg.project.inventory.domain.vo.PcdeCountVO">
|
||||
SELECT
|
||||
s.pcde,
|
||||
@@ -43,6 +65,14 @@
|
||||
GROUP BY s.pcde
|
||||
</select>
|
||||
|
||||
<!--
|
||||
按任务名称分组查询扫描历史记录(分页)
|
||||
根据多个条件筛选扫描记录,按任务名称分组,返回每个任务的最新时间和扫描类型,支持分页查询
|
||||
@param dto 查询条件对象,包含设备ID、任务名称、物资编码、时间范围、扫描类型和状态
|
||||
@param limit 每页记录数
|
||||
@param offset 偏移量
|
||||
@return InventoryMatchScanSimpleVO 扫描记录简单视图列表
|
||||
-->
|
||||
<select id="getGroupedHistoryList" resultType="com.zg.project.inventory.domain.vo.InventoryMatchScanSimpleVO">
|
||||
SELECT
|
||||
task_name AS taskName,
|
||||
@@ -75,6 +105,12 @@
|
||||
LIMIT #{limit} OFFSET #{offset}
|
||||
</select>
|
||||
|
||||
<!--
|
||||
统计分组后的任务数量
|
||||
根据查询条件统计不同任务名称的数量,用于分页查询的总数计算
|
||||
@param dto 查询条件对象,包含设备ID、任务名称、物资编码、时间范围、扫描类型和状态
|
||||
@return int 任务名称数量
|
||||
-->
|
||||
<select id="countGroupedHistory" resultType="int">
|
||||
SELECT COUNT(DISTINCT task_name)
|
||||
FROM inventory_match_scan
|
||||
@@ -101,6 +137,13 @@
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<!--
|
||||
根据任务名称查询扫描记录及关联的SOD物资信息
|
||||
左连接SOD表获取物资详细信息,支持按任务名称和状态筛选,当状态不为2时仅返回剩余数量大于0的记录
|
||||
@param taskName 任务名称(模糊查询,可选)
|
||||
@param status 扫描状态(可选,当不为2时会额外筛选rmn>0的记录)
|
||||
@return InventoryMatchScanVO 扫描记录详细信息列表,包含扫描信息和物资信息
|
||||
-->
|
||||
<select id="getByTaskName" resultType="com.zg.project.inventory.domain.vo.InventoryMatchScanVO">
|
||||
SELECT
|
||||
i.id,
|
||||
@@ -132,6 +175,12 @@
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!--
|
||||
条件查询盘点匹配扫描记录列表(多表关联)
|
||||
关联入库信息表和盘点任务表,获取完整的扫描记录信息,支持多个条件筛选并按时间倒序排列
|
||||
@param param 查询条件对象,包含任务ID、设备ID、物资编码、状态、扫描类型和时间
|
||||
@return InventoryMatchScan 扫描记录实体列表
|
||||
-->
|
||||
<select id="selectInventoryMatchScanList"
|
||||
resultType="com.zg.project.inventory.domain.entity.InventoryMatchScan"
|
||||
parameterType="com.zg.project.inventory.domain.entity.InventoryMatchScan">
|
||||
@@ -171,6 +220,12 @@
|
||||
ORDER BY i.tme DESC
|
||||
</select>
|
||||
|
||||
<!--
|
||||
仅从扫描表中查询物资编码(用于匹配对比)
|
||||
根据条件查询扫描记录中的物资编码,实际数量字段置空,用于与入库信息进行匹配对比
|
||||
@param param 查询条件对象,包含任务ID、设备ID和状态
|
||||
@return RkInfoMatchVO 入库信息匹配视图列表,包含物资编码和实际数量(NULL)
|
||||
-->
|
||||
<select id="selectOnlyFromMatchScan"
|
||||
parameterType="InventoryMatchScan"
|
||||
resultType="com.zg.project.inventory.domain.vo.RkInfoMatchVO">
|
||||
@@ -192,6 +247,12 @@
|
||||
ORDER BY i.tme DESC
|
||||
</select>
|
||||
|
||||
<!--
|
||||
关联入库信息查询物资的实际入库数量
|
||||
根据扫描表中的物资编码,查询入库信息表中的实际入库数量汇总,用于盘点数量对比
|
||||
@param param 查询条件对象,包含任务ID、设备ID和状态
|
||||
@return RkInfoMatchVO 入库信息匹配视图列表,包含物资编码和实际入库数量汇总
|
||||
-->
|
||||
<select id="selectJoinRkInfo"
|
||||
parameterType="InventoryMatchScan"
|
||||
resultType="com.zg.project.inventory.domain.vo.RkInfoMatchVO">
|
||||
|
||||
@@ -12,6 +12,9 @@
|
||||
<!-- 关键字段 -->
|
||||
<result property="rkInfoId" column="rk_info_id"/>
|
||||
<result property="newRkInfoId" column="new_rk_info_id"/>
|
||||
|
||||
<result property="parentMoveId" column="parent_move_id"/>
|
||||
|
||||
<result property="entityId" column="entity_id"/>
|
||||
|
||||
<!-- 数量 -->
|
||||
@@ -55,6 +58,10 @@
|
||||
id,
|
||||
rk_info_id,
|
||||
new_rk_info_id,
|
||||
|
||||
-- ★★★ 新增字段 ★★★
|
||||
parent_move_id,
|
||||
|
||||
entity_id,
|
||||
real_qty,
|
||||
from_cangku,
|
||||
@@ -82,6 +89,9 @@
|
||||
INSERT INTO move_record (
|
||||
rk_info_id,
|
||||
new_rk_info_id,
|
||||
|
||||
parent_move_id,
|
||||
|
||||
entity_id,
|
||||
real_qty,
|
||||
from_cangku,
|
||||
@@ -101,6 +111,9 @@
|
||||
) VALUES (
|
||||
#{rkInfoId},
|
||||
#{newRkInfoId},
|
||||
|
||||
#{parentMoveId},
|
||||
|
||||
#{entityId},
|
||||
#{realQty},
|
||||
#{fromCangku},
|
||||
@@ -172,6 +185,9 @@
|
||||
<set>
|
||||
<if test="rkInfoId != null">rk_info_id = #{rkInfoId},</if>
|
||||
<if test="newRkInfoId != null">new_rk_info_id = #{newRkInfoId},</if>
|
||||
|
||||
<if test="parentMoveId != null">parent_move_id = #{parentMoveId},</if>
|
||||
|
||||
<if test="entityId != null">entity_id = #{entityId},</if>
|
||||
<if test="realQty != null">real_qty = #{realQty},</if>
|
||||
<if test="fromCangku != null">from_cangku = #{fromCangku},</if>
|
||||
@@ -203,4 +219,20 @@
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="selectLastMoveIdByRkInfoId" resultType="java.lang.Long">
|
||||
SELECT id
|
||||
FROM move_record
|
||||
WHERE new_rk_info_id = #{rkInfoId}
|
||||
AND is_delete = '0'
|
||||
ORDER BY create_time DESC
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<select id="countByParentMoveId" resultType="int">
|
||||
SELECT COUNT(1)
|
||||
FROM move_record
|
||||
WHERE parent_move_id = #{parentMoveId}
|
||||
AND is_delete = '0'
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -389,5 +389,116 @@
|
||||
AND is_delete = '0'
|
||||
</update>
|
||||
|
||||
<!-- ========================= 1️⃣ 正常匹配 ========================= -->
|
||||
<select id="getByPcodeIdList" resultMap="RkInfoResult">
|
||||
SELECT
|
||||
ri.*
|
||||
FROM rk_info ri
|
||||
JOIN pcde_detail pd ON ri.pcode_id = pd.encoded_id
|
||||
WHERE ri.is_delete = '0'
|
||||
AND ri.is_chuku = '0'
|
||||
AND pd.is_delete = '0'
|
||||
AND pd.scene = #{sceneId}
|
||||
AND ri.pcode_id IN
|
||||
<foreach collection="pcdeIds" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<!-- ========================= 2️⃣ 未盘点 ========================= -->
|
||||
<select id="getMissedPcodeIds" resultMap="RkInfoResult">
|
||||
SELECT
|
||||
ri.*
|
||||
FROM rk_info ri
|
||||
JOIN pcde_detail pd ON ri.pcode_id = pd.encoded_id
|
||||
WHERE ri.is_delete = '0'
|
||||
AND ri.is_chuku = '0'
|
||||
AND pd.is_delete = '0'
|
||||
AND pd.scene = #{sceneId}
|
||||
<if test="pcdeIds != null and pcdeIds.size() > 0">
|
||||
AND ri.pcode_id NOT IN
|
||||
<foreach collection="pcdeIds" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- ========================= 3️⃣ 异常(不存在) ========================= -->
|
||||
<select id="getNotExistsPcodeIds" resultType="java.lang.String">
|
||||
SELECT t.pcode_id
|
||||
FROM (
|
||||
<foreach collection="pcdeIds" item="id" separator="UNION ALL">
|
||||
SELECT #{id} AS pcode_id
|
||||
</foreach>
|
||||
) t
|
||||
LEFT JOIN (
|
||||
SELECT ri.pcode_id
|
||||
FROM rk_info ri
|
||||
JOIN pcde_detail pd ON ri.pcode_id = pd.encoded_id
|
||||
WHERE ri.is_delete = '0'
|
||||
AND ri.is_chuku = '0'
|
||||
AND pd.is_delete = '0'
|
||||
AND pd.scene = #{sceneId}
|
||||
) s ON t.pcode_id = s.pcode_id
|
||||
WHERE s.pcode_id IS NULL
|
||||
</select>
|
||||
|
||||
<select id="selectPcdeCntFromRkInfo" resultType="com.zg.project.inventory.domain.vo.PcdeCntVO">
|
||||
SELECT pcode AS pcde,
|
||||
COUNT(*) AS cnt
|
||||
FROM rk_info
|
||||
WHERE pcode_id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
GROUP BY pcode
|
||||
</select>
|
||||
|
||||
<select id="getUnscannedPcodeByScene"
|
||||
resultType="com.zg.project.inventory.domain.vo.RkInfoMatchVO">
|
||||
SELECT
|
||||
r.pcode AS rkPcode,
|
||||
COALESCE(SUM(r.real_qty), 0) AS realQty
|
||||
FROM pcde_detail d
|
||||
JOIN rk_info r ON r.pcode = d.pcode
|
||||
LEFT JOIN (
|
||||
SELECT DISTINCT pcode
|
||||
FROM inventory_match_scan
|
||||
WHERE task_id = #{taskId}
|
||||
AND status = '0'
|
||||
) s ON s.pcode = r.pcode
|
||||
WHERE (d.is_delete IS NULL OR d.is_delete = '0')
|
||||
AND d.scene = #{sceneId}
|
||||
AND r.is_chuku = '0'
|
||||
AND s.pcode IS NULL
|
||||
GROUP BY r.pcode
|
||||
ORDER BY MAX(r.create_time) DESC
|
||||
</select>
|
||||
|
||||
<select id="countGetByWh" resultType="java.lang.Integer" parameterType="java.lang.String">
|
||||
SELECT COUNT(1) FROM rk_info
|
||||
WHERE is_delete = '0'
|
||||
AND cangku = #{warehouse}
|
||||
AND is_chuku = '0'
|
||||
</select>
|
||||
|
||||
<select id="listRkInfoByPcode"
|
||||
parameterType="string"
|
||||
resultMap="RkInfoResult">
|
||||
SELECT
|
||||
t.*,
|
||||
wh.warehouse_name AS cangku_name,
|
||||
wh.parent_warehouse_code AS parent_warehouse_code,
|
||||
wh.parent_warehouse_name AS parent_warehouse_name,
|
||||
wh.warehouse_code AS warehouse_code,
|
||||
wh.warehouse_name AS warehouse_name
|
||||
FROM rk_info t
|
||||
LEFT JOIN warehouse_info wh
|
||||
ON wh.warehouse_code = t.cangku
|
||||
WHERE t.is_delete = 0
|
||||
AND t.is_chuku = 0
|
||||
AND t.pcode = #{pcode}
|
||||
ORDER BY t.operation_time DESC, t.id DESC
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -590,70 +590,35 @@
|
||||
COUNT(DISTINCT rr.pcode) AS locationCount,
|
||||
IFNULL(SUM(rr.real_qty), 0) AS totalQuantity
|
||||
FROM rk_record rr
|
||||
<where>
|
||||
rr.is_delete = 0
|
||||
AND rr.exec_status = 1 <!-- 入库 -->
|
||||
|
||||
<if test="operationType != null and operationType.size() > 0">
|
||||
AND rr.operation_type IN
|
||||
<foreach collection="operationType" item="it" open="(" separator="," close=")">
|
||||
#{it}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="xmNo != null and xmNo != ''">
|
||||
AND rr.xm_no LIKE CONCAT('%', #{xmNo}, '%')
|
||||
</if>
|
||||
<if test="wlNo != null and wlNo != ''">
|
||||
AND rr.wl_no LIKE CONCAT('%', #{wlNo}, '%')
|
||||
</if>
|
||||
<if test="pcode != null and pcode != ''">
|
||||
AND rr.pcode LIKE CONCAT('%', #{pcode}, '%')
|
||||
</if>
|
||||
<if test="cangku != null and cangku != ''">
|
||||
AND rr.cangku LIKE CONCAT('%', #{cangku}, '%')
|
||||
</if>
|
||||
<if test="startDate != null">
|
||||
AND rr.operation_time >= #{startDate}
|
||||
</if>
|
||||
<if test="endDate != null">
|
||||
AND rr.operation_time <= #{endDate}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<!-- 出库统计 -->
|
||||
<select id="selectOutRecordStatistic"
|
||||
parameterType="com.zg.project.wisdom.domain.RkRecord"
|
||||
resultType="com.zg.project.wisdom.domain.vo.StockStatisticVO">
|
||||
|
||||
SELECT
|
||||
IFNULL(SUM(rr.real_qty * rr.ht_dj), 0) AS total_amount,
|
||||
COUNT(DISTINCT rr.pcode) AS location_count,
|
||||
IFNULL(SUM(rr.real_qty), 0) AS total_quantity
|
||||
FROM rk_record rr
|
||||
<where>
|
||||
rr.is_delete = 0
|
||||
AND rr.exec_status = 1
|
||||
AND rr.biz_type = 1 <!-- 出库 -->
|
||||
|
||||
<!-- 已修复:String 不可用 size() -->
|
||||
<if test="operationType != null and operationType != ''">
|
||||
AND rr.operation_type LIKE CONCAT('%', #{operationType}, '%')
|
||||
AND rr.operation_type = #{operationType}
|
||||
</if>
|
||||
|
||||
<if test="xmNo != null and xmNo != ''">
|
||||
AND rr.xm_no LIKE CONCAT('%', #{xmNo}, '%')
|
||||
</if>
|
||||
|
||||
<if test="wlNo != null and wlNo != ''">
|
||||
AND rr.wl_no LIKE CONCAT('%', #{wlNo}, '%')
|
||||
</if>
|
||||
|
||||
<if test="pcode != null and pcode != ''">
|
||||
AND rr.pcode LIKE CONCAT('%', #{pcode}, '%')
|
||||
</if>
|
||||
|
||||
<if test="cangku != null and cangku != ''">
|
||||
AND rr.cangku LIKE CONCAT('%', #{cangku}, '%')
|
||||
</if>
|
||||
|
||||
<if test="startDate != null">
|
||||
AND rr.operation_time >= #{startDate}
|
||||
</if>
|
||||
|
||||
<if test="endDate != null">
|
||||
AND rr.operation_time <= #{endDate}
|
||||
</if>
|
||||
|
||||
Reference in New Issue
Block a user