guoshilong
2024-03-14 8fc6411b399d4f418006f063334a4122857e2077
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
<?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.gistack.sm.schedulingModules.mapper.SchedulingRecordMapper">
    <resultMap id="vo" type="cn.gistack.sm.schedulingModules.vo.SchedulingRecordVO">
        <id property="id" column="id"/>
        <result property="reservoirId" column="reservoir_id"/>
        <result property="reservoirName" column="reservoirName"/>
        <result property="gateStatus" column="gate_status"/>
        <result property="content" column="content"/>
        <result property="images" column="images" typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/>
        <result property="reportUser" column="real_name"/>
 
        <result property="createDept" column="create_dept"/>
        <result property="createUser" column="create_user"/>
        <result property="updateUser" column="update_user"/>
        <result property="updateTime" column="update_time"/>
        <result property="createTime" column="create_time"/>
        <result property="status" column="status"/>
        <result property="isDeleted" column="is_deleted"/>
 
        <result property="cityCode" column="cityCode"/>
        <result property="cityName" column="cityName"/>
        <result property="countyCode" column="countyCode"/>
        <result property="countyName" column="countyName"/>
        <result property="townCode" column="townCode"/>
        <result property="townName" column="townName"/>
 
        <result property="engScal" column="engScal"/>
        <result property="resRegCode" column="resRegCode"/>
 
    </resultMap>
 
 
    <select id="selectRecordPage" resultMap="vo">
        SELECT
            R.*,
               arb."name" reservoirName,
 
                arb."res_reg_code" as resRegCode,
                arb."eng_scal" as engScal,
 
                case when town."ad_grad" = 4 THEN town."ad_code" ELSE NULL END AS townCode,
                case when town."ad_grad" = 4 THEN town."ad_name" ELSE NULL END AS townName,
 
                case when town."ad_grad" = 3 THEN town."ad_code"
                when county."ad_grad" = 3 THEN county."ad_code" END AS countyCode,
                case when town."ad_grad" = 3 THEN town."ad_name"
                when county."ad_grad" = 3 THEN county."ad_name" END AS countyName,
 
                case when town."ad_grad" = 2 THEN town."ad_code"
                when county."ad_grad" = 2 THEN county."ad_code"
                ELSE city."ad_code" END AS cityCode,
                case when town."ad_grad" = 2 THEN town."ad_name"
                when county."ad_grad" = 2 THEN county."ad_name"
                ELSE city."ad_name" END AS cityName,
 
               U.REAL_NAME
        FROM SM_SCHEDULING_RECORD R
        LEFT JOIN SJZT_MD."att_res_base" arb on arb."guid" = R.reservoir_id
        LEFT JOIN BLADE_USER U ON U.ID = R.CREATE_USER
 
        LEFT JOIN SJZT_MD."att_ad_base"town ON arb."interior_ad_guid" = town."guid"
        LEFT JOIN SJZT_MD."att_ad_base" county ON town."p_ad_code" = county."guid"
        LEFT JOIN SJZT_MD."att_ad_base" city ON county."p_ad_code" = city."guid"
        LEFT JOIN SJZT_MD."att_ad_base" province ON province."guid" = city."p_ad_code"
 
        WHERE R.IS_DELETED = 0
        <if test="record.adCode != null and record.adCode != '' ">
            AND CONCAT(province."ad_code",city."ad_code",county."ad_code",town."ad_code") LIKE CONCAT('%',#{record.adCode},'%')
        </if>
        <if test="record.reservoirName != null and record.reservoirName !=''">
            AND arb."name" LIKE CONCAT('%',#{record.reservoirName},'%')
        </if>
        <if test="record.gateStatus !=null and record.gateStatus !=''">
            AND R.gate_status = #{record.gateStatus}
        </if>
        <if test="record.createUser !=null and record.createUser !=''">
            AND R.CREATE_USER = #{record.createUser}
        </if>
 
        <if test="record.resRegCode != null and record.resRegCode != ''">
            AND arb."res_reg_code" LIKE CONCAT('%',#{record.resRegCode},'%')
        </if>
        <if test="record.reservoirId != null and record.reservoirId != ''">
            AND r.reservoir_id LIKE CONCAT('%',#{record.reservoirId},'%')
        </if>
        <if test="record.engScal != null and record.engScal != ''">
            AND arb."eng_scal" = #{record.engScal}
        </if>
        <if test="record.startTime != null and record.startTime != ''">
            AND R.create_time &gt;= #{record.startTime}
        </if>
        <if test="record.endTime != null and record.endTime !='' ">
            AND R.create_time &lt;= #{record.endTime}
        </if>
 
 
        ORDER BY R.CREATE_TIME  DESC
    </select>
    <select id="customizeGetDetail" resultType="cn.gistack.sm.schedulingModules.vo.SchedulingRecordVO">
        SELECT R.*,arb."name" reservoirName FROM SM_SCHEDULING_RECORD R
        LEFT JOIN SJZT_MD."att_res_base" arb on arb."guid" = R.reservoir_id
        WHERE R.IS_DELETED = 0 AND r.id = #{record.id}
        <if test="record.reservoirName != null and record.reservoirName !=''">
            AND arb."name" LIKE CONCAT('%',#{record.reservoirName},'%')
        </if>
        <if test="record.gateStatus !=null and record.gateStatus !=''">
            AND R.gate_status = #{record.gateStatus}
        </if>
    </select>
</mapper>