feiyu02
2024-11-21 9de446b0b83610055437fbc5172d216bb374900f
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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
<?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="cn.flightfeather.supervision.domain.ds1.mapper.ProblemlistMapper">
    <resultMap id="BaseResultMap" type="cn.flightfeather.supervision.domain.ds1.entity.Problemlist">
        <!--
          WARNING - @mbg.generated
        -->
        <id column="PL_GUID" property="guid" jdbcType="VARCHAR"/>
        <result column="I_GUID" property="iguid" jdbcType="VARCHAR"/>
        <result column="ST_GUID" property="stguid" jdbcType="VARCHAR"/>
        <result column="S_GUID" property="sguid" jdbcType="VARCHAR"/>
        <result column="PL_SenseName" property="sensename" jdbcType="VARCHAR"/>
        <result column="PL_SenseAddress" property="senseaddress" jdbcType="VARCHAR"/>
        <result column="PT_GUID" property="ptguid" jdbcType="VARCHAR"/>
        <result column="PL_ProblemName" property="problemname" jdbcType="VARCHAR"/>
        <result column="PL_Longitude" property="longitude" jdbcType="DECIMAL"/>
        <result column="PL_Latitude" property="latitude" jdbcType="DECIMAL"/>
        <result column="PL_LocationID" property="locationid" jdbcType="TINYINT"/>
        <result column="PL_Location" property="location" jdbcType="VARCHAR"/>
        <result column="PL_Time" property="time" jdbcType="TIMESTAMP"/>
        <result column="PL_IsRechecked" property="isrechecked" jdbcType="BIT"/>
        <result column="PL_RecheckTime" property="rechecktime" jdbcType="TIMESTAMP"/>
        <result column="PL_RecheckUserGUID" property="recheckuserguid" jdbcType="VARCHAR"/>
        <result column="PL_RecheckUserName" property="recheckusername" jdbcType="VARCHAR"/>
        <result column="PL_RecheckUserRealName" property="recheckuserrealname" jdbcType="VARCHAR"/>
        <result column="PL_RecheckDescription" property="recheckdescription" jdbcType="VARCHAR"/>
        <result column="PL_RecheckResultID" property="recheckresultid" jdbcType="BIT"/>
        <result column="PL_RecheckResult" property="recheckresult" jdbcType="VARCHAR"/>
        <result column="PL_IsChanged" property="ischanged" jdbcType="BIT"/>
        <result column="PL_ChangeCatalog" property="changecatalog" jdbcType="VARCHAR"/>
        <result column="PL_ChangedTime" property="changedtime" jdbcType="TIMESTAMP"/>
        <result column="PL_ChangedResult" property="changedresult" jdbcType="VARCHAR"/>
        <result column="PL_Advise" property="advise" jdbcType="VARCHAR"/>
        <result column="PL_Extension1" property="extension1" jdbcType="VARCHAR"/>
        <result column="PL_Extension2" property="extension2" jdbcType="VARCHAR"/>
        <result column="PL_Extension3" property="extension3" jdbcType="VARCHAR"/>
        <result column="PL_Remark" property="remark" jdbcType="VARCHAR"/>
    </resultMap>
    <sql id="Base_Column_List">
        <!--
          WARNING - @mbg.generated
        -->
        PL_GUID, I_GUID, ST_GUID, S_GUID, PL_SenseName, PL_SenseAddress, PT_GUID, PL_ProblemName,
        PL_Longitude, PL_Latitude, PL_LocationID, PL_Location, PL_Time, PL_IsRechecked, PL_RecheckTime,
        PL_RecheckUserGUID, PL_RecheckUserName, PL_RecheckUserRealName, PL_RecheckDescription,
        PL_RecheckResultID, PL_RecheckResult, PL_IsChanged, PL_ChangeCatalog, PL_ChangedTime,
        PL_ChangedResult, PL_Advise, PL_Extension1, PL_Extension2, PL_Extension3, PL_Remark
    </sql>
 
    <resultMap id="StatisticsVoMap" type="cn.flightfeather.supervision.lightshare.vo.StatisticsVo">
        <result property="name" column="name"/>
        <result property="startTime" column="startTime"/>
        <result property="endTime" column="endTime"/>
        <result property="count" column="count"/>
        <result property="changeCount" column="changeCount"/>
<!--        <collection property="problems" ofType="cn.flightfeather.supervision.domain.ds1.entity.Problemlist" resultMap="BaseResultMap"/>-->
    </resultMap>
    <resultMap id="SceneProblemSummary" type="cn.flightfeather.supervision.lightshare.vo.SceneProblemSummary">
        <id property="sceneId" column="sceneId"/>
        <result property="proNum" column="proNum"/>
        <result property="changeNum" column="changeNum"/>
        <result property="changePer" column="changePer"/>
        <association property="scene" resultMap="cn.flightfeather.supervision.domain.ds1.mapper.ScenseMapper.BaseResultMap" />
<!--        <collection property="subtasks" ofType="cn.flightfeather.supervision.domain.ds1.entity.Subtask"-->
<!--                     resultMap="cn.flightfeather.supervision.domain.ds1.mapper.SubtaskMapper.BaseResultMap" />-->
    </resultMap>
 
    <select id="getStatisticalResult" parameterType="String" resultMap="StatisticsVoMap">
        SELECT
        b.PT_TypeName as name,
        COUNT(b.PT_TypeName) as count,
        COUNT(CASE WHEN a.PL_IsChanged = 1 THEN 1 ELSE NULL END) as changeCount
        FROM
        im_t_problemlist AS a
        LEFT JOIN sm_t_problemtype AS b ON a.PT_GUID = b.PT_GUID
        LEFT JOIN sm_t_scense AS f ON a.S_GUID = f.S_GUID
        LEFT JOIN tm_t_subtask AS c ON a.ST_GUID = c.ST_GUID
        <where>
<!--        <if test="startTime != null">-->
<!--            AND c.ST_PlanStartTime >= #{startTime}-->
<!--        </if>-->
<!--        <if test="endTime != null">-->
<!--            AND c.ST_PlanStartTime &lt;= #{endTime}-->
<!--        </if>-->
<!--        <if test="districtCode != null">-->
<!--            AND f.S_DistrictCode = #{districtCode}-->
<!--        </if>-->
            <if test="scensetypeid != null">
                AND f.S_TypeID = #{scensetypeid}
            </if>
            <if test="sceneId != null">
                AND a.S_GUID = #{sceneId}
            </if>
            <include refid="cn.flightfeather.supervision.domain.ds1.mapper.ScenseMapper.Where_Area">
                <property name="tableAlias" value="f"/>
            </include>
            <include refid="cn.flightfeather.supervision.domain.ds1.mapper.SubtaskMapper.Where_Plan_Time">
                <property name="tableAlias" value="c"/>
            </include>
        </where>
        GROUP BY
        b.PT_TypeName
        ORDER BY
        COUNT(b.PT_TypeName) DESC
    </select>
    <!--根据顶层任务id和场景类型id获取问题分类情况,结果同getStatisticalResult-->
    <select id="getStatisticalResultById" parameterType="String" resultType="map">
        SELECT
        b.PT_TypeName AS name,
        COUNT(b.PT_TypeName) AS count,
        COUNT(CASE WHEN a.PL_IsChanged = 1 THEN 1 ELSE NULL END) as changeCount
        FROM
        im_t_problemlist AS a
        LEFT JOIN sm_t_problemtype AS b ON a.PT_GUID = b.PT_GUID
        LEFT JOIN sm_t_scense AS f ON a.S_GUID = f.S_GUID
        LEFT JOIN tm_t_subtask AS c ON a.ST_GUID = c.ST_GUID
        WHERE
        c.T_GUID = #{param1}
        AND f.S_TypeID = #{param2}
        GROUP BY
        b.PT_TypeName
        ORDER BY
        COUNT(b.PT_TypeName) DESC
    </select>
    <select id="getChangeResult" parameterType="String" resultType="map">
        SELECT
        a.S_GUID as id,
        a.PL_SenseName as name,
        f.S_TypeID as type,
        COUNT(a.PL_GUID) as problemCount,
        COUNT(CASE WHEN a.PL_IsChanged = 1 THEN 1 ELSE NULL END) as changeCount
        FROM
        im_t_problemlist AS a
        LEFT JOIN sm_t_problemtype AS b ON a.PT_GUID = b.PT_GUID
        LEFT JOIN sm_t_scense AS f ON a.S_GUID = f.S_GUID
        LEFT JOIN sm_t_monitorobjectversion as g ON a.S_GUID = g.S_GUID
        WHERE
        a.ST_GUID IN (
        SELECT
        ST_GUID
        FROM
        tm_t_subtask
        WHERE
        T_GUID = #{param1}
        )
        AND f.S_TypeID = #{param2}
        AND g.T_ID = #{param1}
        GROUP BY
        id
        ORDER BY
        problemCount DESC
    </select>
    <select id="getScoreResult" resultType="map" parameterType="String">
        SELECT
        b.ST_name as name,
        E_ResultScoreBef as scoreBef,
        E_ResultScoreAft as scoreAft
        FROM
        ea_t_evaluation AS a
        RIGHT JOIN tm_t_subtask AS b ON a.ST_GUID = b.ST_GUID
        WHERE
        b.T_GUID = #{param1}
        AND a.E_ScenseTypeID = #{param2}
    </select>
    <select id="getProblemByScene" resultMap="BaseResultMap" parameterType="String">
        SELECT
        a.*
        FROM
        im_t_problemlist AS a
        LEFT JOIN tm_t_subtask AS b ON a.ST_GUID = b.ST_GUID
        WHERE
        a.S_GUID = #{param1}
        AND b.T_GUID = #{param2}
    </select>
    <select id="findMonthProblemById" resultType="map">
        SELECT
        b.S_TownCode as towncode,
        b.S_TownName as townname,
        b.S_TypeID as scenetype,
        b.S_Type as scenetypename,
        COUNT(DISTINCT a.S_GUID) as totalscenecount,
        COUNT(DISTINCT d.S_GUID) as problemscenes,
        COUNT(d.PL_GUID) as totalproblems,
        SUM(CASE WHEN d.PL_IsChanged = 1 THEN 1 ELSE 0 END) as changedproblems
        FROM
        sm_t_monitorobjectversion AS a
        LEFT JOIN sm_t_scense AS b ON a.S_GUID = b.S_GUID
        LEFT JOIN tm_t_subtask AS c ON a.T_ID = c.T_GUID AND b.S_GUID = c.ST_ScenseID
        LEFT JOIN im_t_problemlist AS d ON c.ST_GUID = d.ST_GUID
        WHERE
        a.T_ID = #{param1}
        <if test="param2 !=null and param2 !=''">
            AND S_TypeID = #{param2}
        </if>
        GROUP BY
        b.S_TownCode
    </select>
    <select id="findUnchangedCount" resultType="int" parameterType="String">
        SELECT
        SUM(CASE WHEN a.PL_IsChanged = 0 THEN 1 ELSE 0 END) as unChanged
        FROM
        im_t_problemlist AS a
        LEFT JOIN tm_t_subtask AS b ON a.ST_GUID = b.ST_GUID
        WHERE
        b.TS_GUID = #{param1}
        GROUP BY
        b.ST_GUID
    </select>
    <select id="getSceneProSummary" resultMap="SceneProblemSummary">
        SELECT
        IF(proNum = 0, 1, changeNum/proNum) AS changePer,
        t_p.*
        FROM (
            SELECT
            b.S_GUID AS sceneId,
            SUM(d.PL_GUID is NOT null) AS proNum,
            SUM(d.PL_IsChanged = TRUE) AS changeNum,
            b.*
            FROM
            sm_t_scense AS b
            LEFT JOIN tm_t_subtask AS a ON a.ST_ScenseID = b.S_GUID
            LEFT JOIN im_t_problemlist AS d ON a.ST_GUID = d.ST_GUID
            <where>
                <include refid="cn.flightfeather.supervision.domain.ds1.mapper.ScenseMapper.Where_Area">
                    <property name="tableAlias" value="b"/>
                </include>
                <include refid="cn.flightfeather.supervision.domain.ds1.mapper.SubtaskMapper.Where_Plan_Time">
                    <property name="tableAlias" value="a"/>
                </include>
<!--            a.T_GUID = #{topTaskId}-->
                <if test="scensetypeid != null">
                    and b.S_TypeID = #{scensetypeid}
                </if>
            </where>
            GROUP BY
            b.S_GUID
        ) as t_p
        <if test="sortBy == 'pro'">
            <if test="sort == 'asc'">
                ORDER BY proNum asc, changeNum desc
            </if>
            <if test="sort == 'desc'">
                ORDER BY proNum desc, changeNum asc
            </if>
        </if>
        <if test="sortBy == 'changePer'">
            <if test="sort == 'asc'">
                ORDER BY changePer asc, proNum desc
            </if>
            <if test="sort == 'desc'">
                ORDER BY changePer desc, proNum asc
            </if>
        </if>
    </select>
</mapper>