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
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
<?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.ProjectDailyMapperCustom">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.cloudroam.bo.ProjectDailyBO">
        <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_id" property="projectId" />
        <result column="project_name" property="projectName" />
        <result column="task_id" property="taskId" />
        <result column="task_desc" property="taskDesc" />
        <result column="begin_date" property="beginDate" />
        <result column="end_date" property="endDate" />
        <result column="task_name" property="taskName" />
        <result column="daily_type" property="dailyType" />
        <result column="daily_content" property="dailyContent" />
        <result column="daily_status" property="dailyStatus" />
        <result column="daily_date" property="dailyDate" />
 
 
        <result column="supplementary_flag" property="supplementaryFlag" />
 
        <result column="is_commit" property="isCommit" />
        <result column="commit_user_id" property="commitUserId" />
        <result column="commit_user_name" property="commitUserName" />
        <result column="commit_time" property="commitTime" />
 
        <result column="is_confirm" property="isConfirm" />
        <result column="confirm_user_id" property="confirmUserId" />
        <result column="confirm_user_name" property="confirmUserName" />
        <result column="confirm_time" property="confirmTime" />
        <result column="confirm_content" property="confirmContent" />
 
 
        <result column="estimated_hours" property="estimatedHours" />
        <result column="actual_hours" property="actualHours" />
        <result column="remark" property="remark" />
        <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="daily_process_meeting_id" property="dailyProcessMeetingId" />
        <result column="daily_process_state" property="dailyProcessState" />
        <result column="daily_process_remark" property="dailyProcessRemark" />
        <result column="daily_process_user_name" property="dailyProcessUserName" />
        <result column="daily_process_user_id" property="dailyProcessUserId" />
        <result column="daily_process_time" property="dailyProcessTime" />
 
        <result column="daily_process_percent" property="dailyProcessPercent" />
 
 
        <result column="project_name2" property="projectName2" />
        <result column="daily_status_name" property="dailyStatusName" />
        <result column="daily_type_name" property="dailyTypeName" />
        <result column="daily_commit_name" property="dailyCommitName" />
        <result column="daily_confirm_name" property="dailyConfirmName" />
 
 
 
 
    </resultMap>
    <insert id="insertBatch">
 
        insert into project_daily(
            id,
            tenant_id,
            project_id,
            project_name,
            task_id,
            task_desc,
            begin_date,
            end_date,
            task_name,
            daily_type,
            daily_content,
            daily_status,
            daily_date,
            supplementary_flag,
            is_commit,
            commit_user_id,
            commit_user_name,
            commit_time,
            is_confirm,
            confirm_user_id,
            confirm_user_name,
            confirm_time,
            confirm_content,
            estimated_hours,
            actual_hours,
            remark,
            create_user_id,
            create_user_name,
            create_time,
            update_user_id,
            update_user_name,
            update_time,
            is_deleted,
            delete_user_id,
            delete_user_name,
            delete_time
        )
        values
        <foreach collection="list" item="item" index="index" separator=",">
            (
            #{item.id},
            #{item.tenantId},
            #{item.projectId},
            #{item.projectName},
            #{item.taskId},
            #{item.taskDesc},
            #{item.beginDate},
            #{item.endDate},
            #{item.taskName},
            #{item.dailyType},
            #{item.dailyContent},
            #{item.dailyStatus},
            #{item.dailyDate},
 
            #{item.supplementaryFlag},
 
            #{item.isCommit},
            #{item.commitUserId},
            #{item.commitUserName},
            #{item.commitTime},
 
            #{item.isConfirm},
            #{item.confirmUserId},
            #{item.confirmUserName},
            #{item.confirmTime},
 
            #{item.confirmContent},
 
            #{item.estimatedHours},
            #{item.actualHours},
            #{item.remark},
            #{item.createUserId},
            #{item.createUserName},
            #{item.createTime},
            #{item.updateUserId},
            #{item.updateUserName},
            #{item.updateTime},
            #{item.isDeleted},
            #{item.deleteUserId},
            #{item.deleteUserName},
            #{item.deleteTime}
            )
        </foreach>
 
    </insert>
<!--    <update id="deleteDailysByDateUser">-->
<!--        update project_daily set is_deleted=1 where  create_user_id= #{createUserId} and daily_date= #{dailyDate}-->
<!--    </update>-->
 
    <delete id="deleteDailysByDateUser">
        delete from  project_daily  where  create_user_id= #{createUserId} and daily_date= #{dailyDate}
    </delete>
 
 
    <select id="selectProjectDailyPage" resultType="com.cloudroam.bo.ProjectDailyBO">
        <include refid="selectSql" />
        where t.is_deleted=0
        <if test=" dailyDate !=null and dailyDate !='' ">
            and t.daily_date= #{dailyDate}
        </if>
 
        <if test=" projectId !=null and projectId !='' ">
            and t.project_id= #{projectId}
        </if>
 
        <if test=" createUserId !=null and createUserId !='' ">
            and t.create_user_id= #{createUserId}
        </if>
 
        <if test=" keyword !=null and keyword !='' ">
            and (
            t.daily_content like concat('%',#{keyword},'%')
            or t.remark like concat('%',#{keyword},'%')
            )
        </if>
 
        <if test=" dailyType !=null and dailyType !='' ">
            and t.daily_type= #{dailyType}
        </if>
        <if test=" dailyStatus !=null and dailyStatus !='' ">
            and t.daily_status= #{dailyStatus}
        </if>
 
        <if test=" isCommit !=null  ">
            and t.is_commit= #{isCommit}
        </if>
 
        <if test=" isConfirm !=null ">
            and t.is_confirm= #{isConfirm}
        </if>
        order by t.daily_date desc ,t.create_user_id,t.project_id,t.create_time
 
    </select>
    <select id="selectProjectDailyList" resultType="com.cloudroam.bo.ProjectDailyBO">
 
        <include refid="selectSql" />
        <include refid="whereCauseProjectDaily" />
        order by t.daily_date desc ,t.create_user_id,t.project_id,t.create_time
 
    </select>
 
 
 
    <sql id="selectSql">
        select t.* from (
            select d.* ,
                   i.project_name as project_name2,
                   pm.module_name as module_name2,
                   pt.`name` as task_name2,
                   pt.description as task_desc2,
                   pt.plan_begin_date as task_plan_begin_date,
                   pt.plan_end_date as task_plan_end_date,
                   daily_status.label as daily_status_name,
                   daily_type.label as daily_type_name,
                   daily_commit.label as daily_commit_name,
                   daily_confirm.label as daily_confirm_name,
                   daily_process_state.label as daily_process_state_name
 
            from project_daily d
            left join project_info i
            on d.project_id = i.id
            left join project_module pm
            on d.module_id=pm.id
            left join project_task pt
            on d.task_id =pt.id
            left join (
                select id,label,value from sys_dict_item where dict_type='daily_status' and is_deleted=0
            ) daily_status
            on d.daily_status=daily_status.`value`
            left join (
                select id,label,value from sys_dict_item where dict_type='daily_type' and is_deleted=0
            ) daily_type
            on d.daily_type=daily_type.`value`
            left join (
                select id,label,value from sys_dict_item where dict_type='daily_commit' and is_deleted=0
            ) daily_commit
            on d.is_commit=daily_commit.`value`
            left join (
                select id,label,value from sys_dict_item where dict_type='daily_confirm' and is_deleted=0
            ) daily_confirm
            on d.is_confirm=daily_confirm.`value`
            left join (
                select id,label,value from sys_dict_item where dict_type='daily_process_state' and is_deleted=0
            ) daily_process_state
            on d.daily_process_state=daily_process_state.`value`
        )t
    </sql>
 
    <sql id="whereCauseProjectDaily">
        where t.is_deleted=0
        <if test=" startDate !=null and startDate !='' ">
            and t.daily_date &gt;= #{startDate}
        </if>
 
        <if test=" endDate !=null and endDate !='' ">
            and t.daily_date &lt;= #{endDate}
        </if>
 
        <if test=" dailyDate !=null and dailyDate !='' ">
            and t.daily_date= #{dailyDate}
        </if>
 
        <if test=" projectId !=null and projectId !='' ">
            and t.project_id= #{projectId}
        </if>
 
        <if test=" createUserId !=null and createUserId !='' ">
            and t.create_user_id= #{createUserId}
        </if>
 
    </sql>
    <sql id="whereCause">
        where t.is_deleted=0
        <if test=" startDate !=null and startDate !='' ">
            and t.daily_date &gt;= #{startDate}
        </if>
 
        <if test=" endDate !=null and endDate !='' ">
            and t.daily_date &lt;= #{endDate}
        </if>
 
        <if test=" dailyDate !=null and dailyDate !='' ">
            and t.daily_date= #{dailyDate}
        </if>
 
        <if test=" projectId !=null and projectId !='' ">
            and t.project_id= #{projectId}
        </if>
 
        <if test=" createUserId !=null and createUserId !='' ">
            and t.create_user_id= #{createUserId}
        </if>
 
        <if test=" keyword !=null and keyword !='' ">
            and (
            t.daily_content like concat('%',#{keyword},'%')
            or t.remark like concat('%',#{keyword},'%')
            )
        </if>
 
        <if test=" dailyType !=null and dailyType !='' ">
            and t.daily_type= #{dailyType}
        </if>
        <if test=" dailyStatus !=null and dailyStatus !='' ">
            and t.daily_status= #{dailyStatus}
        </if>
 
        <if test=" isCommit !=null  ">
            and t.is_commit= #{isCommit}
        </if>
 
        <if test=" isConfirm !=null ">
            and t.is_confirm= #{isConfirm}
        </if>
    </sql>
 
 
    <select id="getYesterdayUncommittedProjectDailys" resultType="com.cloudroam.bo.ProjectDailyBO">
        select t.* from (
            select d.* ,
                   i.project_name as project_name2,
                   daily_status.label as daily_status_name,
                   daily_type.label as daily_type_name,
                   daily_commit.label as daily_commit_name,
                   daily_confirm.label as daily_confirm_name
 
            from project_daily d
            left join project_info i
            on d.project_id = i.id
 
            left join (
                select id,label,value from sys_dict_item where dict_type='daily_status' and is_deleted=0
            ) daily_status
            on d.daily_status=daily_status.`value`
            left join (
                select id,label,value from sys_dict_item where dict_type='daily_type' and is_deleted=0
            ) daily_type
            on d.daily_type=daily_type.`value`
            left join (
                select id,label,value from sys_dict_item where dict_type='daily_commit' and is_deleted=0
            ) daily_commit
            on d.is_commit=daily_commit.`value`
            left join (
                select id,label,value from sys_dict_item where dict_type='daily_confirm' and is_deleted=0
            ) daily_confirm
            on d.is_confirm=daily_confirm.`value`
 
        )t
 
        where t.is_deleted=0
        and t.daily_date=DATE_SUB(CURRENT_DATE, INTERVAL 1 DAY)
        and t.is_commit=0
        and t.create_user_id=#{createUserId}
 
    </select>
 
    <select id="getYesterdayUnconfirmedProjectDailys" resultType="com.cloudroam.bo.ProjectDailyBO">
        select t.* from (
            select d.* ,
                   i.project_name as project_name2,
                   daily_status.label as daily_status_name,
                   daily_type.label as daily_type_name,
                   daily_commit.label as daily_commit_name,
                   daily_confirm.label as daily_confirm_name
 
            from project_daily d
            left join project_info i
            on d.project_id = i.id
 
            left join (
                select id,label,value from sys_dict_item where dict_type='daily_status' and is_deleted=0
            ) daily_status
            on d.daily_status=daily_status.`value`
            left join (
                select id,label,value from sys_dict_item where dict_type='daily_type' and is_deleted=0
            ) daily_type
            on d.daily_type=daily_type.`value`
            left join (
                select id,label,value from sys_dict_item where dict_type='daily_commit' and is_deleted=0
            ) daily_commit
            on d.is_commit=daily_commit.`value`
            left join (
                select id,label,value from sys_dict_item where dict_type='daily_confirm' and is_deleted=0
            ) daily_confirm
            on d.is_confirm=daily_confirm.`value`
 
        )t
 
        where t.is_deleted=0
        and t.daily_date=DATE_SUB(CURRENT_DATE, INTERVAL 1 DAY)
        and t.is_confirm=0
        and t.create_user_id=#{createUserId}
    </select>
 
    <select id="getTodayNoDailyPeoples" resultType="com.cloudroam.model.UserDO">
        select u.* from lin_user u
        where u.id not in (
            select create_user_id from project_daily where daily_date=CURRENT_DATE and is_deleted=0 group by create_user_id
        )
        and u.id !=1
        and u.is_deleted=0
    </select>
 
    <select id="getYesterdayUncommittedProjectDailysPeoples" resultType="com.cloudroam.model.UserDO">
        select * from lin_user u where u.id in(
            select create_user_id from project_daily d
            where d.is_deleted=0
              and d.daily_date=DATE_SUB(CURRENT_DATE, INTERVAL 1 DAY)
              and d.is_commit=0
        )
        and u.is_deleted=0
 
    </select>
 
    <select id="getYesterdayUncomfirmedProjectDailysPeoples" resultType="com.cloudroam.model.UserDO">
        select * from lin_user u where u.id in(
            select create_user_id from project_daily d
            where d.is_deleted=0
              and d.daily_date=DATE_SUB(CURRENT_DATE, INTERVAL 1 DAY)
              and d.is_confirm=0
 
        )
        and u.is_deleted=0
    </select>
    <select id="getActualHoursStatistic" resultType="com.cloudroam.bo.ProjectStatisticsBO">
        select
            project_id,sum(actual_hours) as actual_hours,sum(estimated_hours) as estimated_hours
        from project_daily d
        where d.is_deleted=0
--           and d.is_confirm=1
          and d.daily_status != 3
          and project_id=#{projectId}
        group by project_id
    </select>
    <select id="getToadyUncomfirmedActualHoursProjectDailysPeoples" resultType="com.cloudroam.model.UserDO">
 
        select * from lin_user where id in(
            select create_user_id
            from project_daily d
            where d.is_deleted=0
              and d.is_commit=1
              and d.is_confirm=1
              and d.actual_hours=0
              and d.daily_status!='3'
            <if test=" dailyDate !=null and dailyDate !='' ">
                and d.daily_date= #{dailyDate}
            </if>
        )
 
 
    </select>
 
    <select id="getTodayUnConfirmedActualHours" resultType="com.cloudroam.bo.ProjectDailyBO">
 
        select t.* from (
                            select d.* ,
                                   i.project_name as project_name2,
                                   daily_status.label as daily_status_name,
                                   daily_type.label as daily_type_name,
                                   daily_commit.label as daily_commit_name,
                                   daily_confirm.label as daily_confirm_name
 
                            from project_daily d
                                     left join project_info i
                                               on d.project_id = i.id
 
                                     left join (
                                select id,label,value from sys_dict_item where dict_type='daily_status' and is_deleted=0
                            ) daily_status
                                               on d.daily_status=daily_status.`value`
                                     left join (
                                select id,label,value from sys_dict_item where dict_type='daily_type' and is_deleted=0
                            ) daily_type
                                               on d.daily_type=daily_type.`value`
                                     left join (
                                select id,label,value from sys_dict_item where dict_type='daily_commit' and is_deleted=0
                            ) daily_commit
                                               on d.is_commit=daily_commit.`value`
                                     left join (
                                select id,label,value from sys_dict_item where dict_type='daily_confirm' and is_deleted=0
                            ) daily_confirm
                                               on d.is_confirm=daily_confirm.`value`
 
                        )t
 
        where t.is_deleted=0
        and t.is_commit=1
        and t.is_confirm=1
        and t.daily_status!='3'
        and t.daily_date=#{dailyDate}
        and t.create_user_id=#{createUserId}
    </select>
    <select id="getUnComfirmedPeoples" resultType="com.cloudroam.model.UserDO">
 
        SELECT
            *
        FROM
            lin_user u
        WHERE
                u.id IN (
                SELECT
                    create_user_id
                FROM
                    project_daily d
                WHERE
                    d.is_deleted = 0
                  AND d.is_confirm = 0
                  AND d.daily_date = #{dailyDate}
            )
          and u.is_deleted=0
    </select>
    <select id="getTodayUncommittedProjectDailysPeoples" resultType="com.cloudroam.model.UserDO">
        select * from lin_user u where u.id in(
            select create_user_id from project_daily d
            where d.is_deleted=0
              and d.daily_date=CURDATE()
              and d.is_commit=0
        )
        and u.is_deleted=0
 
 
 
    </select>
    <select id="getTodayUncommittedProjectDailys" resultType="com.cloudroam.bo.ProjectDailyBO">
        select t.* from (
                            select d.* ,
                                   i.project_name as project_name2,
                                   daily_status.label as daily_status_name,
                                   daily_type.label as daily_type_name,
                                   daily_commit.label as daily_commit_name,
                                   daily_confirm.label as daily_confirm_name
 
                            from project_daily d
                                     left join project_info i
                                               on d.project_id = i.id
 
                                     left join (
                                select id,label,value from sys_dict_item where dict_type='daily_status' and is_deleted=0
                            ) daily_status
                                               on d.daily_status=daily_status.`value`
                                     left join (
                                select id,label,value from sys_dict_item where dict_type='daily_type' and is_deleted=0
                            ) daily_type
                                               on d.daily_type=daily_type.`value`
                                     left join (
                                select id,label,value from sys_dict_item where dict_type='daily_commit' and is_deleted=0
                            ) daily_commit
                                               on d.is_commit=daily_commit.`value`
                                     left join (
                                select id,label,value from sys_dict_item where dict_type='daily_confirm' and is_deleted=0
                            ) daily_confirm
                                               on d.is_confirm=daily_confirm.`value`
 
                        ) t
 
        where t.is_deleted=0
          and t.daily_date=CURDATE()
          and t.is_commit=0
          and t.create_user_id=#{createUserId}
    </select>
 
    <select id="getDailyDatePlanTime" resultType="java.lang.Double">
        select sum(estimated_hours) from project_daily d where d.is_deleted=0 and d.create_user_id=#{createUserId} and d.daily_date=#{dailyDate}
    </select>
    <select id="getDailyDateActualTime" resultType="java.lang.Double">
        select sum(actual_hours) from project_daily d where d.is_deleted=0 and d.create_user_id=#{createUserId} and d.daily_date=#{dailyDate}
    </select>
 
    <select id="existsHoursWithoutIds" resultType="com.cloudroam.vo.projectDaily.ProjectDailyHourVO">
        SELECT
        t.*
        FROM
        (
        SELECT
        d.create_user_id,
        sum(d.actual_hours) as actual_hours,
        sum(d.estimated_hours ) as estimated_hours
        FROM
        project_daily d
        WHERE
        d.is_deleted = 0
        AND d.create_user_id = #{createUserId}
        AND d.daily_date = #{dailyDate}
        <if test="idList != null and idList.size() > 0">
            AND d.id NOT IN
            <foreach collection="idList" item="id" open="(" separator="," close=")">
                #{id}
            </foreach>
        </if>
        ) t
        LIMIT 1
    </select>
 
 
    <select id="getActualHourStatistics" resultType="com.cloudroam.vo.projectDaily.ProjectDailyStatisticsVO">
        select info.project_name,p.project_id,date_format(p.daily_date,'%Y-%m') as year_mon , sum(p.actual_hours) as actual_hours ,sum(p.estimated_hours) as estimated_hours
        from project_daily p
                 left join project_info info
                           on p.project_id=info.id
        where p.is_deleted=0
--           and p.is_confirm=1
          and p.daily_status != 3
        group by project_id, year_mon,project_name
    </select>
    <select id="getEvaluateiActualHourStatistics"
            resultType="com.cloudroam.vo.projectDaily.ProjectDailyStatisticsVO">
        <if test=" type !=null and type =='month' ">
            select info.project_name,p.project_id,date_format(p.daily_date,'%Y-%m') as year_mon , sum(p.actual_hours) as actual_hours ,sum(p.estimated_hours) as estimated_hours
        </if>
        <if test=" type !=null and type =='day' ">
            select info.project_name,p.project_id,date_format(p.daily_date,'%Y-%m-%d') as year_mon , sum(p.actual_hours) as actual_hours ,sum(p.estimated_hours) as estimated_hours
        </if>
        from project_daily p
        left join project_info info
        on p.project_id=info.id
        where p.is_deleted=0 and p.daily_status != 3
        <if test=" projectId !=null and projectId !='' ">
            and p.project_id= #{projectId}
        </if>
        <if test=" startDate !=null and startDate !='' ">
            and DATE_FORMAT(p.daily_date,'%Y-%m-%d') &gt;= #{startDate}
        </if>
        <if test=" endDate !=null and endDate !='' ">
            and DATE_FORMAT(p.daily_date,'%Y-%m-%d') &lt;= #{endDate}
        </if>
 
        <if test=" confirmState !=null and confirmState !='' ">
            and p.is_confirm = #{confirmState}
        </if>
        <if test=" createUserId !=null and createUserId !='' ">
            and p.create_user_id = #{createUserId}
        </if>
        group by project_id, year_mon,project_name
        order by project_id,year_mon
 
    </select>
 
    <select id="getUserActualHourStatistics"
            resultType="com.cloudroam.vo.projectDaily.ProjectDailyStatisticsVO">
 
        select * from (
        select ym.year_mon,ym.create_user_id,ym.project_id,s.project_name,u.nickname as user_name,ifnull(s.actual_hours,0) as actual_hours,ifnull(s.estimated_hours,0) as estimated_hours,u.show_board_flag from (
        SELECT year_mon, project_id,u.id AS create_user_id
        FROM (
        <if test=" type !=null and type =='month' ">
            SELECT date_format( p.daily_date, '%Y-%m' ) AS year_mon,project_id
        </if>
        <if test=" type !=null and type =='day' ">
            SELECT date_format( p.daily_date, '%Y-%m-%d' ) AS year_mon,project_id
        </if>
        FROM project_daily p
        <include refid="projectDailyCause"></include>
        GROUP BY year_mon, id
        ) t,lin_user u
        GROUP BY year_mon,project_id,create_user_id
        )ym
        left join(
        <if test=" type !=null and type =='month' ">
            SELECT info.project_name, p.project_id,p.create_user_id,date_format( p.daily_date, '%Y-%m' ) AS year_mon,sum( p.actual_hours ) AS actual_hours,sum( p.estimated_hours ) AS estimated_hours
        </if>
        <if test=" type !=null and type =='day' ">
            SELECT info.project_name, p.project_id,p.create_user_id,date_format( p.daily_date, '%Y-%m-%d' ) AS year_mon,sum( p.actual_hours ) AS actual_hours,sum( p.estimated_hours ) AS estimated_hours
        </if>
        FROM project_daily p
        LEFT JOIN project_info info ON p.project_id = info.id
        <include refid="projectDailyCause"></include>
        GROUP BY project_id,year_mon,project_name,create_user_id
        )s
        on ym.year_mon=s.year_mon and ym.create_user_id=s.create_user_id and ym.project_id=s.project_id
        left join lin_user u on u.id=ym.create_user_id
        ) t
        where show_board_flag=1
        <if test=" createUserId !=null and createUserId !='' ">
            and create_user_id = #{createUserId}
        </if>
        order by project_id,create_user_id,year_mon
    </select>
 
 
 
    <select id="getRoleHourStatistics" resultType="com.cloudroam.vo.projectDaily.ProjectDailyStatisticsVO">
 
        select ym.year_mon,ym.project_id,ym.group_id,s.project_name,s.actual_hours,s.estimated_hours,g.name as group_name
        from (
        SELECT year_mon,project_id,g.id AS group_id
        FROM(
        <if test=" type !=null and type =='month' ">
            SELECT date_format( p.daily_date, '%Y-%m' ) AS year_mon,project_id
        </if>
        <if test=" type !=null and type =='day' ">
            SELECT date_format( p.daily_date, '%Y-%m-%d' ) AS year_mon,project_id
        </if>
        FROM project_daily p
        <include refid="projectDailyCause"></include>
        GROUP BY year_mon, id
        ) t,lin_group g
        GROUP BY year_mon,project_id,group_id
        )ym
        left join (
        <if test=" type !=null and type =='month' ">
            SELECT info.project_name,p.project_id,g.id AS group_id,g.NAME AS group_name,date_format( p.daily_date, '%Y-%m' ) AS year_mon,sum( p.actual_hours ) AS actual_hours,sum( p.estimated_hours ) AS estimated_hours
        </if>
        <if test=" type !=null and type =='day' ">
            SELECT info.project_name,p.project_id,g.id AS group_id,g.NAME AS group_name,date_format( p.daily_date, '%Y-%m-%d' ) AS year_mon,sum( p.actual_hours ) AS actual_hours,sum( p.estimated_hours ) AS estimated_hours
        </if>
 
        FROM project_daily p
        LEFT JOIN project_info info ON p.project_id = info.id
        LEFT JOIN lin_user u ON u.id = p.create_user_id
        LEFT JOIN lin_user_group ug ON u.id = ug.user_id
        LEFT JOIN lin_group g ON ug.group_id = g.id
        <include refid="projectDailyCause"></include>
        GROUP BY project_id,  year_mon, project_name,group_id, group_name
        )s
        on ym.year_mon=s.year_mon and ym.project_id=s.project_id and ym.group_id=s.group_id
        LEFT JOIN lin_group g ON ym.group_id = g.id
        where 1=1
        <if test=" createUserId !=null and createUserId !='' ">
            and ym.group_id in (
            select group_id from lin_user_group where user_id=#{createUserId}
            )
        </if>
 
 
        order by group_id,year_mon
    </select>
 
<!--    提取会议人员日志记录-->
    <select id="selectProjectDailyProcessList" resultType="com.cloudroam.bo.ProjectDailyBO">
 
        select * from (
            <include refid="selectSql"/>
            where daily_date in (#{dailyDate},DATE_SUB(#{dailyDate},INTERVAL 1 DAY))
            union
            <include refid="selectSql"/>
            where daily_date &gt;= DATE_SUB(#{dailyDate},INTERVAL 1 Week) and daily_date&lt;=#{dailyDate}
            and daily_process_state is null
            <if test=" meetingId !=null and meetingId!='' ">
                union
                <include refid="selectSql"/>
                where daily_process_meeting_id=#{meetingId}
            </if>
 
        )t3
        where t3.is_deleted=0
        <if test=" createUserId !=null and createUserId !='' ">
            and t3.create_user_id = #{createUserId}
        </if>
 
 
        order by daily_date
    </select>
    <select id="selectProjectDailyProcessWithMeetingIdList" resultType="com.cloudroam.bo.ProjectDailyBO">
        select * from (
            <include refid="selectSql"/>
            where 1=1
            <if test=" meetingId !=null and meetingId !='' ">
                and daily_process_meeting_id=#{meetingId}
            </if>
            <if test=" dailyDate !=null and dailyDate !='' ">
                and daily_date= #{dailyDate}
            </if>
 
        )t3
        where t3.is_deleted=0
        <if test=" createUserId !=null and createUserId !='' ">
            and t3.create_user_id = #{createUserId}
        </if>
 
        order by daily_date
    </select>
    <select id="getDailyDateByMeetingId" resultType="java.lang.String">
        select distinct DATE_FORMAT(meeting_date,'%Y-%m-%d') meeting_date from (
           select meeting_date from meeting  where id =#{meetingId}
           union
           select DATE_SUB(meeting_date, INTERVAL 1 DAY) as meeting_date from meeting  where id =#{meetingId}
           union
           select daily_date as meeting_date from project_daily where daily_process_meeting_id=#{meetingId}
        ) t
        order by meeting_date desc
    </select>
    <select id="selectProjectDailyTaskPage" resultType="com.cloudroam.bo.ProjectDailyBO">
        <include refid="selectSql" />
        where t.is_deleted=0
        <if test=" dto.dailyDate !=null and dto.dailyDate !='' ">
            and t.daily_date= #{dto.dailyDate}
        </if>
 
        <if test=" dto.projectId !=null and dto.projectId !='' ">
            and t.project_id= #{dto.projectId}
        </if>
 
        <if test=" dto.createUserId !=null and dto.createUserId !='' ">
            and t.create_user_id= #{dto.createUserId}
        </if>
 
        <if test=" dto.keyword !=null and dto.keyword !='' ">
            and (
                t.daily_content like concat('%',#{dto.keyword},'%')
                or t.remark like concat('%',#{dto.keyword},'%')
                or t.task_name2 like concat('%',#{dto.keyword},'%')
                or t.task_desc2 like concat('%',#{dto.keyword},'%')
            )
        </if>
 
        <if test=" dto.dailyType !=null and dto.dailyType !='' ">
            and t.daily_type= #{dto.dailyType}
        </if>
        <if test=" dto.dailyStatus !=null and dto.dailyStatus !='' ">
            and t.daily_status= #{dto.dailyStatus}
        </if>
 
        <if test=" dto.isCommit !=null  ">
            and t.is_commit= #{dto.isCommit}
        </if>
 
        <if test=" dto.isConfirm !=null ">
            and t.is_confirm= #{dto.isConfirm}
        </if>
 
        <if test="dto.moduleIds != null and dto.moduleIds.size() > 0 ">
            AND t.module_id IN
            <foreach collection="dto.moduleIds" item="moduleId" index="index" open="(" close=")" separator=",">
                #{moduleId}
            </foreach>
        </if>
 
        order by t.daily_date desc ,t.create_user_id,t.project_id,t.create_time
    </select>
    <select id="getProjectDailyTaskInfo" resultType="com.cloudroam.dto.projectTask.QueryTaskDailyDTO">
        SELECT
            min( d.daily_date ) as minStartTime,
            max( d.daily_date ) as maxEndTime,
            sum( d.actual_hours ) as actualHours
        FROM
            project_daily d
        WHERE
            d.is_deleted = 0
        <if test=" taskId !=null and taskId !='' ">
          AND d.task_id =#{taskId}
        </if>
        <if test=" userId !=null and userId !='' ">
          and d.create_user_id =#{userId}
        </if>
    </select>
 
    <sql id="projectDailyCause">
        WHERE p.is_deleted = 0
        AND p.daily_status != 3
        <if test=" projectId !=null and projectId !='' ">
            and p.project_id= #{projectId}
        </if>
        <if test=" startDate !=null and startDate !='' ">
            and DATE_FORMAT(p.daily_date,'%Y-%m-%d') &gt;= #{startDate}
        </if>
        <if test=" endDate !=null and endDate !='' ">
            and DATE_FORMAT(p.daily_date,'%Y-%m-%d') &lt;= #{endDate}
        </if>
 
        <if test=" confirmState !=null and confirmState !='' ">
            and p.is_confirm = #{confirmState}
        </if>
        <if test=" createUserId !=null and createUserId !='' ">
            and p.create_user_id = #{createUserId}
        </if>
    </sql>
 
 
 
</mapper>