<?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.fizz.business.mapper.PlanDashboardMapper">

    <!-- 当前生产中的计划（status = 'PRODUCING'，按 producing_time / start_date 倒序取最新一条） -->
    <select id="selectCurrentProducingPlan" resultType="java.util.Map">
        SELECT
            id,
            coilid,
            planid,
            steel_grade       AS steelGrade,
            entry_weight      AS entryWeight,
            entry_thick       AS entryThick,
            entry_width       AS entryWidth,
            entry_length      AS entryLength,
            status,
            start_date        AS startDate,
            end_date          AS endDate,
            producing_time    AS producingTime,
            unit_code         AS unitCode
        FROM crm_pdi_plan
        WHERE status = 'PRODUCING'
        ORDER BY
            producing_time DESC,
            start_date DESC,
            id DESC
        LIMIT 1
    </select>

</mapper>

