From 73bec5d5d03df5855eb74c8144934541efc8eecd Mon Sep 17 00:00:00 2001
From: songhuangfeng123 <shf18767906695@163.com>
Date: 星期四, 21 七月 2022 16:31:00 +0800
Subject: [PATCH] 连表查字段

---
 incident-manage/incident-manage-service/src/main/resources/config/mapper/incidentManage/WorkInjuryDeclarationInfoMapper.xml |   42 +++++++++++++++++++++++++++++++++++-------
 1 files changed, 35 insertions(+), 7 deletions(-)

diff --git a/incident-manage/incident-manage-service/src/main/resources/config/mapper/incidentManage/WorkInjuryDeclarationInfoMapper.xml b/incident-manage/incident-manage-service/src/main/resources/config/mapper/incidentManage/WorkInjuryDeclarationInfoMapper.xml
index e2dfa75..169bef9 100644
--- a/incident-manage/incident-manage-service/src/main/resources/config/mapper/incidentManage/WorkInjuryDeclarationInfoMapper.xml
+++ b/incident-manage/incident-manage-service/src/main/resources/config/mapper/incidentManage/WorkInjuryDeclarationInfoMapper.xml
@@ -16,9 +16,21 @@
     </resultMap>
 
     <select id="selectWorkInjuryDeclarationList" resultMap="WorkInjuryDeclarationInfoPageDOResult">
-        select id,`declare_user_name`,`declare_department_id`,`accident_express_id` ,work_injury_type ,declare_date ,visit_hospital
-         from work_injury_declaration where del_flag = 0
-        <if test="query.accidentExpressId != null">and `accident_express_id` = #{query.accidentExpressId}</if>
+        SELECT
+        a.id,
+        a.`declare_user_name`,
+        a.`declare_department_id`,
+        a.`accident_express_id`,
+        a.work_injury_type,
+        a.declare_date,
+        a.visit_hospital,
+        b.accident_name AS accidentName
+        FROM
+        work_injury_declaration a
+        LEFT JOIN accident_express b ON a.accident_express_id = b.id
+            WHERE
+            a.del_flag = 0
+        <if test="query.accidentExpressId != null">and a.`accident_express_id` = #{query.accidentExpressId}</if>
     </select>
 
     <insert id="addWorkInjuryDeclaration" parameterType="com.gkhy.safePlatform.incidentManage.entity.WorkInjuryDeclarationInfo"
@@ -84,10 +96,26 @@
     </resultMap>
 
     <select id="selectWorkInjuryDeclarationById" resultMap="WorkInjuryDeclarationInfoDetailDOResult">
-        select id ,declare_user_name ,`declare_user_gender`,`declare_department_id`,`accident_express_id`,`work_injury_type`,declare_date ,lost_time ,
-        `visit_hospital`,`visit_result`,`matters_needing_attention`,`complete_materials`,remark
-         from work_injury_declaration
-        where del_flag = 0 and id = #{id}
+        SELECT
+            a.id,
+            a.declare_user_name,
+            a.`declare_user_gender`,
+            a.`declare_department_id`,
+            a.`accident_express_id`,
+            a.`work_injury_type`,
+            a.declare_date,
+            a.lost_time,
+            a.`visit_hospital`,
+            a.`visit_result`,
+            a.`matters_needing_attention`,
+            a.`complete_materials`,
+            a.remark,
+            b.accident_name AS accidentName,
+            b.occurrence_time AS occurrenceTime
+        FROM
+            work_injury_declaration a
+            LEFT JOIN accident_express b ON a.accident_express_id = b.id
+        WHERE del_flag = 0 and id = #{id}
     </select>
 
     <update id="updateWorkInjuryDeclaration" parameterType="com.gkhy.safePlatform.incidentManage.entity.WorkInjuryDeclarationInfo">

--
Gitblit v1.9.2