five-groups-couplet/couplet-modules/couplet-business/src/main/resources/mapper/business/SysTroubleMapper.xml

50 lines
2.2 KiB
XML

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.couplet.business.server.mapper.SysTroubleMapper">
<resultMap type="com.couplet.common.domain.CoupletTroubleCode" id="SysTroubleResult">
<id property="troubleId" column="trouble_id"/>
<result property="troubleCode" column="trouble_code"/>
<result property="troubleVin" column="trouble_vin"/>
<result property="troubleStartTime" column="trouble_start_time"/>
<result property="troubleEndTime" column="trouble_end_time"/>
<result property="processingState" column="processing_state"/>
</resultMap>
<sql id="selectTroubleVo">
select t.*,f.trouble_fault_type,f.trouble_fault_tag from couplet_trouble_code t
LEFT JOIN couplet_trouble_fault f on t.trouble_position = f.trouble_fault_position
</sql>
<insert id="newFaultData">
INSERT INTO `couplet-cloud`.`couplet_trouble_code`
(`trouble_code`,`trouble_vin`,`trouble_position`,`trouble_start_time`,`processing_state`)
VALUES
(#{troubleCode},#{troubleVin}, #{troublePosition},#{troubleStartTime},#{processingState})
</insert>
<update id="cleanTroubleCode">
truncate table couplet_trouble_code
</update>
<update id="updateState">
update couplet_trouble_code set processing_state = 1 where thourble_id = #{troubleId}
</update>
<select id="selectTroubleList" parameterType="com.couplet.business.server.mapper.SysTroubleMapper" resultMap="SysTroubleResult">
<include refid="selectTroubleVo"/>
<where>
<if test="troubleCode != null and troubleCode != ''">
AND trouble_code = #{troubleCode}
</if>
<if test="troublePosition != null and troublePosition != ''">
AND trouble_position like concat('%', #{troublePosition}, '%')
</if>
</where>
</select>
<select id="selectTroubleListByGrade" resultType="com.couplet.common.domain.CoupletTroubleGrade">
select * from couplet_trouble_grade
</select>
</mapper>