feiyu02
2025-09-30 6904763f0e74d9a9fa4dbc39f635d2aee39416c6
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
<?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.mapper.SelfPatrolTaskMapper">
  <resultMap id="BaseResultMap" type="cn.flightfeather.supervision.domain.entity.SelfPatrolTask">
    <!--
      WARNING - @mbg.generated
    -->
    <id column="SP_GUID" jdbcType="VARCHAR" property="spGuid" />
    <result column="SP_To_User_Id" jdbcType="VARCHAR" property="spToUserId" />
    <result column="SP_From_User_Id" jdbcType="VARCHAR" property="spFromUserId" />
    <result column="SP_Scene_Type_Id" jdbcType="INTEGER" property="spSceneTypeId" />
    <result column="SP_Ledger_Type_Id" jdbcType="VARCHAR" property="spLedgerTypeId" />
    <result column="SP_Tag" jdbcType="VARCHAR" property="spTag" />
    <result column="SP_Publish_Unit" jdbcType="VARCHAR" property="spPublishUnit" />
    <result column="SP_Task_Year" jdbcType="INTEGER" property="spTaskYear" />
    <result column="SP_Task_Month" jdbcType="INTEGER" property="spTaskMonth" />
    <result column="SP_Create_Time" jdbcType="TIMESTAMP" property="spCreateTime" />
    <result column="SP_Deadline" jdbcType="TIMESTAMP" property="spDeadline" />
    <result column="SP_Task_Status" jdbcType="INTEGER" property="spTaskStatus" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--
      WARNING - @mbg.generated
    -->
    SP_GUID, SP_To_User_Id, SP_From_User_Id, SP_Scene_Type_Id, SP_Ledger_Type_Id, SP_Tag, 
    SP_Publish_Unit, SP_Task_Year, SP_Task_Month, SP_Create_Time, SP_Deadline, SP_Task_Status
  </sql>
 
  <resultMap id="SelfPatrolTaskVo" type="cn.flightfeather.supervision.lightshare.vo.SelfPatrolTaskVo" />
  <select id="getPublishedTask" resultMap="SelfPatrolTaskVo">
    SELECT
    a.SP_GUID AS guid,
    a.SP_To_User_Id AS toUserId,
    b.UI_RealName AS toUserName,
    a.SP_From_User_Id AS fromUserId,
    c.UI_RealName AS fromUserName,
    a.SP_Scene_Type_Id AS sceneTypeId,
    a.SP_Ledger_Type_Id AS ledgerTypeId,
    a.SP_Tag AS tag,
    a.SP_Publish_Unit AS publishUnit,
    a.SP_Create_Time AS createTime,
    a.SP_Deadline AS deadline,
    a.SP_Task_Status AS taskStatus,
    SUM(IF(d.SP_GUID IS NOT NULL, 1, 0)) AS finished
    FROM
    ea_t_self_patrol_task AS a
    LEFT JOIN sm_t_userinfo AS b ON a.SP_To_User_Id = b.UI_GUID
    LEFT JOIN sm_t_userinfo AS c ON a.SP_From_User_Id = c.UI_GUID
    LEFT JOIN ea_t_self_patrol_record AS d ON a.SP_GUID = d.SP_GUID
    WHERE a.SP_From_User_Id = #{userId}
    <if test="year != null">
      AND a.SP_Task_Year = #{year}
    </if>
    <if test="month != null">
      AND a.SP_Task_Month = #{month}
    </if>
    GROUP BY
    a.SP_GUID
    ORDER BY createTime DESC
  </select>
</mapper>