feiyu02
2024-04-25 0392c333ed3d987cb2ab3dac4e1a972cff405f21
src/main/resources/mapper/ds1/ProblemlistMapper.xml
@@ -36,13 +36,6 @@
    <result column="PL_Extension3" property="extension3" jdbcType="VARCHAR" />
    <result column="PL_Remark" property="remark" jdbcType="VARCHAR" />
  </resultMap>
  <resultMap id="StatisticsVoMap" type="cn.flightfeather.supervision.lightshare.vo.StatisticsVo">
    <id property="name" column="T_Name"/>
    <result property="startTime" column="startTime"/>
    <result property="endTime" column="endTime"/>
    <result property="count" column="count1"/>
  </resultMap>
  <sql id="Base_Column_List" >
    <!--
      WARNING - @mbg.generated
@@ -54,8 +47,24 @@
    PL_ChangedResult, PL_Advise, PL_Extension1, PL_Extension2, PL_Extension3, PL_Remark
  </sql>
  <!--<select id="getStatisticalResult" parameterType="String" resultMap="StatisticsVoMap">-->
  <select id="getStatisticalResult" parameterType="String" resultType="map">
    <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"/>
    </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,
@@ -64,25 +73,46 @@
        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
      WHERE
        a.ST_GUID IN (
          SELECT
            d.ST_GUID
          FROM
            tm_t_subtask AS d LEFT JOIN tm_t_task AS e ON d.T_GUID = e.T_GUID
          WHERE
            e.T_LevelNum = '2'
            AND e.T_StartTime &lt;= #{param2}
            AND e.T_EndTime >= #{param3}
            AND e.T_DistrictCode = #{param1}
          )
      AND f.S_TypeID = #{param4}
        LEFT JOIN tm_t_subtask AS c ON a.ST_GUID = c.ST_GUID
        <where>
<!--        a.ST_GUID IN (-->
<!--            SELECT-->
<!--            d.ST_GUID-->
<!--            FROM-->
<!--            tm_t_subtask AS d LEFT JOIN tm_t_task AS e ON d.T_GUID = e.T_GUID-->
<!--            WHERE-->
<!--            e.T_LevelNum = '2'-->
<!--            <if test="startTime != null">-->
<!--                AND e.T_StartTime &lt;= #{startTime}-->
<!--            </if>-->
<!--            <if test="endTime != null">-->
<!--                AND e.T_EndTime >= #{endTime}-->
<!--            </if>-->
<!--            <if test="districtCode != null">-->
<!--                AND e.T_DistrictCode = #{districtCode}-->
<!--            </if>-->
<!--        )-->
        <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="sceneType != null">
            AND f.S_TypeID = #{sceneType}
        </if>
        <if test="sceneId != null">
            AND a.S_GUID = #{sceneId}
        </if>
        </where>
      GROUP BY
        b.PT_TypeName
      ORDER BY
        COUNT(b.PT_TypeName) DESC
  </select>
  <!--select DISTINCT T_Name as name, count(*) as count from tm_t_task where T_LevelNum = 2-->
    <!--根据顶层任务id和场景类型id获取问题分类情况,结果同getStatisticalResult-->
    <select id="getStatisticalResultById" parameterType="String" resultType="map">
        SELECT
@@ -102,8 +132,6 @@
        ORDER BY
            COUNT(b.PT_TypeName) DESC
    </select>
    <select id="getChangeResult" parameterType="String" resultType="map">
    SELECT
      a.S_GUID as id,
@@ -144,11 +172,6 @@
            b.T_GUID = #{param1}
        AND a.E_ScenseTypeID = #{param2}
    </select>
    <select id="selectSE" resultType="string" parameterType="String">
        ${_parameter}
    </select>
    <select id="getProblemByScene" resultMap="BaseResultMap" parameterType="String">
        SELECT
            a.*
@@ -182,7 +205,6 @@
        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
@@ -194,4 +216,43 @@
        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
            a.T_GUID = #{topTaskId}
            <if test="sceneTypeId != null">
                and b.S_TypeID = #{sceneTypeId}
            </if>
            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>