|
@@ -5,84 +5,106 @@
|
5
|
5
|
<insert id="createNewLocItems">
|
6
|
6
|
INSERT INTO ta_check_item (item_id, check_id, item_type, type_id, `name`)
|
7
|
7
|
SELECT
|
8
|
|
- UUID_SHORT(),
|
9
|
|
- #{checkId},
|
10
|
|
- 'loc',
|
11
|
|
- t.type_id,
|
12
|
|
- t.`name`
|
|
8
|
+ UUID_SHORT(),
|
|
9
|
+ #{checkId},
|
|
10
|
+ 'loc',
|
|
11
|
+ t.type_id,
|
|
12
|
+ t.`name`
|
13
|
13
|
FROM
|
14
|
|
- td_loc_type t
|
|
14
|
+ td_loc_type t
|
15
|
15
|
WHERE
|
16
|
|
- t.`status` > -1
|
|
16
|
+ t.`status` > -1
|
17
|
17
|
ORDER BY
|
18
|
|
- t.sort_no ASC
|
|
18
|
+ t.sort_no ASC
|
19
|
19
|
</insert>
|
20
|
20
|
<insert id="copyItems">
|
21
|
21
|
insert into ta_check_item (
|
22
|
|
- `item_id`,
|
23
|
|
- `copy_from`,
|
24
|
|
- `check_id`,
|
25
|
|
- `item_type`,
|
26
|
|
- `type_id`,
|
27
|
|
- `name`,
|
28
|
|
- `full_score`,
|
29
|
|
- `num`,
|
30
|
|
- `status`,
|
31
|
|
- `create_date`
|
|
22
|
+ `item_id`,
|
|
23
|
+ `copy_from`,
|
|
24
|
+ `check_id`,
|
|
25
|
+ `item_type`,
|
|
26
|
+ `type_id`,
|
|
27
|
+ `name`,
|
|
28
|
+ `full_score`,
|
|
29
|
+ `num`,
|
|
30
|
+ `status`,
|
|
31
|
+ `create_date`
|
32
|
32
|
)
|
33
|
33
|
select
|
34
|
|
- UUID_SHORT(),
|
35
|
|
- t.`item_id`,
|
36
|
|
- #{newCheckId},
|
37
|
|
- t.`item_type`,
|
38
|
|
- t.`type_id`,
|
39
|
|
- t.`name`,
|
40
|
|
- t.`full_score`,
|
41
|
|
- t.`num`,
|
42
|
|
- 1,
|
43
|
|
- now()
|
|
34
|
+ UUID_SHORT(),
|
|
35
|
+ t.`item_id`,
|
|
36
|
+ #{newCheckId},
|
|
37
|
+ t.`item_type`,
|
|
38
|
+ t.`type_id`,
|
|
39
|
+ t.`name`,
|
|
40
|
+ t.`full_score`,
|
|
41
|
+ t.`num`,
|
|
42
|
+ 1,
|
|
43
|
+ now()
|
44
|
44
|
from ta_check_item t
|
45
|
45
|
WHERE t.check_id = #{oldCheckId}
|
46
|
|
- and t.`status` = 1
|
|
46
|
+ and t.`status` = 1
|
47
|
47
|
</insert>
|
|
48
|
+
|
|
49
|
+ <insert id="syncLoc">
|
|
50
|
+ INSERT INTO ta_check_item(`item_id`,`type_id`,`name`,`create_date`,
|
|
51
|
+ `status`,`num`,`full_score`,`item_type`,`copy_from`,`check_id`)
|
|
52
|
+ SELECT
|
|
53
|
+ UUID_SHORT(), s.type_id ,s.name,now(),1,null,null,'loc',null, #{checkId}
|
|
54
|
+ FROM
|
|
55
|
+ td_loc_type s
|
|
56
|
+ WHERE
|
|
57
|
+ s.`status` = 1 AND
|
|
58
|
+ s.type_id NOT IN ( SELECT t.type_id FROM ta_check_item t WHERE t.`status` = 1 AND t.check_id = #{checkId}
|
|
59
|
+ AND t.item_type = "loc" )
|
|
60
|
+ </insert>
|
|
61
|
+
|
|
62
|
+ <update id="updateLoc">
|
|
63
|
+ UPDATE ta_check_item c inner join td_loc_type l ON c.type_id = l.type_id
|
|
64
|
+ SET c.status = l.status
|
|
65
|
+ WHERE c.check_id = #{checkId}
|
|
66
|
+ </update>
|
|
67
|
+
|
48
|
68
|
<update id="updateFullScore">
|
49
|
69
|
UPDATE ta_check_item t
|
50
|
70
|
SET t.full_score = ( SELECT sum( s.max_score ) FROM ta_check_item_qu s WHERE s.item_id = #{itemId} )
|
51
|
71
|
WHERE
|
52
|
|
- t.item_id = #{itemId}
|
|
72
|
+ t.item_id = #{itemId}
|
53
|
73
|
</update>
|
54
|
74
|
<update id="calcScore">
|
55
|
75
|
UPDATE ta_check_item t
|
56
|
76
|
SET t.score = ( SELECT sum( s.score ) FROM ta_check_answer s WHERE s.item_id = t.item_id )
|
57
|
77
|
WHERE
|
58
|
|
- t.check_id = #{checkId}
|
|
78
|
+ t.check_id = #{checkId}
|
59
|
79
|
</update>
|
60
|
80
|
|
|
81
|
+
|
|
82
|
+
|
61
|
83
|
<select id="getPageBy" resultType="com.example.civilizedcity.entity.TaCheckItem">
|
62
|
84
|
SELECT
|
63
|
|
- IFNULL(m.num, 0) as answer_num,
|
64
|
|
- t.*
|
|
85
|
+ IFNULL(m.num, 0) as answer_num,
|
|
86
|
+ t.*
|
65
|
87
|
FROM
|
66
|
|
- ta_check_item t
|
67
|
|
- INNER JOIN ta_check c ON c.check_id = t.check_id
|
68
|
|
- <if test="itemType != null and itemType == 'loc'">
|
69
|
|
- INNER JOIN td_loc_type s ON t.type_id = s.type_id
|
70
|
|
- </if>
|
71
|
|
- LEFT JOIN (
|
72
|
|
- SELECT
|
73
|
|
- a.item_id,
|
74
|
|
- COUNT( * ) AS num
|
75
|
|
- FROM
|
76
|
|
- ta_check_answer a
|
77
|
|
- WHERE
|
78
|
|
- a.check_id = #{checkId}
|
79
|
|
- GROUP BY
|
80
|
|
- a.item_id
|
81
|
|
- ) m ON m.item_id = t.item_id
|
|
88
|
+ ta_check_item t
|
|
89
|
+ INNER JOIN ta_check c ON c.check_id = t.check_id
|
|
90
|
+ <if test="itemType != null and itemType == 'loc'">
|
|
91
|
+ INNER JOIN td_loc_type s ON t.type_id = s.type_id
|
|
92
|
+ </if>
|
|
93
|
+ LEFT JOIN (
|
|
94
|
+ SELECT
|
|
95
|
+ a.item_id,
|
|
96
|
+ COUNT( * ) AS num
|
|
97
|
+ FROM
|
|
98
|
+ ta_check_answer a
|
|
99
|
+ WHERE
|
|
100
|
+ a.check_id = #{checkId}
|
|
101
|
+ GROUP BY
|
|
102
|
+ a.item_id
|
|
103
|
+ ) m ON m.item_id = t.item_id
|
82
|
104
|
WHERE
|
83
|
|
- t.check_id = #{checkId}
|
84
|
|
- AND t.item_type = #{itemType}
|
85
|
|
- AND t.`status` > -1
|
|
105
|
+ t.check_id = #{checkId}
|
|
106
|
+ AND t.item_type = #{itemType}
|
|
107
|
+ AND t.`status` > -1
|
86
|
108
|
ORDER BY
|
87
|
109
|
<if test="itemType != null and itemType == 'loc'">
|
88
|
110
|
s.sort_no ASC
|
|
@@ -93,53 +115,55 @@
|
93
|
115
|
</select>
|
94
|
116
|
<select id="getListBy" resultType="com.example.civilizedcity.entity.TaCheckItem">
|
95
|
117
|
SELECT
|
96
|
|
- t.*
|
|
118
|
+ t.*
|
97
|
119
|
FROM
|
98
|
|
- ta_check_item t
|
|
120
|
+ ta_check_item t
|
99
|
121
|
WHERE
|
100
|
|
- t.check_id = #{checkId}
|
101
|
|
- AND t.item_type = #{itemType}
|
102
|
|
- AND t.`status` > -1
|
|
122
|
+ t.check_id = #{checkId}
|
|
123
|
+ AND t.item_type = #{itemType}
|
|
124
|
+ AND t.`status` > -1
|
103
|
125
|
</select>
|
104
|
126
|
<select id="sumEvlScore" resultType="java.lang.Double">
|
105
|
127
|
SELECT
|
106
|
128
|
IF (
|
107
|
|
- sum( m.cnt ) IS NULL OR sum( m.cnt ) = 0 , 0 , SUM( t.score ) / SUM( m.cnt )
|
108
|
|
- ) as score
|
|
129
|
+ sum( m.cnt ) IS NULL OR sum( m.cnt ) = 0 , 0 , SUM( t.score ) / SUM( m.cnt )
|
|
130
|
+ ) as score
|
109
|
131
|
FROM
|
110
|
132
|
ta_check_item t
|
111
|
|
- LEFT JOIN (
|
112
|
|
- SELECT
|
113
|
|
- s.item_id,
|
114
|
|
- count(*) AS cnt
|
115
|
|
- FROM
|
116
|
|
- ta_check_answer s
|
117
|
|
- WHERE
|
118
|
|
- s.item_id = #{itemId}
|
119
|
|
- ) m ON t.item_id = m.item_id
|
|
133
|
+ LEFT JOIN (
|
|
134
|
+ SELECT
|
|
135
|
+ s.item_id,
|
|
136
|
+ count(*) AS cnt
|
|
137
|
+ FROM
|
|
138
|
+ ta_check_answer s
|
|
139
|
+ WHERE
|
|
140
|
+ s.item_id = #{itemId}
|
|
141
|
+ ) m ON t.item_id = m.item_id
|
120
|
142
|
WHERE t.item_id = #{itemId};
|
121
|
143
|
</select>
|
122
|
144
|
<select id="sumScore" resultType="java.lang.Double">
|
123
|
145
|
SELECT
|
124
|
|
- SUM( t.score )
|
|
146
|
+ SUM( t.score )
|
125
|
147
|
FROM
|
126
|
|
- ta_check_item t
|
|
148
|
+ ta_check_item t
|
127
|
149
|
WHERE
|
128
|
|
- t.check_id = #{checkId}
|
129
|
|
- AND t.item_type = #{itemType}
|
130
|
|
- AND t.`status` > - 1;
|
131
|
|
-</select>
|
|
150
|
+ t.check_id = #{checkId}
|
|
151
|
+ AND t.item_type = #{itemType}
|
|
152
|
+ AND t.`status` > - 1;
|
|
153
|
+ </select>
|
132
|
154
|
<select id="getExportByCheck" resultType="com.example.civilizedcity.vo.CheckLocExport">
|
133
|
155
|
|
134
|
156
|
SELECT
|
135
|
|
- t.*,
|
136
|
|
- t.full_score * t.num AS subtotal
|
|
157
|
+ t.*,
|
|
158
|
+ t.full_score * t.num AS subtotal
|
137
|
159
|
FROM
|
138
|
|
- ta_check_item t
|
|
160
|
+ ta_check_item t
|
139
|
161
|
WHERE
|
140
|
|
- t.check_id = #{checkId}
|
141
|
|
- AND t.item_type = #{itemType}
|
142
|
|
- AND t.`status` > -1
|
|
162
|
+ t.check_id = #{checkId}
|
|
163
|
+ AND t.item_type = #{itemType}
|
|
164
|
+ AND t.`status` > -1
|
143
|
165
|
</select>
|
144
|
166
|
|
|
167
|
+
|
|
168
|
+
|
145
|
169
|
</mapper>
|