<?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.mes.uppattenusage.mapper.UpPattenUsageMapper">
|
|
<resultMap id="baseMap" type="com.mes.uppattenusage.entity.vo.UpPattenUsageVO">
|
<result column="id" property="id"/>
|
<result column="engineering_id" property="engineeringId"/>
|
<result column="films_id" property="filmsId"/>
|
<result column="width" property="width"/>
|
<result column="height" property="height"/>
|
<result column="thickness" property="thickness"/>
|
<result column="layout_sequence" property="layoutSequence"/>
|
<result column="state" property="state"/>
|
<result column="group_number" property="groupNumber"/>
|
</resultMap>
|
<select id="queryRawGlassByEngineeringId" resultMap="baseMap">
|
SELECT
|
t.*,
|
t.group_number
|
FROM (
|
SELECT
|
upu.*,
|
-- 计算组号
|
@counter := IF(@prev_width = upu.width AND @prev_height = upu.height,
|
@counter,
|
@counter + 1) AS group_number,
|
-- 变量赋值
|
@prev_width := upu.width,
|
@prev_height := upu.height
|
FROM
|
up_patten_usage upu,
|
-- 关键:用虚拟表初始化变量,替代单独的SET语句
|
(SELECT @prev_width := NULL, @prev_height := NULL, @counter := 0) AS init_var
|
WHERE
|
upu.engineering_id = #{engineeringId}
|
AND upu.state = 0
|
ORDER BY
|
upu.layout_sequence
|
) AS t
|
</select>
|
<select id="queryFinishByEngineering" resultType="java.lang.Integer">
|
SELECT id
|
FROM up_patten_usage
|
WHERE engineering_id IN (SELECT engineer_id FROM engineering WHERE station_cell = #{stationCell} AND state = 1)
|
and state = 0
|
order by id
|
LIMIT ${finishCount}
|
</select>
|
|
|
</mapper>
|