修复电池组模板查询映射
使用模板实体显式映射模板主键和名称,避免 MyBatis 未启用下划线转驼峰时误判模板不存在。同步更新电池组服务测试桩。
| | |
| | | import com.ruoyi.system.domain.TBatteryGroup; |
| | | import com.ruoyi.system.domain.TBatteryGroupBattery; |
| | | import com.ruoyi.system.domain.TBatteryGroupRelationField; |
| | | import com.ruoyi.system.domain.TBatteryGroupTemplate; |
| | | import com.ruoyi.system.mapper.TBatteryGroupMapper; |
| | | |
| | | /** 电池组 Service 单元测试。 */ |
| | |
| | | when(batteryGroupMapper.selectBatteryGroupById(12L)).thenReturn(current); |
| | | when(batteryGroupMapper.countTestingByGroupId(12L)).thenReturn(0); |
| | | when(batteryGroupMapper.selectBatteryByNo("BAT-01", 12L)).thenReturn(null); |
| | | when(batteryGroupMapper.selectTemplate(5L)).thenReturn(new TBatteryGroup()); |
| | | when(batteryGroupMapper.selectTemplate(5L)).thenReturn(new TBatteryGroupTemplate()); |
| | | when(batteryGroupMapper.selectTemplateFieldIds(5L)).thenReturn(Collections.singletonList(7L)); |
| | | when(batteryGroupMapper.selectValidTemplateFields(5L, Collections.singletonList(7L))) |
| | | .thenReturn(Collections.singletonList(relation)); |
| | |
| | | validField.setFieldType("number"); |
| | | when(batteryGroupMapper.selectBatteryGroupByName("样品组")).thenReturn(null); |
| | | when(batteryGroupMapper.selectBatteryByNo("BAT-01", null)).thenReturn(null); |
| | | when(batteryGroupMapper.selectTemplate(5L)).thenReturn(new TBatteryGroup()); |
| | | when(batteryGroupMapper.selectTemplate(5L)).thenReturn(new TBatteryGroupTemplate()); |
| | | when(batteryGroupMapper.selectTemplateFieldIds(5L)).thenReturn(Collections.singletonList(7L)); |
| | | when(batteryGroupMapper.selectValidTemplateFields(5L, Collections.singletonList(7L))) |
| | | .thenReturn(Collections.singletonList(validField)); |
| | |
| | | import com.ruoyi.system.domain.TBatteryGroup; |
| | | import com.ruoyi.system.domain.TBatteryGroupBattery; |
| | | import com.ruoyi.system.domain.TBatteryGroupRelationField; |
| | | import com.ruoyi.system.domain.TBatteryGroupTemplate; |
| | | |
| | | /** 电池组 Mapper。 */ |
| | | public interface TBatteryGroupMapper |
| | |
| | | TBatteryGroup selectBatteryGroupByName(@Param("groupName") String groupName); |
| | | List<TBatteryGroupBattery> selectBatteries(Long groupId); |
| | | List<TBatteryGroupRelationField> selectRelationFields(Long groupId); |
| | | TBatteryGroup selectTemplate(@Param("templateId") Long templateId); |
| | | TBatteryGroupTemplate selectTemplate(@Param("templateId") Long templateId); |
| | | List<Long> selectTemplateFieldIds(@Param("templateId") Long templateId); |
| | | List<TBatteryGroupRelationField> selectValidTemplateFields(@Param("templateId") Long templateId, @Param("fieldIds") List<Long> fieldIds); |
| | | TBatteryGroupBattery selectBatteryByNo(@Param("batteryNo") String batteryNo, @Param("groupId") Long groupId); |
| | |
| | | <result property="fieldValue" column="field_value" /> |
| | | <result property="delFlag" column="del_flag" /> |
| | | </resultMap> |
| | | <resultMap type="TBatteryGroupTemplate" id="TBatteryGroupTemplateReferenceResult"> |
| | | <id property="templateId" column="template_id" /> |
| | | <result property="templateName" column="template_name" /> |
| | | </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> |
| | | <select id="selectBatteryGroupList" parameterType="TBatteryGroup" resultMap="TBatteryGroupResult"> |
| | | select bg.group_id, bg.group_name, bg.model, bg.purpose, bg.z, bg.h, bg.f, bg.a, bg.b, bg.status, |
| | |
| | | <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.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="selectTemplate" resultMap="TBatteryGroupTemplateReferenceResult">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' <if test="groupId != null">and group_id != #{groupId}</if> limit 1</select> |