<?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.fjhx.sale.mapper.pack.PackDetailMapper">
    <select id="getPage" resultType="com.fjhx.sale.entity.pack.vo.PackDetailVo">
        select *
        from (SELECT
                     GROUP_CONCAT( t1.id ) AS ids,
                     t1.id,
                     t1.pack_id,
                     t1.waybill_code,
                     t1.express_id,
                     t1.remark,
                     t1.update_time,
                     t1.update_user,
                     t1.create_user,
                     t1.create_time,
                     (SELECT GROUP_CONCAT(CONCAT(t3.`code`, "_", t2.product_name)) AS codeAPName
                      FROM pack_detail_product t2
                               LEFT JOIN contract t3 ON t2.contract_id = t3.id
                      WHERE FIND_IN_SET(t2.pack_detail_id,GROUP_CONCAT( t1.id ))) AS codeAPName,
                     (SELECT GROUP_CONCAT( CONCAT(
                               bom_volume,  ",", box_long, ",", box_wide, ",", box_high, ",", rough_weight, ",", net_weight,",",pack_quantity
                         ) SEPARATOR &apos;_&apos;) FROM pack_detail WHERE 	FIND_IN_SET(id,GROUP_CONCAT( t1.id )) ) AS dataJsonList,
                     sum(t1.pack_quantity)                                 packQuantity,
                     sum( t1.net_weight*t1.pack_quantity )                 netWeight,
                     sum( t1.rough_weight*t1.pack_quantity )               roughWeight,
                     t1.box_long,
                     t1.box_wide,
                     t1.box_high,
                     sum( t1.bom_volume*t1.pack_quantity )                 bomVolume,
                     t1.shipment_status,
                     t1.shipment_time,
                     t1.contract_ids
              FROM pack_detail t1
              GROUP BY t1.pack_id
              ORDER BY t1.create_time desc) pd
            ${ew.customSqlSegment}
    </select>

</mapper>
