gonglilong
2024-09-14 17dc74a722d4b9e441c0db65ff6ed67df8df5a09
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
<?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.sg.mapper.SgProgressReportMapper">
 
    <select id="queryPageList" resultType="cn.gistack.sm.sg.VO.SgProgressReportVO">
        SELECT
        report.*,
        de.device_name,
        de.device_type,
        dict."DICT_VALUE" as typeName
        FROM
        ywxt.SG_PROGRESS_REPORT report
        LEFT JOIN ywxt.sg_device de ON report.gx_device_id = de.id
        left join YWXT."BLADE_DICT_BIZ" as dict  on de.device_type=dict.DICT_KEY  and dict.CODE='SG_DEVICE_TYPE'
        where 1=1
        <if test="dto.projectName != null and dto.projectName != ''">
            and report.PROGRAM_NAME like CONCAT(CONCAT('%',#{dto.projectName}),'%')
        </if>
        <if test="dto.deviceName != null and dto.deviceName != ''">
            and de.device_name like CONCAT(CONCAT('%', #{dto.deviceName}), '%')
        </if>
        <if test="dto.status != null ">
            and report.status = #{dto.status}
        </if>
        <if test="dto.reportPerson != null ">
            and report.report_user = #{dto.reportPerson}
        </if>
        <if test="dto.startTime != null and dto.startTime !='' ">
            and report.report_time &gt;= #{dto.startTime}
        </if>
        <if test="dto.endTime != null and dto.endTime !='' ">
            and report.report_time &lt;= #{dto.endTime}
        </if>
        order by report_time desc
    </select>
 
    <select id="queryPageListAll" resultType="cn.gistack.sm.sg.VO.SgProgressReportVO">
        SELECT
        report.*,
        de.device_name,
        de.device_type,
        dict."DICT_VALUE" as typeName, si.control_unit,si.self_unit,dria."county_cd"
        FROM
        ywxt.SG_PROGRESS_REPORT report
        LEFT JOIN ywxt.SG_PROJECT_INFO si ON report.profram_id = si.id
        LEFT JOIN SJZT_DW."dim_res_info_a" dria ON dria."res_cd" = si.sk_id
        LEFT JOIN ywxt.sg_device de ON report.gx_device_id = de.id
        left join YWXT."BLADE_DICT_BIZ" as dict  on de.device_type=dict.DICT_KEY  and dict.CODE='SG_DEVICE_TYPE'
        where 1=1 and report."STATUS" != 4
        <if test="dto.projectName != null and dto.projectName != ''">
            and report.PROGRAM_NAME like CONCAT(CONCAT('%',#{dto.projectName}),'%')
        </if>
        <if test="dto.deviceName != null and dto.deviceName != ''">
            and de.device_name like CONCAT(CONCAT('%', #{dto.deviceName}), '%')
        </if>
        <if test="dto.status != null ">
            and report.status = #{dto.status}
        </if>
        <if test="dto.startTime != null and dto.startTime != ''">
            and report.create_time &gt;= #{dto.startTime}
        </if>
        <if test="dto.endTime != null and dto.endTime != ''">
            and report.create_time &lt;= #{dto.endTime}
        </if>
        order by report.report_time desc
    </select>
 
    <select id="queryById" resultType="cn.gistack.sm.sg.VO.SgProgressReportVO">
        select report.*,si.control_unit,si.self_unit,dria."county_cd" from  SG_PROGRESS_REPORT report  LEFT JOIN ywxt.SG_PROJECT_INFO si ON report.profram_id = si.id
                                                  LEFT JOIN SJZT_DW."dim_res_info_a" dria ON dria."res_cd" = si.sk_id where report.id = #{id}
    </select>
    <select id="queryList" resultType="cn.gistack.sm.sg.VO.SgProgressReportVO">
        SELECT distinct
        report.id,
        report.program_name,
        report.gx_step_name,
        report."STATUS",
        report.audit_person,
        report.report_time,
        report.create_time,
        report.gx_progress,
        report.remark,
        DBMS_LOB.SUBSTR(report.images_urls) imagesUrls ,
        DBMS_LOB.SUBSTR(report.video_urls) videoUrls,
        de.device_name,
        de.device_type,
        userR.approval_status,
        dict."DICT_VALUE" as typeName,
        si.control_unit,si.self_unit,dria."county_cd"
        FROM
        ywxt.SG_PROGRESS_REPORT report
        LEFT JOIN ywxt.SG_PROJECT_INFO si ON report.profram_id = si.id
        LEFT JOIN SJZT_DW."dim_res_info_a" dria ON dria."res_cd" = si.sk_id
        LEFT JOIN ywxt.sg_device de ON report.gx_device_id = de.id
        left join YWXT."BLADE_DICT_BIZ" as dict  on de.device_type=dict.DICT_KEY  and dict.CODE='SG_DEVICE_TYPE'
        LEFT JOIN ywxt.sg_report_user userR ON report.id = userR.report_id
        WHERE
        1 = 1 and report."STATUS" != 4
        <if test="dto.userUnit != null and dto.userUnit != ''">
            and  si.CONTROL_UNIT=#{dto.userUnit}
        </if>
        <if test="dto.countryUnit != null and dto.countryUnit != ''">
            and dria."county_cd"=#{dto.userUnit}
        </if>
        <if test="dto.roleUnit != null and dto.roleUnit != ''">
            and userR.role_id=#{dto.roleUnit}
        </if>
       <!-- AND userR.is_his = 0 -->
        <if test="dto.projectName != null and dto.projectName != ''">
            and report.PROGRAM_NAME like CONCAT(CONCAT('%',#{dto.projectName}),'%')
        </if>
        <if test="dto.deviceName != null and dto.deviceName != ''">
            and de.device_name like CONCAT(CONCAT('%', #{dto.deviceName}), '%')
        </if>
        <if test="dto.userId != null and dto.userId != ''">
            and userR.user_id = #{dto.userId} and userR.approval_order != 0
        </if>
        <if test="dto.approvalStatus != null and dto.approvalStatus ==0">
            and userR.approval_status = 0 and report.audit_person = #{dto.roleUnit} and (report."STATUS" = 0 or report."STATUS" = 1)
        </if>
        <if test="dto.approvalStatus != null and dto.approvalStatus ==1">
           and userR.approval_status = 1
        </if>
        <if test="dto.approvalStatus != null and dto.approvalStatus ==2">
            AND userR.approval_status = 2
        </if>
        <if test="dto.startTime != null and dto.startTime !='' ">
            and report.report_time &gt;= #{dto.startTime}
        </if>
        <if test="dto.endTime != null and dto.endTime !='' ">
            and report.report_time &lt;= #{dto.endTime}
        </if>
        order by report.report_time desc
        <!--<choose >
            <when test="dto.approvalStatus != null and dto.approvalStatus == 0">
                and report.audit_person = #{dto.userId} and (report."STATUS" = 0 or report."STATUS" = 1)
            </when>
            <when test="dto.approvalStatus != null and dto.approvalStatus == 1">
               and report."STATUS" != 1
            </when>
            <when test="dto.approvalStatus != null and dto.approvalStatus == 3">
                and report.report_user = #{dto.userId}
            </when>
        </choose>-->
    </select>
    <select id="countList" resultType="java.lang.Long">
        select count(1) from  ywxt.SG_PROGRESS_REPORT report
        left join  ywxt.sg_device de on report.gx_device_id = de.id
        left join ywxt.sg_report_user userR on  report.id = userR.report_id
        where 1=1 and userR.is_his = 0 and userR.approval_order != 0
        <if test="dto.userId != null and dto.userId != ''">
            and userR.user_id = #{dto.userId}
        </if>
        <if test="dto.approvalStatus != null ">
            and userR.approval_status = #{dto.approvalStatus}
        </if>
        <choose >
            <when test="dto.approvalStatus != null and dto.approvalStatus == 0">
                and report.audit_person = #{dto.userId}
            </when>
        </choose>
    </select>
    <select id="selectByDeviceId" resultType="cn.gistack.sm.sg.VO.SgStepReportVO">
        SELECT
            step.id AS stepId,
            step.gx_step_name AS stepName,
            step.gx_step_num AS stepNum,
            re.STATUS AS approvalStatus,
            re.report_time,
            re.resubmit
        FROM
            ywxt.sg_gx_step step
                LEFT JOIN ywxt.sg_gx gx ON step.gx_info_id = gx.id
                LEFT JOIN ywxt.sg_device de ON gx.gx_type = de.device_type
                LEFT JOIN ywxt.sg_progress_report re ON re.gx_step_id = step.id and re.gx_device_id = de.id and re."STATUS" != 4
        WHERE
            1 =1 and de.id = #{deviceId}
    </select>
    <select id="statusCount" resultType="cn.gistack.sm.sg.VO.SgProgressReportVO">
        SELECT
        report.*,
        de.device_name,
        de.device_type,
        dict."DICT_VALUE" as typeName
        FROM
        ywxt.SG_PROGRESS_REPORT report
        LEFT JOIN ywxt.sg_device de ON report.gx_device_id = de.id
        left join YWXT."BLADE_DICT_BIZ" as dict  on de.device_type=dict.DICT_KEY  and dict.CODE='SG_DEVICE_TYPE'
        where 1=1
        <if test="dto.projectName != null and dto.projectName != ''">
            and report.PROGRAM_NAME like CONCAT(CONCAT('%',#{dto.projectName}),'%')
        </if>
        <if test="dto.deviceName != null and dto.deviceName != ''">
            and de.device_name like CONCAT(CONCAT('%', #{dto.deviceName}), '%')
        </if>
        <if test="dto.reportPerson != null">
            and report.report_user = #{dto.reportPerson}
        </if>
    </select>
    <select id="getUserByIds" resultType="java.util.Map">
        select u.id ,u.real_name ,d.full_name as deptName from ywxt.blade_user u inner join ywxt.blade_dept d on u.dept_id = convert(varchar(100),d.id) where 1 = 1
        <if test="ids != null and ids.size>0">
            AND u.id in
            <foreach collection="ids" item="item" index="index" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
    </select>
    <select id="selectProframId" resultType="java.lang.Long">
        select program_id from ywxt.sg_device where id = #{deviceId}
    </select>
    <select id="selectProcessUserByProjectId" resultType="cn.gistack.sm.sg.DO.SgReportUserDO">
        select  u.* from ywxt.sg_report_user u left join  ywxt.sg_progresss_report r on u.report_id = r.id
        where 1=1 and r.profram_id = #{programId}
    </select>
</mapper>