<?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.jeeplus.test.materialManagement.wareHouse.mapper.WareHouseSummaryMapper">
    <delete id="deleteByDetailedId">
        update material_management_warehouse_summary set del_flag = 1
    </delete>
    <select id="getInfoByTradeName"
            resultType="java.lang.Double">
        SELECT
            ( sum( a.trade_number )- c.num2 ) AS num1
        FROM
            material_management_warehouse_detailed a
            LEFT JOIN (
            SELECT
                sum( b.collect_number ) AS num2,
                b.collect_type,
                b.goods_name
            FROM
                material_management_collect_detailed b
                LEFT JOIN material_management_collect_basics c ON b.basic_id = c.id
                AND c.del_flag = 0
            WHERE
                b.collect_type = #{wareHouseType}
                AND b.goods_name = #{tradeName}

            AND b.del_flag = 0
            AND c.`status` = 5
            ) AS c ON a.ware_house_type = c.collect_type
            AND a.trade_name = c.goods_name
        WHERE
            a.ware_house_type = #{wareHouseType}
            AND a.trade_name = #{tradeName}
            AND a.del_flag = 0
    </select>
    <select id="getInfoByBasicId"
            resultType="com.jeeplus.test.materialManagement.wareHouse.domain.WareHouseSummary">
        select * from material_management_warehouse_summary where basic_id = #{id}
    </select>
</mapper>
