ZengTao
2025-09-11 924ce82faeec6d896fcdc360b279215e84b69fb9
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
<?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.bigstorage.mapper.BigStorageCageMapper">
 
 
    <select id="queryFreeDeviceByUsed" resultType="java.lang.Integer">
        SELECT
            T.DEVICE_ID
        FROM BIG_STORAGE_CAGE T
                 LEFT JOIN (SELECT * FROM BIG_STORAGE_CAGE_DETAILS WHERE STATE NOT IN (101, 8, 9)) T1
                           ON T.SLOT = T1.SLOT
        WHERE T.MAX_THICKNESS >= #{thickness} AND T.SLOT_HEIGHT &gt; #{slotHeight}
          AND T.ENABLE_STATE = 1
        GROUP BY T.DEVICE_ID
        HAVING COUNT(DISTINCT T.SLOT) - COUNT(DISTINCT T1.SLOT) > 0
        ORDER BY min(T.MAX_THICKNESS),
                 TRUNCATE(COUNT(DISTINCT T1.TEMPERING_LAYOUT_ID)/9,0), COUNT(DISTINCT T1.TEMPERING_LAYOUT_ID)%9 DESC,
                                 FIELD(T.device_id, 5, 4, 3, 2, 1), T.device_id
    </select>
 
    <!--    <select id="queryFreeDeviceByNotUsed" resultType="java.lang.Integer">-->
    <!--        SELECT T.DEVICE_ID-->
    <!--        FROM BIG_STORAGE_CAGE T-->
    <!--                 LEFT JOIN (SELECT * FROM BIG_STORAGE_CAGE_DETAILS WHERE STATE NOT IN (101, 8, 9)) T1-->
    <!--                           ON T.SLOT = T1.SLOT-->
    <!--        WHERE T.MAX_THICKNESS >= #{thickness}-->
    <!--          AND T.ENABLE_STATE = 1-->
    <!--        GROUP BY T.DEVICE_ID-->
    <!--        ORDER BY COUNT(DISTINCT T1.ENGINEER_ID)-->
    <!--                 COUNT(DISTINCT T1.TEMPERING_LAYOUT_ID),-->
    <!--                 COUNT(DISTINCT T.SLOT) - COUNT(DISTINCT T1.SLOT) DESC-->
    <!--    </select>-->
    <select id="queryPieChart" resultType="com.mes.largenscreen.entity.PieChartVO">
        SELECT
            round(sum( CASE WHEN e.station_cell = 5 THEN 1 ELSE 0 END ),2) as oneCompletedQuantity,
            round(sum( CASE WHEN e.station_cell = 5 THEN bscd.width*bscd.height/1000000 ELSE 0 END ),2) as oneCompletedArea,
            round(sum( CASE WHEN e.station_cell = 6 THEN 1 ELSE 0 END ),2) as twoCompletedQuantity,
            round(sum( CASE WHEN e.station_cell = 6 THEN bscd.width*bscd.height/1000000 ELSE 0 END ),2) as twoCompletedArea,
            round(sum( CASE WHEN e.station_cell = 5 and bscd.device_id is null THEN 1 ELSE 0 END ),2) as oneUncompletedQuantity,
            round(sum( CASE WHEN e.station_cell = 5 and bscd.device_id is null THEN gi.width*gi.height/1000000 ELSE 0 END ),2) as oneUncompletedArea,
            round(sum( CASE WHEN e.station_cell = 6 and bscd.device_id is null THEN 1 ELSE 0 END ),2) as twoUncompletedQuantity,
            round(sum( CASE WHEN e.station_cell = 6 and bscd.device_id is null THEN gi.width*gi.height/1000000 ELSE 0 END ),2) as twoUncompletedArea
        FROM
            glass_info gi
                left join big_storage_cage_details bscd ON gi.glass_id = bscd.glass_id
                left join engineering e on gi.engineer_id=e.engineer_id
        WHERE
            date(e.create_time) = date(now())
    </select>
</mapper>