GarOrderMatchAskMapper.xml 16.8 KB
<?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.trash.garbage.mapper.GarOrderMatchAskMapper">

    <resultMap id="BaseResultMap" type="com.trash.garbage.pojo.domain.GarOrderMatchAsk">
            <id property="garId" column="gar_id" jdbcType="VARCHAR"/>
            <result property="garOrderId" column="gar_order_id" jdbcType="VARCHAR"/>
            <result property="garCarryingWeight" column="gar_carrying_weight" jdbcType="VARCHAR"/>
            <result property="garOrderHandlerTel" column="gar_order_handler_tel" jdbcType="VARCHAR"/>
            <result property="garOrderHandlerName" column="gar_order_handler_name" jdbcType="VARCHAR"/>
            <result property="garOrderContainerVolume" column="gar_order_container_volume" jdbcType="VARCHAR"/>
            <result property="garOrderHandlerCompanyId" column="gar_order_handler_company_id" jdbcType="VARCHAR"/>
            <result property="garOrderHandlerCompanyName" column="gar_order_handler_company_name" jdbcType="VARCHAR"/>
            <result property="garCreateTime" column="gar_create_time" jdbcType="TIMESTAMP"/>
            <result property="garUpdateTime" column="gar_update_time" jdbcType="TIMESTAMP"/>
            <result property="garCreateBy" column="gar_create_by" jdbcType="VARCHAR"/>
            <result property="garUpdateBy" column="gar_update_by" jdbcType="VARCHAR"/>
            <result property="garRemark" column="gar_remark" jdbcType="VARCHAR"/>
    </resultMap>

    <sql id="Base_Column_List">
        gar_id,gar_order_id,gar_order_handler_tel,gar_order_container_volume,gar_carrying_weight,
        gar_order_handler_name,gar_order_handler_company_id,gar_order_handler_company_name,
        gar_create_time,gar_update_time,gar_create_by,
        gar_update_by,gar_remark
    </sql>
    <resultMap type="DriverSend" id="driverSendMap">
        <result property="orderId" column="order_id" />
        <result property="phone" column="phone" />
    </resultMap>

    <insert id="addDriverSend" parameterType="DriverSend">
        insert into driver_send (order_id,phone,state) values (#{orderId},#{phone},#{state})
    </insert>
    <select id="queryDriverSend" parameterType="DriverSend" resultMap="driverSendMap">
        select * from driver_send where phone = #{phone} and state = 0 limit 1
    </select>
    <update id="updateDriverSendState" parameterType="DriverSend">
        update  driver_send set state = 1 where  phone = #{phone}
    </update>

    <resultMap type="GarOrderMatchAsk" id="GarOrderMatchAskResult">
        <result property="garId"    column="gar_id"    />
        <result property="garOrderId"    column="gar_order_id"    />
        <result property="garOrderHandlerTel"    column="gar_order_handler_tel"    />
        <result property="garOrderHandlerName"    column="gar_order_handler_name"    />
        <result property="garOrderContainerVolume"    column="gar_order_container_volume"    />
        <result property="garOrderHandlerId"    column="gar_order_handler_id"    />
        <result property="garHandlerCarCode"    column="gar_handler_car_code"    />
        <result property="garOrderHandlerCompanyId"    column="gar_order_handler_company_id"    />
        <result property="garOrderHandlerCompanyName"    column="gar_order_handler_company_name"    />
        <result property="garCreateTime"    column="gar_create_time"    />
        <result property="garUpdateTime"    column="gar_update_time"    />
        <result property="garCreateBy"    column="gar_create_by"    />
        <result property="garUpdateBy"    column="gar_update_by"    />
        <result property="garRemark"    column="gar_remark"    />
        <result property="garCarryingWeight"    column="gar_carrying_weight"    />
        <result property="dropPointId"    column="drop_point_id"    />
        <result property="dropPointName"    column="drop_point_name"    />
        <result property="garOrderType"    column="gar_order_type"    />
        <result property="disposalId"    column="disposal_id"    />
        <result property="disposalSiteName"    column="disposal_site_name"    />
        <result property="garOrderNumber"    column="gar_order_number"    />
        <result property="garOrderPhone"    column="gar_order_phone"    />
        <result property="garOrderName"    column="gar_order_name"    />
        <result property="dropCustodianPhone"    column="drop_custodian_phone"    />
        <result property="dropAddress"    column="drop_address"    />
        <result property="dropCarNum"    column="drop_car_num"    />
        <result property="garCarCode"    column="gar_car_code"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="garOrderTime"    column="gar_order_time"    />
        <result property="transportDistance"    column="transport_distance"    />
        <result property="unloadingLonLat" column="unloading_lon_lat" />
    </resultMap>

    <sql id="selectGarOrderMatchAskVo">
        select gar_id,gar_order_id,gar_order_handler_tel,gar_order_handler_name,gar_order_container_volume,gar_order_handler_id,gar_handler_car_code,gar_order_handler_company_id,gar_order_handler_company_name,gar_create_time,gar_update_time,gar_create_by,gar_update_by,gar_remark,gar_carrying_weight,drop_point_id,drop_point_name,gar_order_type,disposal_id,disposal_site_name,gar_order_number,gar_order_phone,gar_order_name,drop_custodian_phone,drop_address,drop_car_num,gar_car_code,create_time,create_by,update_time,update_by,gar_order_time,transport_distance from gar_order_match_ask
    </sql>

    <select id="selectGarOrderMatchAskList" parameterType="GarOrderMatchAsk" resultMap="GarOrderMatchAskResult">
        <include refid="selectGarOrderMatchAskVo"/>
        <where>
            <if test="garOrderId != null  and garOrderId != ''"> and gar_order_id = #{garOrderId}</if>
            <if test="garOrderHandlerTel != null  and garOrderHandlerTel != ''"> and gar_order_handler_tel = #{garOrderHandlerTel}</if>
            <if test="garOrderHandlerName != null  and garOrderHandlerName != ''"> and gar_order_handler_name like concat('%', #{garOrderHandlerName}, '%')</if>
            <if test="garOrderContainerVolume != null  and garOrderContainerVolume != ''"> and gar_order_container_volume = #{garOrderContainerVolume}</if>
            <if test="garOrderHandlerId != null  and garOrderHandlerId != ''"> and gar_order_handler_id = #{garOrderHandlerId}</if>
            <if test="garHandlerCarCode != null  and garHandlerCarCode != ''"> and gar_handler_car_code like concat('%', #{garHandlerCarCode}, '%')</if>
            <if test="garOrderHandlerCompanyId != null  and garOrderHandlerCompanyId != ''"> and gar_order_handler_company_id = #{garOrderHandlerCompanyId}</if>
            <if test="garOrderHandlerCompanyName != null  and garOrderHandlerCompanyName != ''"> and gar_order_handler_company_name like concat('%', #{garOrderHandlerCompanyName}, '%')</if>
            <if test="garCreateTime != null "> and gar_create_time = #{garCreateTime}</if>
            <if test="garUpdateTime != null "> and gar_update_time = #{garUpdateTime}</if>
            <if test="garCreateBy != null  and garCreateBy != ''"> and gar_create_by = #{garCreateBy}</if>
            <if test="garUpdateBy != null  and garUpdateBy != ''"> and gar_update_by = #{garUpdateBy}</if>
            <if test="garRemark != null  and garRemark != ''"> and gar_remark = #{garRemark}</if>
            <if test="garCarryingWeight != null "> and gar_carrying_weight = #{garCarryingWeight}</if>
            <if test="dropPointName != null  and dropPointName != ''"> and drop_point_name like concat('%', #{dropPointName}, '%')</if>
            <if test="garOrderType != null  and garOrderType != ''"> and gar_order_type = #{garOrderType}</if>
            <if test="disposalId != null  and disposalId != ''"> and disposal_id = #{disposalId}</if>
            <if test="disposalSiteName != null  and disposalSiteName != ''"> and disposal_site_name like concat('%', #{disposalSiteName}, '%')</if>
            <if test="garOrderNumber != null  and garOrderNumber != ''"> and gar_order_number = #{garOrderNumber}</if>
            <if test="garOrderPhone != null  and garOrderPhone != ''"> and gar_order_phone = #{garOrderPhone}</if>
            <if test="garOrderName != null  and garOrderName != ''"> and gar_order_name like concat('%', #{garOrderName}, '%')</if>
        </where>
        <!-- 添加按创建时间倒序排序 -->
        order by gar_create_time desc
    </select>

    <select id="selectGarOrderMatchAskById" parameterType="String" resultMap="GarOrderMatchAskResult">
        <include refid="selectGarOrderMatchAskVo"/>
        where gar_id = #{garId}
    </select>

    <insert id="insertGarOrderMatchAsk" parameterType="GarOrderMatchAsk">
        insert into gar_order_match_ask
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="garId != null">gar_id,</if>
            <if test="garOrderId != null">gar_order_id,</if>
            <if test="garOrderHandlerTel != null">gar_order_handler_tel,</if>
            <if test="garOrderHandlerName != null">gar_order_handler_name,</if>
            <if test="garOrderContainerVolume != null">gar_order_container_volume,</if>
            <if test="garOrderHandlerId != null">gar_order_handler_id,</if>
            <if test="garHandlerCarCode != null">gar_handler_car_code,</if>
            <if test="garOrderHandlerCompanyId != null">gar_order_handler_company_id,</if>
            <if test="garOrderHandlerCompanyName != null">gar_order_handler_company_name,</if>
            <if test="garCreateTime != null">gar_create_time,</if>
            <if test="garUpdateTime != null">gar_update_time,</if>
            <if test="garCreateBy != null">gar_create_by,</if>
            <if test="garUpdateBy != null">gar_update_by,</if>
            <if test="garRemark != null">gar_remark,</if>
            <if test="garCarryingWeight != null">gar_carrying_weight,</if>
            <if test="dropPointId != null">drop_point_id,</if>
            <if test="dropPointName != null">drop_point_name,</if>
            <if test="garOrderType != null">gar_order_type,</if>
            <if test="disposalId != null">disposal_id,</if>
            <if test="disposalSiteName != null">disposal_site_name,</if>
            <if test="garOrderNumber != null">gar_order_number,</if>
            <if test="garOrderPhone != null">gar_order_phone,</if>
            <if test="garOrderName != null">gar_order_name,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="garId != null">#{garId},</if>
            <if test="garOrderId != null">#{garOrderId},</if>
            <if test="garOrderHandlerTel != null">#{garOrderHandlerTel},</if>
            <if test="garOrderHandlerName != null">#{garOrderHandlerName},</if>
            <if test="garOrderContainerVolume != null">#{garOrderContainerVolume},</if>
            <if test="garOrderHandlerId != null">#{garOrderHandlerId},</if>
            <if test="garHandlerCarCode != null">#{garHandlerCarCode},</if>
            <if test="garOrderHandlerCompanyId != null">#{garOrderHandlerCompanyId},</if>
            <if test="garOrderHandlerCompanyName != null">#{garOrderHandlerCompanyName},</if>
            <if test="garCreateTime != null">#{garCreateTime},</if>
            <if test="garUpdateTime != null">#{garUpdateTime},</if>
            <if test="garCreateBy != null">#{garCreateBy},</if>
            <if test="garUpdateBy != null">#{garUpdateBy},</if>
            <if test="garRemark != null">#{garRemark},</if>
            <if test="garCarryingWeight != null">#{garCarryingWeight},</if>
            <if test="dropPointId != null">#{dropPointId},</if>
            <if test="dropPointName != null">#{dropPointName},</if>
            <if test="garOrderType != null">#{garOrderType},</if>
            <if test="disposalId != null">#{disposalId},</if>
            <if test="disposalSiteName != null">#{disposalSiteName},</if>
            <if test="garOrderNumber != null">#{garOrderNumber},</if>
            <if test="garOrderPhone != null">#{garOrderPhone},</if>
            <if test="garOrderName != null">#{garOrderName},</if>
        </trim>
    </insert>

    <update id="updateGarOrderMatchAsk" parameterType="GarOrderMatchAsk">
        update gar_order_match_ask
        <trim prefix="SET" suffixOverrides=",">
            <if test="garOrderId != null">gar_order_id = #{garOrderId},</if>
            <if test="garOrderHandlerTel != null">gar_order_handler_tel = #{garOrderHandlerTel},</if>
            <if test="garOrderHandlerName != null">gar_order_handler_name = #{garOrderHandlerName},</if>
            <if test="garOrderContainerVolume != null">gar_order_container_volume = #{garOrderContainerVolume},</if>
            <if test="garOrderHandlerId != null">gar_order_handler_id = #{garOrderHandlerId},</if>
            <if test="garHandlerCarCode != null">gar_handler_car_code = #{garHandlerCarCode},</if>
            <if test="garOrderHandlerCompanyId != null">gar_order_handler_company_id = #{garOrderHandlerCompanyId},</if>
            <if test="garOrderHandlerCompanyName != null">gar_order_handler_company_name = #{garOrderHandlerCompanyName},</if>
            <if test="garCreateTime != null">gar_create_time = #{garCreateTime},</if>
            <if test="garUpdateTime != null">gar_update_time = #{garUpdateTime},</if>
            <if test="garCreateBy != null">gar_create_by = #{garCreateBy},</if>
            <if test="garUpdateBy != null">gar_update_by = #{garUpdateBy},</if>
            <if test="garRemark != null">gar_remark = #{garRemark},</if>
            <if test="garCarryingWeight != null">gar_carrying_weight = #{garCarryingWeight},</if>
            <if test="dropPointId != null">drop_point_id = #{dropPointId},</if>
            <if test="dropPointName != null">drop_point_name = #{dropPointName},</if>
            <if test="garOrderType != null">gar_order_type = #{garOrderType},</if>
            <if test="disposalId != null">disposal_id = #{disposalId},</if>
            <if test="disposalSiteName != null">disposal_site_name = #{disposalSiteName},</if>
            <if test="garOrderNumber != null">gar_order_number = #{garOrderNumber},</if>
            <if test="garOrderPhone != null">gar_order_phone = #{garOrderPhone},</if>
            <if test="garOrderName != null">gar_order_name = #{garOrderName},</if>
        </trim>
        where gar_id = #{garId}
    </update>

    <delete id="deleteGarOrderMatchAskById" parameterType="String">
        delete from gar_order_match_ask where gar_id = #{garId}
    </delete>

    <delete id="deleteGarOrderMatchAskByIds" parameterType="String">
        delete from gar_order_match_ask where gar_id in
        <foreach item="garId" collection="array" open="(" separator="," close=")">
            #{garId}
        </foreach>
    </delete>

    <select id="queryGarOrderMatchAsk" resultType="java.lang.Integer">
        select COUNT(*) from gar_order_match_ask where gar_order_id = #{orderId} and transport_distance is not null
    </select>

    <select id="queryGarOrderMatchAsks" resultType="java.lang.Integer">
        select COUNT(*) from gar_order_match_ask where gar_order_id = #{orderId} and (transport_distance is null or transport_distance = '')
    </select>

    <select id="selectByGarOrderAskId" parameterType="string" resultMap="GarOrderMatchAskResult">
        SELECT gar_id,gar_order_id,gar_create_by,gar_update_by,drop_point_id,drop_point_name,gar_order_type,disposal_id,disposal_site_name,gar_order_number,gar_order_phone,gar_order_name,drop_address,drop_car_num,gar_order_time
        FROM gar_order_match_ask
        WHERE gar_order_id = #{garOrderId}
        ORDER BY gar_order_number DESC
        LIMIT 1
    </select>

    <insert id="insertGarOrderMatchAskBySelect" parameterType="com.trash.garbage.pojo.domain.GarOrderMatchAsk">
        INSERT INTO gar_order_match_ask (
            gar_id,
            gar_order_id,
            gar_create_by,
            gar_update_by,
            drop_point_id,
            drop_point_name,
            gar_order_type,
            disposal_id,
            disposal_site_name,
            gar_order_number,
            gar_order_phone,
            gar_order_name,
            drop_address,
            drop_car_num,
            gar_order_time
        ) VALUES (
                     #{garId},
                     #{garOrderId},
                     #{garCreateBy},
                     #{garUpdateBy},
                     #{dropPointId},
                     #{dropPointName},
                     #{garOrderType},
                     #{disposalId},
                     #{disposalSiteName},
                     #{garOrderNumber},
                     #{garOrderPhone},
                     #{garOrderName},
                     #{dropAddress},
                     #{dropCarNum},
                     #{garOrderTime}
                 )
    </insert>

</mapper>