ZengTao
2025-02-21 5ad6234b30f68ae65d6ffc345e874af09c56f4e3
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?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.rawglassdetails.mapper.RawGlassStorageDetailsMapper">
 
    <resultMap id="baseMap" type="com.mes.rawglassdetails.entity.RawGlassStorageDetails">
        <result column="DEVICE_ID" property="deviceId"/>
        <result column="SLOT" property="slot"/>
    </resultMap>
    <resultMap id="RawGlassStorageDetailsDTO" type="com.mes.rawglassdetails.entity.dto.RawGlassStorageDetailsDTO">
        <result property="patternWidth" column="pattern_width"/>
        <result property="patternHeight" column="pattern_height"/>
        <result property="patternThickness" column="pattern_thickness"/>
        <result property="filmsId" column="films_id"/>
        <result property="count" column="count"/>
        <result property="finishCount" column="finishCount"/>
        <result property="damageCount" column="damageCount"/>
        <!-- 如果有其他字段,请继续添加 -->
    </resultMap>
 
 
    <select id="listBySlotState" resultMap="baseMap">
        SELECT
        T.SLOT,
        T.DEVICE_ID
        FROM
        RAW_GLASS_STORAGE_STATION T
        LEFT JOIN RAW_GLASS_STORAGE_DETAILS AS T1 ON T.DEVICE_ID = T1.DEVICE_ID
        AND T.SLOT = T1.SLOT
        AND T1.STATE IN
        <foreach collection="state" item="item" open='(' close=')' separator=','>
            #{item}
        </foreach>
        WHERE
        T.ENABLE_STATE = 1
        AND T.DEVICE_ID IN
        <foreach collection="leftingStation" item="item" open='(' close=')' separator=','>
            #{item}
        </foreach>
        AND T1.SLOT IS NULL
    </select>
 
    <select id="listBySlotState" resultMap="RawGlassStorageDetailsDTO">
        select rgsd.pattern_width,
               rgsd.pattern_height,
               rgsd.pattern_thickness,
               rgsd.films_id,
               rgsd.count + sum(lgdth.finish_count) + sum(damage_count),
               rgsd.count,
               sum(lgdth.finish_count) as finishCount,
               sum(damage_count)       as damageCount
        from (select pattern_width,
                     pattern_height,
                     pattern_thickness,
                     films_id,
                     sum(case when state = 100 then remain_quantity else 0 end) as count
              from raw_glass_storage_details
              group by pattern_width, pattern_height, pattern_thickness, films_id) as rgsd
                 left JOIN load_glass_device_task_history as lgdth
                           on rgsd.pattern_width = lgdth.raw_glass_width
                               and rgsd.pattern_height = lgdth.raw_glass_height
                               and rgsd.pattern_thickness = lgdth.raw_glass_thickness
                               and rgsd.films_id = lgdth.raw_glass_films_id
        where rgsd.pattern_width like "%#{processId}%"
          and rgsd.pattern_height like "%#{pattern_height}%"
          and rgsd.pattern_thickness like "%#{pattern_thickness}%"
          and rgsd.films_id like "%#{films_id}%"
        group by rgsd.pattern_width, rgsd.pattern_height, rgsd.pattern_thickness, rgsd.films_id
    </select>
</mapper>