郑永安
2023-06-19 7a6abd05683528032687c75e80e0bd2030a3e46c
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
<?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.gkhy.safePlatform.safeCheck.repository.SafeCheckWorkRepository" >
    <resultMap id="BaseResultMap" type="com.gkhy.safePlatform.safeCheck.entity.SafeCheckWork" >
        <id column="id" property="id" />
        <result column="uuid" property="uuid"/>
        <result column="delete_status" property="deleteStatus" />
        <result column="work_type" property="workType" />
        <result column="work_status" property="workStatus"/>
        <result column="unit_id" property="unitId" />
        <result column="unit_uuid" property="unitUuid" />
        <result column="exec_classgroup_id" property="execClassgroupId" />
        <result column="exec_dep_id" property="execDepId" />
        <result column="check_cycle" property="checkCycle" />
        <result column="check_cycle_unit" property="checkCycleUnit" />
        <result column="notice_time" property="noticeTime" />
        <result column="notice_time_unit" property="noticeTimeUnit" />
        <result column="valid_time" property="validTime" />
        <result column="valid_time_unit" property="validTimeUnit" />
        <result column="next_notice_time" property="nextNoticeTime" />
        <result column="next_check_time" property="nextCheckTime" />
        <result column="last_check_time" property="lastCheckTime" />
        <result column="first_start_time" property="firstStartTime" />
    </resultMap>
 
    <sql id="allWorkFields">
        id,
        uuid,
        delete_status,
        work_type,
        work_status,
        unit_id,
        unit_uuid,
        exec_classgroup_id,
        exec_dep_id,
        check_cycle,
        check_cycle_unit,
        notice_time,
        notice_time_unit,
        valid_time,
        valid_time_unit,
        next_notice_time,
        next_check_time,
        last_check_time,
        first_start_time
    </sql>
    <select id="getWorkByTaskUnitId" resultMap="BaseResultMap">
        select
        <include refid="allWorkFields"></include>
        from safe_check_work
        where unit_id = #{taskUnitId} and delete_status = #{deleteStatus}
    </select>
 
 
    <select id="findActiveWorkListByTime" resultMap="BaseResultMap">
        select
        <include refid="allWorkFields"></include>
        from safe_check_work
        <where>
            delete_status = 0
            <if test="startTime != null">
                and next_notice_time >= #{startTime}
            </if>
            <if test="endTime != null">
                and next_notice_time &lt;= #{endTime}
            </if>
            <if test="status != null">
                and work_status = #{status}
            </if>
        </where>
    </select>
 
    <select id="getWorkById" resultType="com.gkhy.safePlatform.safeCheck.entity.SafeCheckWork">
        select
        <include refid="allWorkFields"></include>
        from safe_check_work
        <where>
            delete_status = 0
            <if test="workId != null">
                and id = #{workId}
            </if>
        </where>
    </select>
 
    <select id="findFaildScheduleList" resultType="com.gkhy.safePlatform.safeCheck.entity.SafeCheckWork">
        select
        <include refid="allWorkFields"></include>
        from safe_check_work
        <where>
            delete_status = 0
            <if test="nowTime != null">
                and next_notice_time &lt;= #{nowTime}
            </if>
                and work_status in (#{openStatus},#{dispatchingStatus})
        </where>
    </select>
 
    <select id="getWorkByIdAndWorkStatus" resultType="com.gkhy.safePlatform.safeCheck.entity.SafeCheckWork">
        select
        <include refid="allWorkFields"></include>
        from safe_check_work
        where id = #{workId} and work_status = #{status} and delete_status = 0
    </select>
 
 
    <update id="deleteWorkById">
        update safe_check_work set
            delete_status = #{work.deleteStatus}
        <where>
            id = #{work.id}
            <if test="workStatus != null and workStatus.size >0 ">
                <foreach collection="workStatus" open="and work_status in(" close=")" item="workStatus" separator=",">
                    #{workStatus}
                </foreach>
            </if>
        </where>
    </update>
 
 
    <update id="updateWorkStatusById">
        update safe_check_work set
            work_status = #{work.workStatus}
        where id = #{work.id} and delete_status = #{status}
    </update>
 
    <update id="updateWorkInfoById">
        update safe_check_work
        <set>
            <if test="work.workType != null">
                work_type = #{work.workType},
            </if>
            <if test="work.workStatus != null">
                work_status = #{work.workStatus},
            </if>
            <if test="work.execClassgroupId != null">
                exec_classgroup_id = #{work.execClassgroupId},
            </if>
            <if test="work.execDepId != null ">
                exec_dep_id = #{work.execDepId},
            </if>
            <if test="work.firstStartTime != null">
                first_start_time = #{work.firstStartTime},
            </if>
            <if test="work.nextNoticeTime != null">
                next_notice_time = #{work.nextNoticeTime},
            </if>
            <if test="work.nextCheckTime != null">
                next_check_time = #{work.nextCheckTime},
            </if>
            <if test="work.checkCycle != null">
                check_cycle = #{work.checkCycle},
            </if>
            <if test="work.checkCycleUnit != null">
                check_cycle_unit = #{work.checkCycleUnit},
            </if>
            <if test="work.noticeTime != null">
                notice_time = #{work.noticeTime},
            </if>
            <if test="work.noticeTimeUnit != null">
                notice_time_unit = #{work.noticeTimeUnit},
            </if>
            <if test="work.validTime != null">
                valid_time = #{work.validTime},
            </if>
            <if test="work.validTimeUnit != null">
                valid_time_unit = #{work.validTimeUnit},
            </if>
        </set>
        where id = #{work.id} and delete_status = #{status}
    </update>
 
    <update id="resetWorkStatus">
        update safe_check_work
        <set>
            <if test="work.nextNoticeTime != null">
                next_notice_time = #{work.nextNoticeTime},
            </if>
            <if test="work.nextCheckTime != null">
                next_check_time = #{work.nextCheckTime},
            </if>
            <if test="work.lastCheckTime != null">
                last_check_time = #{work.lastCheckTime},
            </if>
            <if test="newStatus != null">
                work_status = #{newStatus},
            </if>
        </set>
        where id = #{work.id} and delete_status = 0
    </update>
 
</mapper>