mitao
2025-02-21 31573d6180d15ef65ed0df9c2732495f40b12663
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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
<?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.panzhihua.service_community.dao.ComActReserveAnswerContentMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.panzhihua.service_community.model.dos.ComActReserveAnswerContentDO">
        <id column="id" property="id"/>
        <result column="reserve_sub_id" property="reserveSubId"/>
        <result column="reserve_selection_id" property="reserveSelectionId"/>
        <result column="user_id" property="userId"/>
        <result column="type" property="type"/>
        <result column="choice" property="choice"/>
        <result column="answer_content" property="answerContent"/>
        <result column="create_by" property="createBy"/>
        <result column="create_at" property="createAt"/>
        <result column="update_by" property="updateBy"/>
        <result column="update_at" property="updateAt"/>
        <result column="reserve_record_id" property="reserveRecordId"/>
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, reserve_sub_id, reserve_selection_id, user_id, type, choice, answer_content, create_by, create_at, update_by, update_at, reserve_record_id
    </sql>
 
    <select id="selectListByReserve" resultType="com.panzhihua.common.model.vos.community.ComActQuestnaireAnswerContentVO">
        SELECT
            qs.type as optionType,ac.*,su.nick_name,carr.create_at as `time`
        FROM
            com_act_reserve_answer_content ac
            LEFT JOIN com_act_reserve_sub qs ON ac.reserve_sub_id = qs.id
            LEFT JOIN com_act_reserve qn ON qs.reserve_id = qn.id
            LEFT JOIN sys_user su ON ac.user_id = su.user_id
            LEFT JOIN com_act_reserve_record carr ON carr.id = ac.reserve_record_id
        WHERE
            qn.id = #{reserveId}
            order by ac.reserve_record_id asc,ac.id asc
    </select>
 
    <select id="pageRegisterDetailedListAdmin" parameterType="com.panzhihua.common.model.dtos.community.reserve.PageReserveRegisterDetailedAdminDTO"
            resultType="com.panzhihua.common.model.vos.community.reserve.ComActReserveRegisterDetailedVO">
        SELECT
            carr.id,
            su.nick_name,
            carr.create_at
        FROM
            com_act_reserve_record AS carr
            LEFT JOIN sys_user AS su ON su.user_id = carr.user_id
            left join com_act_reserve_answer_content carac on carr.id=carac.reserve_record_id
        WHERE
            reserve_id = #{detailedAdminDTO.reserveId}
            <if test='detailedAdminDTO.startTime != null and detailedAdminDTO.startTime != &quot;&quot;'>
                AND carr.create_at <![CDATA[ >= ]]> #{detailedAdminDTO.startTime}
            </if>
            <if test='detailedAdminDTO.endTime != null and detailedAdminDTO.endTime != &quot;&quot;'>
                AND carr.create_at <![CDATA[ <= ]]> #{detailedAdminDTO.endTime}
            </if>
            <if test='detailedAdminDTO.beginTime != null and detailedAdminDTO.beginTime != &quot;&quot;'>
                AND STR_TO_DATE(carac.answer_content,'%Y-%m-%d %H:%i:%s') <![CDATA[ >= ]]> #{detailedAdminDTO.beginTime}
            </if>
            <if test='detailedAdminDTO.stopTime != null and detailedAdminDTO.stopTime != &quot;&quot;'>
                AND STR_TO_DATE(carac.answer_content,'%Y-%m-%d %H:%i:%s') <![CDATA[ <= ]]> #{detailedAdminDTO.stopTime}
            </if>
        <if test="detailedAdminDTO.keyword!=null and detailedAdminDTO.keyword != &quot;&quot;">
            AND carr.json_object like concat ('%',#{detailedAdminDTO.keyword},'%')
        </if>
        <if test="detailedAdminDTO.area!=null and detailedAdminDTO.area != &quot;&quot;">
            AND JSON_EXTRACT(json_object, '$[6].values') like concat ('%',#{detailedAdminDTO.area},'%')
        </if>
        <if test="detailedAdminDTO.from!=null and detailedAdminDTO.from != &quot;&quot;">
            AND JSON_EXTRACT(json_object, '$[3].values') like concat ('%',#{detailedAdminDTO.from},'%')
        </if>
        group by carr.id order by carr.id desc
    </select>
 
    <select id="pageRegisterDetailedListAdminExport" parameterType="com.panzhihua.common.model.dtos.community.reserve.PageReserveRegisterDetailedAdminDTO"
            resultType="com.panzhihua.common.model.vos.community.reserve.ComActReserveRegisterDetailedVO">
        SELECT
        carr.id,
        su.nick_name,
        carr.create_at
        FROM
        com_act_reserve_record AS carr
        LEFT JOIN sys_user AS su ON su.user_id = carr.user_id
        left join com_act_reserve_answer_content carac on carr.id=carac.reserve_record_id
        WHERE
        reserve_id = #{detailedAdminDTO.reserveId}
        <if test='detailedAdminDTO.startTime != null and detailedAdminDTO.startTime != &quot;&quot;'>
            AND carr.create_at <![CDATA[ >= ]]> #{detailedAdminDTO.startTime}
        </if>
        <if test='detailedAdminDTO.endTime != null and detailedAdminDTO.endTime != &quot;&quot;'>
            AND carr.create_at <![CDATA[ <= ]]> #{detailedAdminDTO.endTime}
        </if>
        <if test='detailedAdminDTO.beginTime != null and detailedAdminDTO.beginTime != &quot;&quot;'>
            AND STR_TO_DATE(carac.answer_content,'%Y-%m-%d %H:%i:%s') <![CDATA[ >= ]]> #{detailedAdminDTO.beginTime}
        </if>
        <if test='detailedAdminDTO.stopTime != null and detailedAdminDTO.stopTime != &quot;&quot;'>
            AND STR_TO_DATE(carac.answer_content,'%Y-%m-%d %H:%i:%s') <![CDATA[ <= ]]> #{detailedAdminDTO.stopTime}
        </if>
        <if test="detailedAdminDTO.keyword!=null and detailedAdminDTO.keyword != &quot;&quot;">
            AND carr.json_object like concat ('%',#{detailedAdminDTO.keyword},'%')
        </if>
        <if test="detailedAdminDTO.area!=null and detailedAdminDTO.area != &quot;&quot;">
            AND carr.json_object like concat ('%',#{detailedAdminDTO.area},'%')
        </if>
        group by carr.id order by carr.id desc
    </select>
 
    <select id="getRegisterDetailedAnswerList" resultType="com.panzhihua.common.model.vos.community.reserve.ComActReserveRegisterDetailedAnswerVO">
        SELECT
            car.content as reserveSubContent, carac.answer_content as answerContent,carac.reserve_sub_id as reserveSubId,car.`type`
        FROM
            com_act_reserve_answer_content AS carac
            LEFT JOIN com_act_reserve_sub AS car ON car.id = carac.reserve_sub_id
        where carac.reserve_record_id = #{reserveRecordId} order by carac.id asc
    </select>
 
    <select id="getRegisterDetailedById" resultType="com.panzhihua.common.model.vos.community.reserve.ComActReserveRegisterDetailedVO">
        SELECT
            carr.id,
            su.nick_name,
            carr.create_at
        FROM
            com_act_reserve_record AS carr
            LEFT JOIN sys_user AS su ON su.user_id = carr.user_id
            where carr.id = #{reserveRecordId}
    </select>
 
    <select id="export" resultType="com.panzhihua.common.model.vos.community.ComActQuestnaireAnswerContentVO">
        select ac.*,ac.create_at as time,u.nick_name,cars.type as optionType from com_act_reserve_record carr
        left join com_act_reserve_answer_content ac on ac.reserve_record_id = carr.id
        left join sys_user u on carr.user_id = u.user_id
        left join com_act_reserve_sub cars on ac.reserve_sub_id = cars.id
        where carr.reserve_id = #{detailedAdminDTO.reserveId} and ac.reserve_record_id in ( SELECT DISTINCT
        carr.id
        FROM
        com_act_reserve_record carr
        LEFT JOIN com_act_reserve_answer_content ac ON carr.id = ac.reserve_record_id
        WHERE
        carr.reserve_id =#{detailedAdminDTO.reserveId}
        <if test='detailedAdminDTO.startTime != null and detailedAdminDTO.startTime != &quot;&quot;'>
            AND carr.create_at <![CDATA[ >= ]]> #{detailedAdminDTO.startTime}
        </if>
        <if test='detailedAdminDTO.endTime != null and detailedAdminDTO.endTime != &quot;&quot;'>
            AND carr.create_at <![CDATA[ <= ]]> #{detailedAdminDTO.endTime}
        </if>
        <if test='detailedAdminDTO.beginTime != null and detailedAdminDTO.beginTime != &quot;&quot;'>
            AND STR_TO_DATE(ac.answer_content,'%Y-%m-%d %H:%i:%s') <![CDATA[ >= ]]> #{detailedAdminDTO.beginTime}
        </if>
        <if test='detailedAdminDTO.stopTime != null and detailedAdminDTO.stopTime != &quot;&quot;'>
            AND STR_TO_DATE(ac.answer_content,'%Y-%m-%d %H:%i:%s') <![CDATA[ <= ]]> #{detailedAdminDTO.stopTime}
        </if>
        <if test="detailedAdminDTO.keyword!=null and detailedAdminDTO.keyword != &quot;&quot;">
            AND carr.json_object like concat ('%',#{detailedAdminDTO.keyword},'%')
        </if>
        <if test="detailedAdminDTO.area!=null and detailedAdminDTO.area != &quot;&quot;">
            AND JSON_EXTRACT(json_object, '$[6].values') like concat ('%',#{detailedAdminDTO.area},'%')
        </if>
        <if test="detailedAdminDTO.from!=null and detailedAdminDTO.from != &quot;&quot;">
            AND JSON_EXTRACT(json_object, '$[3].values') like concat ('%',#{detailedAdminDTO.from},'%')
        </if>
        )
        order by ac.reserve_record_id DESC,ac.id ASC
    </select>
    <select id="pageRegisterHomeQuarantine" resultType="java.lang.String">
        SELECT answer_content FROM (
        SELECT carr.id, carac.answer_content
        FROM com_act_reserve_record AS carr
        LEFT JOIN com_act_reserve_answer_content carac ON carr.id=carac.reserve_record_id
        LEFT JOIN com_act_reserve_sub t ON carac.reserve_sub_id = t.id
        WHERE carr.reserve_id = #{detailedAdminDTO.reserveId} AND t.content LIKE '身份证%'
        <if test="detailedAdminDTO.keyword!=null and detailedAdminDTO.keyword != &quot;&quot;">
            AND carac.answer_content LIKE CONCAT (#{detailedAdminDTO.keyword},'%')
        </if>
        ORDER BY carr.id ASC LIMIT 9999999) temp
        WHERE 1=1
        <if test='detailedAdminDTO.startTime != null and detailedAdminDTO.startTime != &quot;&quot;'>
            AND temp.create_at <![CDATA[ >= ]]> #{detailedAdminDTO.startTime}
        </if>
        <if test='detailedAdminDTO.endTime != null and detailedAdminDTO.endTime != &quot;&quot;'>
            AND temp.create_at <![CDATA[ <= ]]> #{detailedAdminDTO.endTime}
        </if>
        GROUP BY answer_content ORDER BY id DESC
    </select>
    <select id="selectStatistics"
            resultType="com.panzhihua.common.model.vos.community.reserve.HomeQuarantineRegisterStatisticsVO">
        SELECT carr.id, carr.create_at, su.nick_name, carac.reserve_record_id, car.content AS reserveSubContent,
        carac.answer_content AS answerContent, carac.reserve_sub_id AS reserveSubId, car.`type` AS optionType
        FROM com_act_reserve_record AS carr
        LEFT JOIN com_act_reserve_answer_content carac ON carr.id=carac.reserve_record_id
        LEFT JOIN com_act_reserve_sub AS car ON carac.reserve_sub_id = car.id
        LEFT JOIN sys_user su ON carr.user_id = su.user_id
        WHERE carr.id IN (
            SELECT t1.reserve_record_id FROM com_act_reserve_answer_content t1
            LEFT JOIN com_act_reserve_record t2 ON t1.reserve_record_id = t2.id
            WHERE t2.reserve_id = #{reserveId} AND t1.answer_content = #{record}
        ) ORDER BY carr.id ASC
    </select>
    <select id="exportHomeQuarantine" resultType="java.lang.String">
        SELECT answer_content FROM (
        SELECT carr.id, carac.answer_content
        FROM com_act_reserve_record AS carr
        LEFT JOIN com_act_reserve_answer_content carac ON carr.id=carac.reserve_record_id
        LEFT JOIN com_act_reserve_sub t ON carac.reserve_sub_id = t.id
        WHERE carr.reserve_id = #{detailedAdminDTO.reserveId} AND t.content LIKE '身份证%'
        <if test="detailedAdminDTO.keyword!=null and detailedAdminDTO.keyword != &quot;&quot;">
            AND carac.answer_content LIKE CONCAT (#{detailedAdminDTO.keyword},'%')
        </if>
        ORDER BY carr.id ASC LIMIT 9999999) temp
        WHERE 1=1
        <if test='detailedAdminDTO.startTime != null and detailedAdminDTO.startTime != &quot;&quot;'>
            AND temp.create_at <![CDATA[ >= ]]> #{detailedAdminDTO.startTime}
        </if>
        <if test='detailedAdminDTO.endTime != null and detailedAdminDTO.endTime != &quot;&quot;'>
            AND temp.create_at <![CDATA[ <= ]]> #{detailedAdminDTO.endTime}
        </if>
        GROUP BY answer_content ORDER BY id DESC
    </select>
 
    <select id="fiveCount" resultType="com.panzhihua.common.model.vos.community.reserve.FiveCount">
        select (
                   select count(*) from   com_act_reserve_record where reserve_id = #{reserveId}
                                                                   and  JSON_EXTRACT(json_object, '$[9].values') = 0
 
               ) redMark,(
                   select count(*) from   com_act_reserve_record where reserve_id = #{reserveId}
                                                                   and  JSON_EXTRACT(json_object, '$[9].values') = 1
               ) yellowMark,(
                   select count(*) from   com_act_reserve_record where reserve_id = #{reserveId}
                                                                   and  JSON_EXTRACT(json_object, '$[9].values') = 2
               ) greenMark,(select count(*) from   com_act_reserve_record where reserve_id = #{reserveId}
                                                                            and  JSON_EXTRACT(json_object, '$[10].values') = 0  ) dangerCount,
               ( select count(*) from   com_act_reserve_record where reserve_id = #{reserveId}) allCount
    </select>
</mapper>