<?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.bs.jxc.mapper.CmCargoMapper">

    <select id="custCargoList" resultType="CmCargo" parameterType="CmCargo">
        select a.id,
            a.hs_code,
            a.cargo_name,
            a.cargo_spec,
            a.origin_country,
            a.cargo_unit,
            a.ems_no,
            a.gds_seqno,
            a.gds_mtno,
            a.code_ts,
            a.gds_unit,
            a.g_unit_ratio,
            a.first_unit,
            a.first_unit_ratio,
            a.curr,
            a.remark,
            sum(b.cargo_num) cargo_num,
            sum(b.cargo_wt) cargo_wt,
            sum(b.cargo_vol) cargo_vol,
            sum(b.cargo_value) cargo_value
               from cm_cargo a
        left join ck_cargo_stock b
        on a.id = b.cargo_id
        where b.cust_id = #{custId}
          and a.del_flag = '0'
          and b.del_flag = '0'
        GROUP BY a.id

    </select>
</mapper>
