tj
2025-06-05 2d549a04870d1315868a7cf19952b64e8071e711
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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
<?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.cloudroam.mapper.ProjectInfoMapperCustom">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.cloudroam.bo.ProjectInfoBO">
        <id column="id" property="id" />
        <!--<result column="create_time" property="createTime" />
        <result column="update_time" property="updateTime" />
        <result column="delete_time" property="deleteTime" />-->
        <result column="tenant_id" property="tenantId" />
        <result column="project_no" property="projectNo" />
        <result column="project_name" property="projectName" />
        <result column="manager_id" property="managerId" />
        <result column="contact_id" property="contactId" />
        <result column="project_desc" property="projectStatus" />
        <result column="estimate_start_time" property="estimateStartTime" />
        <result column="estimate_complete_time" property="estimateCompleteTime" />
        <result column="actual_start_time" property="actualStartTime" />
        <result column="actual_complete_time" property="actualCompleteTime" />
        <result column="inner_hours" property="innerHours" />
        <result column="outer_hours" property="outerHours" />
        <result column="actual_hours" property="actualHours" />
        <result column="project_status" property="projectStatus" />
        <result column="remark" property="remark" />
        <result column="company_id" property="companyId" />
        <result column="project_stage" property="projectStage" />
        <result column="project_type" property="projectType" />
        <result column="estimate_develop_hours" property="estimateDevelopHours" />
        <result column="estimate_test_hours" property="estimateTestHours" />
        <result column="need_design" property="needDesign" />
        <result column="need_develop" property="needDevelop" />
        <result column="need_price" property="needPrice" />
        <result column="create_user_id" property="createUserId" />
        <result column="create_user_name" property="createUserName" />
        <result column="update_user_id" property="updateUserId" />
        <result column="update_user_name" property="updateUserName" />
        <result column="is_deleted" property="isDeleted" />
        <result column="delete_user_id" property="deleteUserId" />
        <result column="delete_user_name" property="deleteUserName" />
 
        <result column="pro_estimate_start_time" property="proEstimateStartTime" />
        <result column="pro_estimate_complete_time" property="proEstimateCompleteTime" />
        <result column="pro_actual_start_time" property="proActualStartTime" />
        <result column="pro_actual_complete_time" property="proActualCompleteTime" />
 
        <result column="bus_estimate_start_time" property="busEstimateStartTime" />
        <result column="bus_estimate_complete_time" property="busEstimateCompleteTime" />
        <result column="bus_actual_start_time" property="busActualStartTime" />
        <result column="bus_actual_complete_time" property="busActualCompleteTime" />
 
        <result column="company_name" property="companyName" />
        <result column="contact_name" property="contactName" />
        <result column="manager_name" property="managerName" />
        <result column="project_type_name" property="projectTypeName" />
        <result column="project_status_name" property="projectStatusName" />
        <result column="project_stage_name" property="projectStageName" />
 
 
    </resultMap>
 
    <select id="selectProjectInfoPage" resultType="com.cloudroam.bo.ProjectInfoBO">
        select p.*,
        c.short_name as company_name ,
        co.name as contact_name,
        u.nickname as manager_name,
        dict_type.label as project_type_name,
        dict_status.label as project_status_name,
        dict_stage.label as project_stage_name
        from project_info p
        left join company_info c
        on p.company_id= c.id
        left join contact_info co
        on p.contact_id =co.id
        left join lin_user u
        on p.manager_id=u.id
        left join (
        select id,label,value from sys_dict_item where dict_type='project_type' and is_deleted=0
        ) dict_type
        on p.project_type=dict_type.`value`
        left join (
        select id,label,value from sys_dict_item where dict_type='project_status' and is_deleted=0
        ) dict_status
        on p.project_status=dict_status.`value`
        left join (
        select id,label,value from sys_dict_item where dict_type='project_stage' and is_deleted=0
        ) dict_stage
        on p.project_stage=dict_stage.`value`
        where p.is_deleted=0
 
        <if test=" keyword !=null and keyword !='' ">
            and (
            UPPER(p.project_name) like  UPPER(concat('%',#{keyword},'%'))
            or p.project_desc like concat('%',#{keyword},'%')
            or p.remark like concat('%',#{keyword},'%')
            or c.short_name like concat('%',#{keyword},'%')
            or co.name like concat('%',#{keyword},'%')
            or u.username like concat('%',#{keyword},'%')
            )
        </if>
 
        <if test=" status !=null and status !='' ">
            and p.project_status= #{status}
        </if>
        <if test=" stage !=null and stage !='' ">
            and p.project_stage=#{stage}
        </if>
        <if test=" type !=null and type !='' ">
            and p.project_type= #{type}
        </if>
 
        order by p.create_time desc
    </select>
 
 
 
    <sql id="baseInfo">
        select p.*,
        c.short_name as company_name ,
        co.name as contact_name,
        u.nickname as manager_name,
        dict_type.label as project_type_name,
        dict_status.label as project_status_name,
        dict_stage.label as project_stage_name
        from project_info p
        left join company_info c
        on p.company_id= c.id
        left join contact_info co
        on p.contact_id =co.id
        left join lin_user u
        on p.manager_id=u.id
        left join (
        select id,label,value from sys_dict_item where dict_type='project_type' and is_deleted=0
        ) dict_type
        on p.project_type=dict_type.`value`
        left join (
        select id,label,value from sys_dict_item where dict_type='project_status' and is_deleted=0
        ) dict_status
        on p.project_status=dict_status.`value`
        left join (
        select id,label,value from sys_dict_item where dict_type='project_stage' and is_deleted=0
        ) dict_stage
        on p.project_stage=dict_stage.`value`
        where p.is_deleted=0
 
    </sql>
 
    <select id="getProjectHourStatistics" resultType="com.cloudroam.bo.ProjectUserStatisticsBO">
 
 
        SELECT *
        FROM
        (
            SELECT i.project_name,u.nickname as create_user_name,t.* ,t2.total_actual_hours,t2.total_estimated_hours,round((t.actual_hours/t2.total_actual_hours)*100 ,2)as actual_hours_percent
            FROM project_info i
            INNER JOIN (
                SELECT project_id,create_user_id, sum( estimated_hours ) AS estimated_hours,sum( actual_hours ) AS actual_hours
                FROM project_daily
                WHERE is_deleted = 0
                AND daily_status != 3
                <if test=" dto.isConfirm !=null">
                    AND is_confirm = #{dto.isConfirm}
                </if>
                GROUP BY project_id,create_user_id
            ) t
            ON i.id = t.project_id
            LEFT JOIN lin_user u ON t.create_user_id = u.id
            left join (
                select project_id,sum( estimated_hours ) AS total_estimated_hours,sum(actual_hours) as total_actual_hours
                from project_daily d
                where d.is_deleted=0
                <if test=" dto.isConfirm !=null">
                    AND d.is_confirm = #{dto.isConfirm}
                </if>
                and d.daily_status != 3
                group by project_id
            )t2
            on i.id=t2.project_id
        ) t3
        WHERE 1=1
        <if test=" dto.projectId !=null and dto.projectId !='' ">
            and project_id=#{dto.projectId}
        </if>
        ORDER BY project_id,create_user_id
    </select>
    <select id="getDetailById" resultType="com.cloudroam.bo.ProjectInfoBO">
        select p.*,
        c.short_name as company_name ,
        co.name as contact_name,
        u.nickname as manager_name,
        dict_type.label as project_type_name,
        dict_status.label as project_status_name,
        dict_stage.label as project_stage_name
        from project_info p
        left join company_info c
        on p.company_id= c.id
        left join contact_info co
        on p.contact_id =co.id
        left join lin_user u
        on p.manager_id=u.id
        left join (
        select id,label,value from sys_dict_item where dict_type='project_type' and is_deleted=0
        ) dict_type
        on p.project_type=dict_type.`value`
        left join (
        select id,label,value from sys_dict_item where dict_type='project_status' and is_deleted=0
        ) dict_status
        on p.project_status=dict_status.`value`
        left join (
        select id,label,value from sys_dict_item where dict_type='project_stage' and is_deleted=0
        ) dict_stage
        on p.project_stage=dict_stage.`value`
        where p.is_deleted=0
        <if test=" projectId !=null and projectId !='' ">
            and p.id= #{projectId}
        </if>
    </select>
    <select id="getBoardProjectList" resultType="com.cloudroam.bo.ProjectInfoBO">
 
        <include refid="baseSelectSql" />
        <if test=" dto.projecdtList !=null and dto.projecdtList.size > 0 ">
            and p.id in
            <foreach collection="dto.projecdtList" item="id" open="(" separator="," close=")">
                #{id}
            </foreach>
        </if>
        <if test=" dto.statusList !=null and dto.statusList.size > 0 ">
            and p.project_status in
            <foreach collection="dto.statusList" item="status" open="(" separator="," close=")">
                #{status}
            </foreach>
        </if>
        <if test=" dto.stage !=null and dto.stage !='' ">
            and p.project_stage=#{dto.stage}
        </if>
 
    </select>
    <select id="getProjectMinMaxDateList" resultType="com.cloudroam.bo.project.ProjectMinMaxDateBO">
        select min(project_time) as min_date,max(project_time) as max_date
        from(
                select
                    id,pro_estimate_start_time as project_time
                from project_info
                union
                select
                    id,pro_estimate_complete_time as project_time
                from project_info
                union
                select
                    id,pro_actual_start_time as project_time
                from project_info
                union
                select
                    id,pro_actual_complete_time as project_time
                from project_info
                union
                select
                    id,bus_estimate_start_time as project_time
                from project_info
                union
                select
                    id,bus_estimate_complete_time as project_time
                from project_info
                union
                select
                    id,bus_actual_start_time as project_time
                from project_info
                union
                select
                    id,bus_actual_complete_time as project_time
                from project_info
            )t
        where t.id in
        <foreach collection="list" item="id" open="(" separator="," close=")">
            #{id}
        </foreach>
        limit 1
    </select>
    <select id="getProjectMinMaxDateDefaultList" resultType="com.cloudroam.bo.project.ProjectMinMaxDateBO">
        select min(project_time) as min_date,max(project_time) as max_date
        from(
                select
                    id,estimate_start_time as project_time
                from project_info
                union
                select
                    id,estimate_complete_time as project_time
                from project_info
                union
                select
                    id,actual_start_time as project_time
                from project_info
                union
                select
                    id,actual_complete_time as project_time
                from project_info
            )t
    </select>
    <select id="selectProjectInfoPageByDTO" resultType="com.cloudroam.bo.ProjectInfoBO">
        <include refid="pageReportSql"></include>
    </select>
    
<!--    获取所有报表项目数据-->
    <select id="getReportList" resultType="com.cloudroam.bo.ProjectInfoBO">
        <include refid="pageReportSql"></include>
    </select>
    
    
    <sql id="pageReportSql">
        select p.*,
        c.short_name as company_name ,
        co.name as contact_name,
        u.nickname as manager_name,
        dict_type.label as project_type_name,
        dict_status.label as project_status_name,
        dict_stage.label as project_stage_name
        from project_info p
        left join company_info c
        on p.company_id= c.id
        left join contact_info co
        on p.contact_id =co.id
        left join lin_user u
        on p.manager_id=u.id
        left join (
        select id,label,value from sys_dict_item where dict_type='project_type' and is_deleted=0
        ) dict_type
        on p.project_type=dict_type.`value`
        left join (
        select id,label,value from sys_dict_item where dict_type='project_status' and is_deleted=0
        ) dict_status
        on p.project_status=dict_status.`value`
        left join (
        select id,label,value from sys_dict_item where dict_type='project_stage' and is_deleted=0
        ) dict_stage
        on p.project_stage=dict_stage.`value`
        where p.is_deleted=0
 
        <if test=" dto.keyword !=null and dto.keyword !='' ">
            and (
            UPPER(p.project_name) like  UPPER(concat('%',#{dto.keyword},'%'))
            or p.project_desc like concat('%',#{dto.keyword},'%')
            or p.remark like concat('%',#{dto.keyword},'%')
            or c.short_name like concat('%',#{dto.keyword},'%')
            or co.name like concat('%',#{dto.keyword},'%')
            or u.username like concat('%',#{dto.keyword},'%')
            )
        </if>
 
        <if test=" dto.status !=null and dto.status !='' ">
            and p.project_status= #{dto.status}
        </if>
        <if test=" dto.stage !=null and dto.stage !='' ">
            and p.project_stage=#{dto.stage}
        </if>
        <if test=" dto.type !=null and dto.type !='' ">
            and p.project_type= #{dto.type}
        </if>
 
        <if test="dto.statusList != null and dto.statusList.size() > 0">
            and p.project_status in
            <foreach collection="dto.statusList" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
 
        <if test="dto.stageList != null and dto.stageList.size() > 0">
            and p.project_stage in
            <foreach collection="dto.stageList" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
 
        <if test="dto.typeList != null and dto.typeList.size() > 0">
            and p.project_type in
            <foreach collection="dto.typeList" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
 
        order by p.create_time desc
    </sql>
 
    <sql id="baseSelectSql">
        select p.*,
               c.short_name as company_name ,
               co.name as contact_name,
               u.nickname as manager_name,
               dict_type.label as project_type_name,
               dict_status.label as project_status_name,
               dict_stage.label as project_stage_name
        from project_info p
        left join company_info c
        on p.company_id= c.id
        left join contact_info co
        on p.contact_id =co.id
        left join lin_user u
        on p.manager_id=u.id
        left join (
            select id,label,value from sys_dict_item where dict_type='project_type' and is_deleted=0
        ) dict_type
        on p.project_type=dict_type.`value`
        left join (
            select id,label,value from sys_dict_item where dict_type='project_status' and is_deleted=0
        ) dict_status
        on p.project_status=dict_status.`value`
        left join (
            select id,label,value from sys_dict_item where dict_type='project_stage' and is_deleted=0
        ) dict_stage
        on p.project_stage=dict_stage.`value`
        where p.is_deleted=0
    </sql>
 
</mapper>