diff --git a/src/main/resources/mybatis/wisdom/RkRecordMapper.xml b/src/main/resources/mybatis/wisdom/RkRecordMapper.xml
index d643bba..3b36f85 100644
--- a/src/main/resources/mybatis/wisdom/RkRecordMapper.xml
+++ b/src/main/resources/mybatis/wisdom/RkRecordMapper.xml
@@ -93,8 +93,8 @@
SELECT
rr.*,
- /* ===== 新增:统一计算总金额 ===== */
- rr.real_qty * rr.ht_dj AS total_amount,
+ /* 总金额 */
+ COALESCE(rr.real_qty,0) * COALESCE(rr.ht_dj,0) AS total_amount,
su.nick_name AS operator_name,
mt.type_name AS wl_type_name,
@@ -107,7 +107,10 @@
wh.parent_warehouse_code AS parent_warehouse_code,
wh.parent_warehouse_name AS parent_warehouse_name,
- ct.team_name AS team_name
+ ct.team_name AS team_name,
+
+ -- 新增 gys_jh 主键
+ gj.id AS gys_jh_id
FROM rk_record rr
LEFT JOIN sys_user su ON rr.operator = su.user_id
@@ -120,6 +123,13 @@
LEFT JOIN construction_team ct
ON rr.team_code = ct.team_code
AND ct.is_delete = '0'
+ /* 新增关联 */
+ LEFT JOIN gys_jh gj
+ ON rr.sap_no = gj.sap_no
+ AND rr.wl_no = gj.wl_no
+ AND rr.xm_no = gj.xm_no
+ AND gj.is_delete = '0'
+
@@ -282,7 +292,11 @@
WHERE rr.bill_no = #{billNo}
AND (rr.is_delete = '0' OR rr.is_delete = 0 OR rr.is_delete IS NULL)
- ORDER BY rr.exec_status = '0' DESC, rr.create_time ASC
+
+ ORDER BY
+ rr.exec_status = '0' DESC,
+ rr.create_time ASC,
+ gj.id ASC