From ebd47e950c8d45f5cc21336f4996857de58e0ea6 Mon Sep 17 00:00:00 2001
From: yeg <1347747024@qq.com>
Date: 星期四, 27 八月 2026 22:51:35 +0800
Subject: [PATCH] fix: persist battery group configuration

---
 ruoyi-system/src/main/resources/mapper/system/TBatteryGroupMapper.xml |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/ruoyi-system/src/main/resources/mapper/system/TBatteryGroupMapper.xml b/ruoyi-system/src/main/resources/mapper/system/TBatteryGroupMapper.xml
index 62451dc..38ce8c6 100644
--- a/ruoyi-system/src/main/resources/mapper/system/TBatteryGroupMapper.xml
+++ b/ruoyi-system/src/main/resources/mapper/system/TBatteryGroupMapper.xml
@@ -22,6 +22,7 @@
         <id property="relationId" column="relation_id" /><result property="groupId" column="group_id" />
         <result property="templateId" column="template_id" /><result property="batteryGroupFieldId" column="battery_group_field_id" />
         <result property="fieldName" column="field_name" /><result property="fieldType" column="field_type" />
+        <result property="fieldValue" column="field_value" />
         <result property="delFlag" column="del_flag" />
     </resultMap>
     <sql id="groupColumns">select group_id, group_name, model, purpose, z, h, f, a, b, status, create_by, create_time, update_by, update_time, remark, del_flag from t_battery_group</sql>
@@ -50,18 +51,18 @@
     <select id="selectBatteryGroupById" parameterType="Long" resultMap="TBatteryGroupResult"><include refid="groupColumns"/> where group_id = #{groupId} and del_flag = '0'</select>
     <select id="selectBatteryGroupByName" resultMap="TBatteryGroupResult"> <include refid="groupColumns"/> where group_name = #{groupName} and del_flag = '0' limit 1</select>
     <select id="selectBatteries" parameterType="Long" resultMap="TBatteryGroupBatteryResult">select relation_id, group_id, battery_no, sort_order, del_flag from t_battery_group_battery where group_id = #{groupId} and del_flag = '0' order by sort_order, relation_id</select>
-    <select id="selectRelationFields" parameterType="Long" resultMap="TBatteryGroupRelationFieldResult">select r.relation_id, r.group_id, r.template_id, r.battery_group_field_id, f.field_name, f.field_type, r.del_flag from t_battery_group_relation_field r inner join t_battery_group_field f on f.field_id = r.battery_group_field_id and f.del_flag = '0' where r.group_id = #{groupId} and r.del_flag = '0' order by r.relation_id</select>
+    <select id="selectRelationFields" parameterType="Long" resultMap="TBatteryGroupRelationFieldResult">select r.relation_id, r.group_id, r.template_id, r.battery_group_field_id, f.field_name, f.field_type, r.field_value, r.del_flag from t_battery_group_relation_field r inner join t_battery_group_field f on f.field_id = r.battery_group_field_id and f.del_flag = '0' where r.group_id = #{groupId} and r.del_flag = '0' order by r.relation_id</select>
     <select id="selectTemplate" resultType="TBatteryGroup">select template_id, template_name from t_battery_group_template where template_id = #{templateId}</select>
     <select id="selectTemplateFieldIds" resultType="Long">select field_id from t_battery_group_template_field where template_id = #{templateId} and del_flag = '0' order by sort_order, relation_id</select>
     <select id="selectValidTemplateFields" resultMap="TBatteryGroupRelationFieldResult">select r.relation_id, r.template_id, r.field_id as battery_group_field_id, f.field_name, f.field_type, '0' as del_flag from t_battery_group_template_field r inner join t_battery_group_field f on f.field_id = r.field_id and f.del_flag = '0' where r.template_id = #{templateId} and r.del_flag = '0' and r.field_id in <foreach collection="fieldIds" item="fieldId" open="(" separator="," close=")">#{fieldId}</foreach></select>
     <select id="selectBatteryByNo" resultMap="TBatteryGroupBatteryResult">select relation_id, group_id, battery_no, sort_order, del_flag from t_battery_group_battery where battery_no = #{batteryNo} and del_flag = '0' limit 1</select>
     <insert id="insertBatteryGroup" parameterType="TBatteryGroup" useGeneratedKeys="true" keyProperty="groupId">insert into t_battery_group (group_name, model, purpose, z, h, f, a, b, status, create_by, create_time, remark, del_flag) values (#{groupName}, #{model}, #{purpose}, #{z}, #{h}, #{f}, #{a}, #{b}, #{status}, #{createBy}, sysdate(), #{remark}, '0')</insert>
-    <update id="updateBatteryGroup" parameterType="TBatteryGroup">update t_battery_group set group_name=#{groupName}, model=#{model}, purpose=#{purpose}, z=#{z}, h=#{h}, f=#{f}, a=#{a}, b=#{b}, update_by=#{updateBy}, update_time=sysdate(), remark=#{remark} where group_id=#{groupId} and del_flag='0'</update>
+    <update id="updateBatteryGroup" parameterType="TBatteryGroup">update t_battery_group set group_name=#{groupName}, model=#{model}, purpose=#{purpose}, z=#{z}, h=#{h}, f=#{f}, a=#{a}, b=#{b}, status=#{status}, update_by=#{updateBy}, update_time=sysdate(), remark=#{remark} where group_id=#{groupId} and del_flag='0'</update>
     <update id="updateBatteryGroupStatus" parameterType="TBatteryGroup">update t_battery_group set status=#{status}, update_by=#{updateBy}, update_time=sysdate() where group_id=#{groupId} and del_flag='0'</update>
     <update id="deleteBatteryGroup">update t_battery_group set del_flag=cast(group_id as char), update_by=#{updateBy}, update_time=sysdate() where group_id=#{groupId} and del_flag='0'</update>
     <update id="deleteBatteries">update t_battery_group_battery set del_flag=cast(relation_id as char) where group_id=#{groupId} and del_flag='0'</update>
     <update id="deleteRelationFields">update t_battery_group_relation_field set del_flag=cast(relation_id as char) where group_id=#{groupId} and del_flag='0'</update>
     <insert id="batchInsertBatteries">insert into t_battery_group_battery (group_id,battery_no,sort_order,del_flag) values <foreach collection="items" item="item" separator=",">(#{item.groupId},#{item.batteryNo},#{item.sortOrder},#{item.delFlag})</foreach></insert>
-    <insert id="batchInsertRelationFields">insert into t_battery_group_relation_field (group_id,template_id,battery_group_field_id,del_flag) values <foreach collection="items" item="item" separator=",">(#{item.groupId},#{item.templateId},#{item.batteryGroupFieldId},#{item.delFlag})</foreach></insert>
-    <select id="countTestingByGroupId" resultType="int">select count(1) from t_test_battery b inner join t_test t on t.test_id = b.test_id and t.del_flag = '0' where b.group_id=#{groupId} and b.del_flag='0' and t.status='1'</select>
+    <insert id="batchInsertRelationFields">insert into t_battery_group_relation_field (group_id,template_id,battery_group_field_id,field_value,del_flag) values <foreach collection="items" item="item" separator=",">(#{item.groupId},#{item.templateId},#{item.batteryGroupFieldId},#{item.fieldValue},#{item.delFlag})</foreach></insert>
+    <select id="countTestingByGroupId" resultType="int">select count(1) from t_test_battery b inner join t_test t on t.test_id = b.test_id and t.del_flag = 0 where b.group_id=#{groupId} and b.del_flag=0 and t.test_status not in ('COMPLETED', 'TERMINATED')</select>
 </mapper>

--
Gitblit v1.7.1