<?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.ningdatech.carapi.company.mapper.NdCompanyProductManageMapper">

    <select id="manageList" resultType="com.ningdatech.carapi.company.entity.dto.ResProductManageDTO">
        SELECT ncpm.product_name AS productName,
        ncpm.car_start_time AS carStartTime,
        ncpm.equipment_status AS equipmentStatus,
        ncpm.sum_product_count AS sumProductCount,
        ncpm.real_product_count AS realProductCount,
        ncpm.company_id AS companyId,
        c.name AS companyName,
        ncpm.region_id AS regionId,
        r.name AS regionName
        FROM nd_company_product_manage ncpm
        left join nd_company_info c on ncpm.company_id = c.id
        left join nd_region r on ncpm.region_id = r.id
        <where>
            1 = 1
            <if test="po.companyName != null and po.companyName != ''">
                AND ncpm.company_name LIKE CONCAT(CONCAT('%',
                #{po.companyName}),'%')
            </if>

            <if test="po.regionIds != null and po.regionIds.size > 0">
                AND ncpm.region_id in
                <foreach collection="po.regionIds" item="item" open="(" close= ")" separator=",">
                    #{item}
                </foreach>
            </if>
        </where>
        ${po.dataScopeSql}
        ORDER BY ncpm.id DESC
    </select>
</mapper>
