-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathJobInstanceMapper.xml
More file actions
113 lines (105 loc) · 4.48 KB
/
JobInstanceMapper.xml
File metadata and controls
113 lines (105 loc) · 4.48 KB
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
<?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.dinky.mapper.JobInstanceMapper">
<select id="getByIdWithoutTenant" resultType="org.dinky.data.model.job.JobInstance">
select *
from dinky_job_instance
where id = #{id}
limit 1
</select>
<select id="selectForProTable" resultType="org.dinky.data.vo.task.JobInstanceVo">
select
a.*,
dh.type as type,
(select dc.name FROM dinky_cluster dc where dc.id=a.cluster_id) as clusterName,
dt.first_level_owner,
dt.second_level_owners
from
dinky_job_instance a
<if test='!(param.isHistory!=null and param.isHistory==true)'>
inner join (
select max(ji.id) as id from dinky_job_instance ji
group by ji.task_id
) snap on snap.id = a.id
</if>
left join dinky_history dh on a.history_id = dh.id
left join dinky_task dt on a.task_id = dt.id
<where>
1=1
<if test='param.status!=null and param.status!=""'>
and a.status = #{param.status}
</if>
<if test='param.type!=null and param.type!=""'>
and dh.type = #{param.type}
</if>
<if test='param.taskId!=null and param.taskId!=""'>
and a.task_id = #{param.taskId}
</if>
<if test='param.step!=null and param.step!=""'>
and a.step = #{param.step}
</if>
<if test='param.name!=null and param.name!=""'>
and a.name like concat('%',#{param.name},'%')
</if>
<if test='param.jid!=null and param.jid!=""'>
and a.jid like concat('%',#{param.jid},'%')
</if>
<if test='param.createTime!=null and param.createTime!=""'>
and a.create_time <![CDATA[>=]]> str_to_date( #{param.createTime},'%Y-%m-%d %H:%i:%s')
and a.create_time <![CDATA[<=]]> str_to_date( #{param.createTime},'%Y-%m-%d %H:%i:%s')
</if>
<if test='param.updateTime!=null and param.updateTime!=""'>
and a.update_time <![CDATA[>=]]> str_to_date( #{param.updateTime[0]},'%Y-%m-%d %H:%i:%s')
and a.update_time <![CDATA[<=]]> str_to_date( #{param.updateTime[1]},'%Y-%m-%d %H:%i:%s')
</if>
<if test='ew.sqlSegment!=null and ew.sqlSegment!="" and !ew.sqlSegment.startsWith(" ORDER BY")'>
and
</if>
<if test='ew.sqlSegment!=null and ew.sqlSegment!=""'>
${ew.sqlSegment}
</if>
</where>
</select>
<select id="countStatus" resultType="org.dinky.data.model.home.JobInstanceCount">
select a.status,
count(1) as counts
from dinky_job_instance a
inner join (
select max(ji.id) as id
from dinky_job_instance ji
group by ji.task_id
) snap on snap.id = a.id
group by status
</select>
<select id="getJobStreamingOrBatchModelOverview" resultType="org.dinky.data.model.home.JobModelOverview">
select sum(case when b.batch then 1 else 0 end ) as batchJobCount,
sum(case when b.batch then 0 else 1 end ) as streamingJobCount
from (select batch_model as batch
from (select max(ji.id) as id from dinky_job_instance ji group by ji.task_id) as a
left join dinky_job_instance dji on dji.id = a.id
left join dinky_history dh on dji.history_id = dh.id) b
</select>
<select id="listJobInstanceActive" resultType="org.dinky.data.model.job.JobInstance">
select *
from dinky_job_instance
where status not in ('FAILED', 'CANCELED', 'FINISHED', 'UNKNOWN')
order by id desc
</select>
<select id="getJobInstanceByTaskId" resultType="org.dinky.data.model.job.JobInstance">
select *
from dinky_job_instance
where task_id = #{id}
order by id desc limit 1
</select>
<select id="getJobInstanceByTaskName" resultType="org.dinky.data.model.job.JobInstance">
select *
from dinky_job_instance
where name = #{taskName}
order by id desc limit 1
</select>
<select id="getTenantByJobInstanceId" resultType="java.lang.Integer">
select tenant_id
from dinky_job_instance
where id = #{id}
</select>
</mapper>