hyingbo
7 天以前 cc0e9036de6e922e8fe254fef01d8de9996024b7
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<?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="org.jeecg.modules.mdc.mapper.MdcDeviceCalendarMapper">
 
    <!--分页列表查询-->
    <select id="pageList" resultType="org.jeecg.modules.mdc.vo.MdcDeviceCalendarVo">
        SELECT
            t1.*,
            t2.shift_name,
            t3.shift_sub_name,
            t3.start_date,
            t3.end_date,
            t3.sleep_start_date,
            t3.sleep_end_date,
            t3.is_day_span,
            t4.equipment_name
        FROM
            mdc_device_calendar t1
            LEFT JOIN mdc_shift t2 ON t1.shift_id = t2.id
            LEFT JOIN mdc_shift_sub t3 ON t1.shift_sub_id = t3.id
            LEFT JOIN mdc_equipment t4 ON t1.equipment_id = t4.equipment_id
        WHERE 1=1
        <if test="deviceCalendar.effectiveDate != null and deviceCalendar.effectiveDate != ''">
            AND t1.effective_date LIKE CONCAT('%',#{ deviceCalendar.effectiveDate },'%')
        </if>
        <if test="deviceCalendar.equipmentId != null and deviceCalendar.equipmentId != ''">
            AND t1.equipment_id = #{ deviceCalendar.equipmentId }
        </if>
        <if test="deviceCalendar.startTime != null and deviceCalendar.startTime != ''">
            AND t1.effective_date &gt;= #{ deviceCalendar.startTime }
        </if>
        <if test="deviceCalendar.endTime != null and deviceCalendar.endTime != ''">
            AND t1.effective_date &lt;= #{ deviceCalendar.endTime }
        </if>
        <if test="deviceCalendar.equipmentIdList != null and deviceCalendar.equipmentIdList.size() > 0 ">
            AND t1.equipment_id IN
            <foreach collection="deviceCalendar.equipmentIdList" item="id" index="index" open="(" close=")" separator=",">
                #{ id }
            </foreach>
        </if>
        ORDER BY t4.equipment_name ASC, t1.EFFECTIVE_DATE ASC
    </select>
 
 
    <select id="listByEquipmentAndDate" resultType="org.jeecg.modules.mdc.vo.MdcDeviceCalendarVo">
        SELECT
            t1.*,
            t2.shift_name,
            t3.shift_sub_name,
            t3.start_date,
            t3.end_date,
            t3.sleep_start_date,
            t3.sleep_end_date,
            t3.is_day_span,
            t4.equipment_name
        FROM
            mdc_device_calendar t1
            LEFT JOIN mdc_shift t2 ON t1.shift_id = t2.id
            LEFT JOIN mdc_shift_sub t3 ON t1.shift_sub_id = t3.id
            LEFT JOIN mdc_equipment t4 ON t1.equipment_id = t4.equipment_id
        <where>
            <if test="equipmentId != null and equipmentId != ''">
                AND t4.equipment_id = #{ equipmentId }
            </if>
            <if test="stringDate != null and stringDate != ''">
                AND t1.effective_date = #{ stringDate }
            </if>
        </where>
    </select>
 
    <select id="findAcquiesceShift" resultType="org.jeecg.modules.mdc.vo.MdcDeviceCalendarVo">
        SELECT
            t1.id shiftId,
            t2.id shiftSubId,
            t1.shift_name shiftName,
            t2.shift_sub_name shiftSubName,
            t2.start_date startDate,
            t2.end_date endDate,
            t2.sleep_start_date sleepStartDate,
            t2.sleep_end_date sleepEndDate,
            t2.is_day_span isDaySpan
        FROM
            mdc_shift t1 LEFT JOIN mdc_shift_sub t2 ON t2.shift_id = t1.id
        WHERE t1.default_shift = 'true'
    </select>
 
    <!--计算实际班产天数-->
    <select id="computeActualWorkDayCount" resultType="java.lang.String">
        SELECT DISTINCT
            effective_date
        FROM
            mdc_device_calendar
        WHERE
            effective_date LIKE CONCAT(#{ validDate }, '%')
            AND equipment_id = #{ equipmentId }
    </select>
 
    <!--查询班次分类-->
    <select id="findShiftSort" resultType="java.lang.String">
        SELECT DISTINCT
            t2.shift_name
        FROM
            mdc_device_calendar t1 LEFT JOIN mdc_shift t2 ON t1.shift_id = t2.id
        WHERE
            t1.effective_date LIKE CONCAT(#{ validDate }, '%')
            AND t1.equipment_id = #{ equipmentId }
    </select>
 
    <!--查询班次数量-->
    <select id="computeShiftTimeCount" resultType="java.lang.Integer">
        SELECT
            COUNT(*)
        FROM
            mdc_device_calendar
        WHERE
            effective_date LIKE CONCAT(#{ validDate }, '%')
            AND equipment_id = #{ equipmentId }
    </select>
 
    <select id="getFirstData" resultType="org.jeecg.modules.mdc.entity.MdcDeviceCalendar">
        SELECT TOP 1 * FROM mdc_device_calendar WHERE equipment_id = #{ equipmentId } ORDER BY effective_date ASC
    </select>
 
    <select id="listByEquipmentAndDates" resultType="org.jeecg.modules.mdc.vo.MdcDeviceCalendarVo">
        SELECT
            t1.*,
            t2.shift_name,
            t3.shift_sub_name,
            t3.start_date,
            t3.end_date,
            t3.sleep_start_date,
            t3.sleep_end_date,
            t3.is_day_span,
            t4.equipment_name
        FROM
            mdc_device_calendar t1
            LEFT JOIN mdc_shift t2 ON t1.shift_id = t2.id
            LEFT JOIN mdc_shift_sub t3 ON t1.shift_sub_id = t3.id
            LEFT JOIN mdc_equipment t4 ON t1.equipment_id = t4.equipment_id
        <where>
            <if test="equipmentId != null and equipmentId != ''">
                AND t4.equipment_id = #{ equipmentId }
            </if>
            <if test="stringDates != null and stringDates.size() > 0 ">
                AND t1.effective_date IN
                <foreach collection="stringDates" item="stringDate" index="index" open="(" close=")" separator=",">
                    #{ stringDate }
                </foreach>
            </if>
        </where>
        ORDER BY
            t1.effective_date ASC
    </select>
 
</mapper>