<?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.casic.missiles.mapper.meter.MeterTrainLogMapper">
<resultMap id="TrainLogDetailResultMap" type="com.casic.missiles.dto.meter.TrainLogDetailResponse">
<result column="log_no" property="logNo"/>
<result column="preparer" property="preparer"/>
<result column="train_name" property="trainName"/>
<result column="train_person" property="trainPerson"/>
<result column="train_number" property="trainNumber"/>
<result column="train_time" property="trainTime"/>
<result column="train_hour" property="trainHour"/>
<result column="train_address" property="trainAddress"/>
<result column="train_content" property="trainContent"/>
<result column="train_effect" property="trainEffect"/>
<result column="problems" property="problems"/>
<result column="improve_method" property="improveMethod"/>
<result column="log_remark" property="remark"/>
<collection property="trainStaffList" javaType="list" ofType="com.casic.missiles.model.meter.MeterTrainStaff">
<result column="id" property="id"/>
<result column="staff_id" property="staffId"/>
<result column="plan_id" property="planId"/>
<result column="name" property="name"/>
<result column="company" property="company"/>
<result column="technology_job" property="technologyJob"/>
<result column="exam_result" property="examResult"/>
<result column="sign_time" property="signTime"/>
<result column="remark" property="remark"/>
</collection>
</resultMap>
<select id="selectMaxTrainLogNo" resultType="java.lang.Long">
SELECT IFNULL(max(RIGHT(log_no, 12)), 0) from meter_train_log
</select>
<select id="selectTrainLogById" resultMap="TrainLogDetailResultMap">
SELECT mtl.log_no, mtl.preparer, mtl.train_name, mtl.train_person, mtl.train_number, mtl.train_time, mtl.train_hour,
mtl.train_address, mtl.train_content, mtl.train_effect, mtl.problems, mtl.improve_method, mtl.remark AS log_remark,
mts.id, mts.staff_id, mts.plan_id,mts.name, mts.company, mts.technology_job, mts.sign_time, mts.exam_result, mts.remark
FROM meter_train_log mtl
LEFT JOIN meter_train_plan mtp ON mtp.id = mtl.plan_id
LEFT JOIN meter_train_staff mts ON mtp.id = mts.plan_id
WHERE mtl.id = #{id} AND mtl.is_del = 0
</select>
</mapper>