huang
2025-10-22 3eaf0f2f1b909ac429cac9fc26af767ddecda065
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?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>