陈昶聿
8 天以前 608bdb9e55b95e9d4052f8c57ac4d92c9ecde5c3
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
192
193
194
195
196
197
198
199
200
<?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.smartor.mapper.ServiceTaskScheduleMapper">
 
    <resultMap type="com.smartor.domain.ServiceTaskSchedule" id="ServiceTaskScheduleResult">
        <id property="id" column="id"/>
        <result property="taskid" column="taskid"/>
        <result property="maxLoopCount" column="max_loop_count"/>
        <result property="currentLoopCount" column="current_loop_count"/>
        <result property="currentSeq" column="current_seq"/>
        <result property="nextSeq" column="next_seq"/>
        <result property="scheduleStyle" column="schedule_style"/>
        <result property="scheduleTimeNum" column="schedule_time_num"/>
        <result property="scheduleTimeUnit" column="schedule_time_unit"/>
        <result property="nextExecuteTime" column="next_execute_time"/>
        <result property="scheduleBenchmark" column="schedule_benchmark"/>
        <result property="scheduleBenchmarkCustomTime" column="schedule_benchmark_custom_time"/>
        <result property="deptCodes" column="dept_codes"/>
        <result property="wardCodes" column="ward_codes"/>
        <result property="icd10Codes" column="icd10_codes"/>
        <result property="oplevelCodes" column="oplevel_codes"/>
        <result property="remark" column="remark"/>
        <result property="delFlag" column="del_flag"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="orgid" column="orgid"/>
        <result property="campusid" column="campusid"/>
    </resultMap>
 
    <sql id="selectServiceTaskScheduleVo">
        select id,
               taskid,
               max_loop_count,
               current_loop_count,
               current_seq,
               next_seq,
               schedule_style,
               schedule_time_num,
               schedule_time_unit,
               next_execute_time,
               schedule_benchmark,
               schedule_benchmark_custom_time,
               dept_codes,
               ward_codes,
               icd10_codes,
               oplevel_codes,
               remark,
               del_flag,
               create_by,
               create_time,
               update_by,
               update_time,
               orgid,
               campusid
        from service_task_schedule
    </sql>
 
    <select id="selectServiceTaskScheduleById" parameterType="Long" resultMap="ServiceTaskScheduleResult">
        <include refid="selectServiceTaskScheduleVo"/>
        where id = #{id} and del_flag = '0'
    </select>
 
    <select id="selectByTaskid" resultMap="ServiceTaskScheduleResult">
        <include refid="selectServiceTaskScheduleVo"/>
        where taskid = #{taskid} and del_flag = '0'
        order by id desc
        limit 1
    </select>
 
    <select id="selectServiceTaskScheduleList" parameterType="com.smartor.domain.ServiceTaskSchedule"
            resultMap="ServiceTaskScheduleResult">
        <include refid="selectServiceTaskScheduleVo"/>
        where del_flag = '0'
        <if test="taskid != null">and taskid = #{taskid}</if>
        <if test="scheduleStyle != null">and schedule_style = #{scheduleStyle}</if>
        <if test="deptCode != null">and INSTR(dept_codes,  #{deptCode}) > 0</if>
        <if test="wardCode != null">and INSTR(ward_codes,  #{wardCode}) > 0</if>
        <if test="icd10Code != null">and INSTR(icd10_codes,  #{icd10Code}) > 0</if>
        <if test="oplevelCode != null">and INSTR(oplevel_codes,  #{oplevelCode}) > 0</if>
        <if test="orgid != null and orgid != ''">and orgid = #{orgid}</if>
        <if test="campusid != null and campusid != ''">and campusid = #{campusid}</if>
        order by id desc
    </select>
 
    <insert id="insertServiceTaskSchedule" parameterType="com.smartor.domain.ServiceTaskSchedule"
            useGeneratedKeys="true" keyProperty="id">
        insert into service_task_schedule
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="taskid != null">taskid,</if>
            <if test="maxLoopCount != null">max_loop_count,</if>
            <if test="currentLoopCount != null">current_loop_count,</if>
            <if test="currentSeq != null">current_seq,</if>
            <if test="nextSeq != null">next_seq,</if>
            <if test="scheduleStyle != null">schedule_style,</if>
            <if test="scheduleTimeNum != null">schedule_time_num,</if>
            <if test="scheduleTimeUnit != null">schedule_time_unit,</if>
            <if test="nextExecuteTime != null">next_execute_time,</if>
            <if test="scheduleBenchmark != null">schedule_benchmark,</if>
            <if test="scheduleBenchmarkCustomTime != null">schedule_benchmark_custom_time,</if>
            <if test="deptCodes != null">dept_codes,</if>
            <if test="wardCodes != null">ward_codes,</if>
            <if test="icd10Codes != null">icd10_codes,</if>
            <if test="oplevelCodes != null">oplevel_codes,</if>
            <if test="remark != null">remark,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="orgid != null">orgid,</if>
            <if test="campusid != null">campusid,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="taskid != null">#{taskid},</if>
            <if test="maxLoopCount != null">#{maxLoopCount},</if>
            <if test="currentLoopCount != null">#{currentLoopCount},</if>
            <if test="currentSeq != null">#{currentSeq},</if>
            <if test="nextSeq != null">#{nextSeq},</if>
            <if test="scheduleStyle != null">#{scheduleStyle},</if>
            <if test="scheduleTimeNum != null">#{scheduleTimeNum},</if>
            <if test="scheduleTimeUnit != null">#{scheduleTimeUnit},</if>
            <if test="nextExecuteTime != null">#{nextExecuteTime},</if>
            <if test="scheduleBenchmark != null">#{scheduleBenchmark},</if>
            <if test="scheduleBenchmarkCustomTime != null">#{scheduleBenchmarkCustomTime},</if>
            <if test="deptCodes != null">#{deptCodes},</if>
            <if test="wardCodes != null">#{wardCodes},</if>
            <if test="icd10Codes != null">#{icd10Codes},</if>
            <if test="oplevelCodes != null">#{oplevelCodes},</if>
            <if test="remark != null">#{remark},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="orgid != null">#{orgid},</if>
            <if test="campusid != null">#{campusid},</if>
        </trim>
    </insert>
 
    <update id="updateServiceTaskSchedule" parameterType="com.smartor.domain.ServiceTaskSchedule">
        update service_task_schedule
        <trim prefix="SET" suffixOverrides=",">
            <if test="taskid != null">taskid = #{taskid},</if>
            <if test="maxLoopCount != null">max_loop_count = #{maxLoopCount},</if>
            <if test="currentLoopCount != null">current_loop_count = #{currentLoopCount},</if>
            <if test="currentSeq != null">current_seq = #{currentSeq},</if>
            <if test="nextSeq != null">next_seq = #{nextSeq},</if>
            <if test="scheduleStyle != null">schedule_style = #{scheduleStyle},</if>
            <if test="scheduleTimeNum != null">schedule_time_num = #{scheduleTimeNum},</if>
            <if test="scheduleTimeUnit != null">schedule_time_unit = #{scheduleTimeUnit},</if>
            <if test="nextExecuteTime != null">next_execute_time = #{nextExecuteTime},</if>
            <if test="scheduleBenchmark != null">schedule_benchmark = #{scheduleBenchmark},</if>
            <if test="scheduleBenchmarkCustomTime != null">
                schedule_benchmark_custom_time = #{scheduleBenchmarkCustomTime},
            </if>
            <if test="deptCodes != null">dept_codes = #{deptCodes},</if>
            <if test="wardCodes != null">ward_codes = #{wardCodes},</if>
            <if test="icd10Codes != null">icd10_codes = #{icd10Codes},</if>
            <if test="oplevelCodes != null">oplevel_codes = #{oplevelCodes},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="orgid != null">orgid = #{orgid},</if>
            <if test="campusid != null">campusid = #{campusid},</if>
        </trim>
        where id = #{id}
    </update>
 
    <update id="deleteServiceTaskScheduleById" parameterType="Long">
        update service_task_schedule
        set del_flag = '1',
            update_time = now()
        where id = #{id}
    </update>
 
    <update id="deleteByTaskid">
        update service_task_schedule
        set del_flag = '1',
            update_time = now()
        where taskid = #{taskid}
          and del_flag = '0'
    </update>
 
    <select id="selectActiveCycleSchedules" resultMap="ServiceTaskScheduleResult">
        <include refid="selectServiceTaskScheduleVo"/>
        where del_flag = '0'
          and schedule_style = 1
          and (max_loop_count is null
                or max_loop_count = 0
                or current_loop_count &lt; max_loop_count)
        order by id asc
        limit #{limit}
    </select>
 
</mapper>