<?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.huazheng.project.mysql.mapper.TmsMapper">
    
    <select id="selectTransformHistoryNodeNew" parameterType="TransformHistoryNode" resultType="TransformHistoryNode">
		select 
			id, task_no, last_commit_time, second_node
		from transform_history_node
		where id &gt; #{id}
		limit 20
    </select>
    <select id="selectHandoverTaskNew" parameterType="HandoverTask" resultType="HandoverTask">
    	select 
    		a.task_id, a.task_no, a.task_type, a.task_state, a.f_plant, a.plant, a.customer_id,
    		customer_name, a.kunnr, a.actual_handover_num, a.receipt_state, a.receipt_time,
    		cost_state, a.cost_handle_time, a.handover_print_state, a.last_print_time,
    		appearance_state, a.appearance_time, a.company_id, a.company_no, a.company_name,
    		netweight_count, a.weight_count, a.handover_direct_count, a.transport_type, a.vehicle_type,
    		delivery_cost, a.delivery_date, a.sign_time, a.area_name, a.area_id, a.port, a.delivery_type,
    		dispatch_type, a.piece_count, a.remark, a.is_valid, a.created_user_id, a.created_time,
    		modified_user_id, a.modified_time, a.receipt_remark,b.s12,b.s21,b.s24
    	from handover_task a
    	LEFT JOIN (
			SELECT 
				task_no,
				MAX(IF(second_node='12',last_commit_time,NULL)) AS s12,
				MAX(IF(second_node='21',last_commit_time,NULL)) AS s21,
				MAX(IF(second_node='24',last_commit_time,NULL)) AS s24
			FROM transform_history_node 
			GROUP BY task_no
		) b ON a.task_no = b.task_no
		where a.task_id &gt; #{task_id}
		limit 20
    </select>
	<select id="selectTransformNewNodeNew" parameterType="TransformNewNode" resultType="TransformNewNode">
		select id, task_id, task_no, vehicle_no, last_commit_time, first_node, second_node, 
			vehicle_type, driver, driver_phone, location, exception_comment, comit_type, 
			exception_type, exception_picture, is_valid, lon, lat, created_user_id, 
			created_time, modified_user_id, modified_time
		from transform_new_node
		where id &gt; #{id}
		limit 20
    </select>
    <select id="selectHandoverNew" parameterType="Handover" resultType="Handover">
    	select 
			vbeln, task_id, handover_id, handover_type, order_type, task_no, sale_no, 
			delivery_type, handover_state, f_plant, plant, customer_id, customer_name, 
			fmenge, delivery_num, port, piect_total, total_net_weight, weight_total, 
			settlement_weight, weight_state, vrkme, average_freight, order_remark, 
			delivery_time, erdat, plan_product_time, open_ready_time, already_ready_time, 
			appearance_time, sign_time, edatu, area_no, area_name, fmenge_time, klabc, 
			sales_man, sales_department, is_valid, created_user_id, created_time, 
			modified_user_id, modified_time, remark, is_auto_created, delivery_state, 
			operate_tag, transport_time, is_date_success, is_num_success, is_sign_success, 
			weighing_weight, delivery_issued_time
    	from handover 
    	where handover_id &gt; #{handover_id}
		limit 20
    </select>

	<select id="selectHandoverById" parameterType="Handover" resultType="Handover">
		select 
			vbeln, task_id, handover_id, handover_type, order_type, task_no, sale_no, 
			delivery_type, handover_state, f_plant, plant, customer_id, customer_name, 
			fmenge, delivery_num, port, piect_total, total_net_weight, weight_total, 
			settlement_weight, weight_state, vrkme, average_freight, order_remark, 
			delivery_time, erdat, plan_product_time, open_ready_time, already_ready_time, 
			appearance_time, sign_time, edatu, area_no, area_name, fmenge_time, klabc, 
			sales_man, sales_department, is_valid, created_user_id, created_time, 
			modified_user_id, modified_time, remark, is_auto_created, delivery_state, 
			operate_tag, transport_time, is_date_success, is_num_success, is_sign_success, 
			weighing_weight, delivery_issued_time
		from handover where handover_id = #{handover_id}
    </select>
	<select id="selectHandoverTaskById" parameterType="HandoverTask" resultType="HandoverTask">
    	select 
    		a.task_id, a.task_no, a.task_type, a.task_state, a.f_plant, a.plant, a.customer_id,
    		customer_name, a.kunnr, a.actual_handover_num, a.receipt_state, a.receipt_time,
    		cost_state, a.cost_handle_time, a.handover_print_state, a.last_print_time,
    		appearance_state, a.appearance_time, a.company_id, a.company_no, a.company_name,
    		netweight_count, a.weight_count, a.handover_direct_count, a.transport_type, a.vehicle_type,
    		delivery_cost, a.delivery_date, a.sign_time, a.area_name, a.area_id, a.port, a.delivery_type,
    		dispatch_type, a.piece_count, a.remark, a.is_valid, a.created_user_id, a.created_time,
    		modified_user_id, a.modified_time, a.receipt_remark,b.s12,b.s21,b.s24
    	from handover_task a
    	LEFT JOIN (
			SELECT 
				task_no,
				MAX(IF(second_node='12',last_commit_time,NULL)) AS s12,
				MAX(IF(second_node='21',last_commit_time,NULL)) AS s21,
				MAX(IF(second_node='24',last_commit_time,NULL)) AS s24
			FROM transform_history_node 
			GROUP BY task_no
		) b ON a.task_no = b.task_no
		where a.task_id = #{task_id}
    </select>
    <select id="selectTransformNewNodeById" parameterType="TransformNewNode" resultType="TransformNewNode">
		select 
			id, task_id, task_no, vehicle_no, last_commit_time, first_node, second_node, 
			vehicle_type, driver, driver_phone, location, exception_comment, comit_type, 
			exception_type, exception_picture, is_valid, lon, lat, created_user_id, 
			created_time, modified_user_id, modified_time
		from transform_new_node where id = #{id}
    </select>
	<select id="selectTransformHistoryNodeById" parameterType="TransformHistoryNode" resultType="TransformHistoryNode">
		select id, task_no, last_commit_time, second_node
		from transform_history_node where id = #{id}
    </select>
    
</mapper>
