<?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.shkj.wms.mapper.BusinDpsContainerRecordMapper">
    <resultMap type="BusinDpsContainerRecord" id="BusinDpsRecordResult">
        <result property="id"    column="id"    />
        <result property="containerId"    column="container_id"    />
        <result property="pointNo"    column="point_no"    />
        <result property="isState"    column="is_state"    />
        <result property="taskCode"    column="task_code"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="branchId"    column="branch_id"    />
    </resultMap>

    <sql id="selectBusinPunchRecordVo">
        select id, punch_no, agv_no, is_state, task_code, create_time, update_time, create_by, update_by, branch_id from busin_punch_record
    </sql>

    <select id="selectBusinDpscontainerRecord" parameterType="String" resultType="map">
        select record.*,pointGroup.max_task_qty,pointGroup.min_task_qty  from (
        select count(*) as counts,point_no as pointNo from busin_dpscontainer_record
        where is_state=0 or is_state=1
        <if test="punchNo != null "> and point_no = #{pointNo}</if>
        group by point_no
        ) as record
        inner join base_point point  on record.pointNo = point.point_no
        inner join base_point_group pointGroup on pointGroup.id =point.point_group
    </select>

    <select id="selectBusinDpscontainerRecord1" parameterType="String" resultType="map">
        select record.*,pointGroup.max_task_qty,pointGroup.min_task_qty  from (
        select count(*) as counts,point_no as pointNo from busin_dpscontainer_record
        where is_state=1
        <if test="punchNo != null "> and point_no = #{pointNo}</if>
        group by point_no
        ) as record
        inner join base_point point  on record.pointNo = point.point_no
        inner join base_point_group pointGroup on pointGroup.id =point.point_group
    </select>

    <select id="selectByTaskid" parameterType="String" resultMap="BusinDpsRecordResult">
        select *
        from
            busin_dpscontainer_record
        where
            task_code=#{taskid}
    </select>
</mapper>
