luohairen
2024-12-04 fc6b946b1020ddff4fe2b01c9e439680cbda6b47
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
<?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.ycl.mapper.PlanMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.ycl.domain.vo.PlanVO">
        <result column="project_info_id" property="projectInfoId" />
        <result column="report_status" property="reportStatus" />
        <result column="month_status" property="monthStatus" />
        <result column="season_status" property="seasonStatus" />
        <result column="year_status" property="yearStatus" />
        <result column="gmt_create" property="gmtCreate" />
        <result column="gmt_update" property="gmtUpdate" />
    </resultMap>
 
    <!-- 分页条件查询项目计划记录映射结果 -->
    <resultMap id="PageResultMap" type="com.ycl.domain.vo.ProjectPlanResponseVO">
        <id property="id" column="id" />
        <result property="projectName" column="project_name" />
        <result property="reportStatus" column="report_status" />
        <result property="projectCode" column="project_code" />
        <result property="projectType" column="project_type" />
        <result property="projectPhase" column="project_phase" />
        <result property="monthStatus" column="month_status" />
        <result property="seasonStatus" column="season_status" />
        <result property="yearStatus" column="year_status" />
        <result property="projectStatus" column="project_status" />
        <result property="investType" column="invest_type" />
    </resultMap>
 
 
 
 
 
 
 
    <select id="getById" resultMap="BaseResultMap">
        SELECT
            TP.project_info_id,
            TP.report_status,
            TP.month_status,
            TP.season_status,
            TP.year_status,
            TP.gmt_create_time,
            TP.gmt_update_time,
            TP.id
        FROM
            t_plan TP
        WHERE
            TP.id = #{id} AND TP.deleted = 0
    </select>
 
 
    <select id="getPage" resultMap="PageResultMap">
        SELECT DISTINCT
            pi.id,
            pi.project_name,
            p.report_status,
            pi.project_code,
            pi.project_type,
            pi.project_phase,
            IFNULL((select report_status from t_project_plan_record
             WHERE plan_time_flag = 0 AND project_info_id = pi.id ORDER BY create_time DESC LIMIT 1),1) as month_status,
            IFNULL((select report_status from t_project_plan_record
             WHERE plan_time_flag = 1 AND project_info_id = pi.id ORDER BY create_time DESC LIMIT 1),1) as season_status,
            IFNULL((select report_status from t_project_plan_record
             WHERE plan_time_flag = 2 AND project_info_id = pi.id ORDER BY create_time DESC LIMIT 1),1) as year_status,
            pi.project_status,
            pi.invest_type
        FROM t_plan AS p
            INNER JOIN t_project_info AS pi ON p.project_info_id = pi.id
            INNER JOIN t_project_plan_record AS ppr ON p.id = ppr.plan_id
        WHERE
            p.deleted = 0
    </select>
 
</mapper>