Files
klp-oa/klp-pocket/src/main/resources/mapper/pocket/AcidOeeMapper.xml
2026-02-04 15:22:34 +08:00

96 lines
4.9 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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.klp.pocket.acid.mapper.AcidOeeMapper">
<!-- OEE日汇总结果映射 -->
<resultMap id="AcidOeeDailySummaryResultMap" type="com.klp.pocket.acid.domain.vo.AcidOeeDailySummaryVo">
<result column="stat_date" property="statDate" jdbcType="VARCHAR"/>
<result column="line_id" property="lineId" jdbcType="VARCHAR"/>
<result column="line_name" property="lineName" jdbcType="VARCHAR"/>
<result column="planned_time_min" property="plannedTimeMin" jdbcType="BIGINT"/>
<result column="planned_downtime_min" property="plannedDowntimeMin" jdbcType="BIGINT"/>
<result column="loading_time_min" property="loadingTimeMin" jdbcType="BIGINT"/>
<result column="downtime_min" property="downtimeMin" jdbcType="BIGINT"/>
<result column="run_time_min" property="runTimeMin" jdbcType="BIGINT"/>
<result column="total_output_ton" property="totalOutputTon" jdbcType="DECIMAL"/>
<result column="total_output_coil" property="totalOutputCoil" jdbcType="BIGINT"/>
<result column="good_output_ton" property="goodOutputTon" jdbcType="DECIMAL"/>
<result column="good_output_coil" property="goodOutputCoil" jdbcType="BIGINT"/>
<result column="defect_output_ton" property="defectOutputTon" jdbcType="DECIMAL"/>
<result column="defect_output_coil" property="defectOutputCoil" jdbcType="BIGINT"/>
<result column="ideal_cycle_time_min_per_ton" property="idealCycleTimeMinPerTon" jdbcType="DECIMAL"/>
<result column="ideal_cycle_time_min_per_coil" property="idealCycleTimeMinPerCoil" jdbcType="DECIMAL"/>
</resultMap>
<!-- 查询OEE日汇总 -->
<select id="selectDailySummary" resultMap="AcidOeeDailySummaryResultMap">
SELECT
DATE_FORMAT(e.INSDATE, '%Y-%m-%d') AS stat_date,
'SY' AS line_id,
'酸轧线' AS line_name,
-- 计划时间暂时使用24小时1440分钟后续可从计划表获取
1440 AS planned_time_min,
-- 计划停机暂时为0后续可从停机事件表中筛选stop_type='计划停机'的汇总
0 AS planned_downtime_min,
-- 负荷时间 = 计划时间 - 计划停机
1440 AS loading_time_min,
-- 停机时间在Service层通过停机事件表聚合填充
0 AS downtime_min,
-- 总产量(吨):出口重量总和
COALESCE(SUM(e.EXIT_WEIGHT), 0) AS total_output_ton,
-- 总产量(卷):记录数
COUNT(*) AS total_output_coil,
-- 良品/次品在Service层通过WMS判定后填充
0 AS good_output_ton,
0 AS good_output_coil,
0 AS defect_output_ton,
0 AS defect_output_coil,
-- 理论节拍在Service层通过回归数据填充
NULL AS ideal_cycle_time_min_per_ton,
NULL AS ideal_cycle_time_min_per_coil
FROM klptcm1_pdo_excoil e
WHERE DATE(e.INSDATE) BETWEEN #{startDate} AND #{endDate}
GROUP BY DATE_FORMAT(e.INSDATE, '%Y-%m-%d')
ORDER BY stat_date ASC
</select>
<!-- 查询每日的钢卷号和重量(用于良品/次品判定) -->
<select id="selectCoilInfoByDate" resultType="com.klp.pocket.acid.mapper.AcidOeeMapper$CoilInfoByDate">
SELECT
DATE_FORMAT(e.INSDATE, '%Y-%m-%d') AS statDate,
-- 当前钢卷号使用出口卷号excoilid或成品卷号encoilid
COALESCE(e.EXCOILID, e.ENCOILID) AS coilNo,
-- 重量(吨):出口重量
e.EXIT_WEIGHT AS weight
FROM klptcm1_pdo_excoil e
WHERE DATE(e.INSDATE) BETWEEN #{startDate} AND #{endDate}
AND e.EXIT_WEIGHT IS NOT NULL
AND e.EXIT_WEIGHT > 0
AND (e.EXCOILID IS NOT NULL OR e.ENCOILID IS NOT NULL)
ORDER BY e.INSDATE ASC, e.ENCOILID ASC
</select>
<!-- 查询卷级生产节拍min/吨):(END_DATE - START_DATE)/EXIT_WEIGHT -->
<select id="selectCoilCycleMinPerTon" resultType="java.math.BigDecimal">
SELECT
-- 生产节拍(分钟/吨)
TIMESTAMPDIFF(MINUTE, e.START_DATE, e.END_DATE) / e.EXIT_WEIGHT AS cycle_min_per_ton
FROM klptcm1_pdo_excoil e
WHERE 1 = 1
<if test="startDate != null and startDate != ''">
AND DATE(e.INSDATE) &gt;= #{startDate}
</if>
<if test="endDate != null and endDate != ''">
AND DATE(e.INSDATE) &lt;= #{endDate}
</if>
AND e.START_DATE IS NOT NULL
AND e.END_DATE IS NOT NULL
AND e.END_DATE &gt; e.START_DATE
AND e.EXIT_WEIGHT IS NOT NULL
AND e.EXIT_WEIGHT &gt; 0
AND TIMESTAMPDIFF(MINUTE, e.START_DATE, e.END_DATE) &gt; 0
</select>
</mapper>