yangys
2024-11-03 1d5e5ce674ae1cecbf199b885b68e52ac8a9df72
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?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.qianwen.smartman.modules.smis.mapper.WorkstationMapper">
 
    <select id="listWorkStationOnShiftIndex" resultType="com.qianwen.smartman.modules.smis.entity.Workstation">
        SELECT w.*
        FROM blade_workstation w
        INNER JOIN blade_production_calendar pc ON w.calendar_code = pc.code AND pc.year = #{year}
        INNER JOIN blade_production_calendar_day pdc
        ON pc.id = pdc.calendar_id AND pdc.is_deleted = 0 AND pdc.calendar_date = TO_DATE(#{queryDate}, 'yyyy-mm-dd')
        INNER JOIN blade_shift_detail sd ON pdc.model_id = sd.model_id AND sd.shift_index = #{shift}
        WHERE w.is_deleted = 0
        AND pc.is_deleted = 0
        AND pdc.is_deleted = 0
        AND w.type = #{type}
        <if test="ids != null and ids.size() > 0">
            AND w.id IN
            <foreach collection="ids" item="id" open="(" separator="," close=")">
                #{id}
            </foreach>
        </if>
        order by w.code asc;
    </select>
    <select id="countWorkStationOnShiftIndex" resultType="java.lang.Integer">
        SELECT count(*)
        FROM blade_workstation w
        INNER JOIN blade_production_calendar pc ON w.calendar_code = pc.code AND pc.year = #{year}
        INNER JOIN blade_production_calendar_day pdc
        ON pc.id = pdc.calendar_id AND pdc.is_deleted = 0 AND pdc.calendar_date =TO_DATE(#{queryDate}, 'yyyy-mm-dd')
        INNER JOIN blade_shift_detail sd ON pdc.model_id = sd.model_id AND sd.shift_index = #{shift}
        WHERE w.is_deleted = 0
        AND pc.is_deleted = 0
        AND pdc.is_deleted = 0
        AND w.type = #{type}
        <if test="ids != null and ids.size() > 0">
            AND w.id IN
            <foreach collection="ids" item="id" open="(" separator="," close=")">
                #{id}
            </foreach>
        </if>
    </select>
 
 
    <select id="findByIndexAndDateAndTypeAndYear" resultType="java.lang.Long">
        SELECT distinct w.id
        FROM blade_workstation w
                 INNER JOIN blade_production_calendar pc ON w.calendar_code = pc.code AND pc.year = #{year}
                 INNER JOIN blade_production_calendar_day pdc
                            ON pc.id = pdc.calendar_id AND pdc.is_deleted = 0 AND pdc.calendar_date =TO_DATE(#{queryDate}, 'yyyy-mm-dd')
                 INNER JOIN blade_shift_detail sd ON pdc.model_id = sd.model_id AND sd.shift_index = #{shift}
        WHERE w.is_deleted = 0
          AND pc.is_deleted = 0
          AND pdc.is_deleted = 0
          AND w.type = #{type}
    </select>
 
 
 
 
    <select id="listWorkStationOnShift" resultType="com.qianwen.smartman.modules.smis.entity.Workstation">
        SELECT distinct w.*
        FROM blade_workstation w
        INNER JOIN blade_production_calendar pc ON w.calendar_code = pc.code AND pc.year = #{year}
        INNER JOIN blade_production_calendar_day pdc
        ON pc.id = pdc.calendar_id AND pdc.is_deleted = 0 AND pdc.calendar_date = TO_DATE(#{queryDate}, 'yyyy-mm-dd')
        INNER JOIN blade_shift_detail sd ON pdc.model_id = sd.model_id AND sd.shift_index IN
        <foreach collection="shifts" item="shift" open="(" separator="," close=")">
            #{shift}
        </foreach>
        WHERE w.is_deleted = 0
        AND pc.is_deleted = 0
        AND pdc.is_deleted = 0
        AND w.type = #{type}
        <if test="ids != null and ids.size() > 0">
            AND w.id IN
            <foreach collection="ids" item="id" open="(" separator="," close=")">
                #{id}
            </foreach>
        </if>
        order by w.code;
    </select>
 
    <select id="getDayShift" resultType="com.qianwen.smartman.modules.smis.entity.ProductionCalendarDay">
        select bpcd.*
        from blade_production_calendar_day bpcd
                 left join blade_production_calendar bpc on bpc.id = bpcd.calendar_id
        where bpcd.calendar_date =TO_DATE(#{calendarDate}, 'yyyy-mm-dd')
          and bpc.code = (select bw.calendar_code
                          from blade_workstation bw
                          where bw.id = #{workstationId})
    </select>
 
 
</mapper>