liuxiaolong
2019-05-06 f99bc8c6a1d10610373738edd7d0aa0181c81d99
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
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
<?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.cloud.user.dao.BbEmployeeDao" >
 
    <sql id="table"> bb_person_base </sql>
    <sql id="temp_person_table"> bb_person_temporary </sql>  <!--wp 添加-->
 
    <resultMap id="beanMap" type="Map">
        <id column="id" property="id" />                                      <!--id-->
        <result column="orgId" property="orgId"/>                             <!--组织架构Id-->
        <result column="officeId" property="officeId"/>                       <!--部门Id-->
        <result column="no" property="no"/>                                   <!--工卡、学生校徽等卡片编号-->
        <result column="cardId" property="cardId"/>                           <!--身份证号-->
        <result column="userId" property="userId"/>                           <!--用户id-->
        <result column="userName" property="userName"/>                       <!--用户名冗余-->
        <result column="name" property="name"/>                               <!--姓名-->
        <result column="gender" property="gender"/>                           <!--性别-->
        <result column="mnemonicCode" property="mnemonicCode"/>               <!--助记码-->
        <result column="nation" property="nation"/>                           <!--民族-->
        <result column="phone" property="phone"/>                             <!--电话-->
        <result column="type" property="type"/>                               <!--人员类型(学生、职工、校外)-->
        <result column="registerAddress" property="registerAddress"/>         <!--注册地址-->
        <result column="distributionIds" property="distributionIds"/>         <!--分布节点IDs-->
        <result column="distributionNames" property="distributionNames"/>     <!--分布节点Names-->
        <result column="photos" property="photos"/>                           <!--人员照片(格式-->
        <result column="faceIds" property="faceIds"/>                         <!--人脸Id(格式-->
        <result column="createBy" property="createBy"/>                       <!--创建者-->
        <result column="createTime" property="createTime"/>                   <!--创建时间-->
        <result column="updateBy" property="updateBy"/>                       <!--更新者-->
        <result column="updateTime" property="updateTime"/>                   <!--更新时间-->
        <result column="remarks" property="remarks"/>                         <!--备注信息-->
        <result column="delFlag" property="delFlag"/>                         <!--逻辑删除标记(0-->
        <result column="rev_json1" property="revJson1"/>                      <!--预留json格式字段1-->
        <result column="officeName" property="officeName"/>                   <!--部门Name-->
    </resultMap>
 
    <!--学生Map集合-->
    <resultMap id="stuMap" type="com.cloud.model.sys.BbEmployee">
        <id column="id" property="id" />                                      <!--id-->
        <result column="orgId" property="orgId"/>                             <!--组织架构Id-->
        <result column="officeId" property="officeId"/>                       <!--部门Id-->
        <result column="no" property="no"/>                                   <!--工卡、学生校徽等卡片编号-->
        <result column="name" property="name"/>                               <!--姓名-->
        <result column="gender" property="gender"/>                           <!--性别-->
        <result column="photos" property="photos"/>                           <!--人员照片(格式-->
        <result column="remarks" property="remarks"/>
    </resultMap>
 
    <insert id="add" parameterType="com.cloud.model.sys.BbEmployee" useGeneratedKeys="true" keyProperty="id">
        insert into <include refid="table" />
        (
        id                  , <!--id-->
        orgId               , <!--组织架构Id-->
        officeId            , <!--部门Id-->
        no                  , <!--工卡、学生校徽等卡片编号-->
        cardId              , <!--身份证号-->
        userId              , <!--用户id-->
        userName            , <!--用户名冗余-->
        name                , <!--姓名-->
        mnemonicCode        , <!--助记码-->
        gender              , <!--性别-->
        nation              , <!--民族-->
        phone               , <!--电话-->
        type                , <!--人员类型(学生、职工、校外)-->
        compactType         , <!--教师合同类型-->
        registerAddress     , <!--注册地址-->
        distributionIds     , <!--分布节点IDs-->
        distributionNames   , <!--分布节点Names-->
        photos              , <!--人员照片(格式-->
        faceIds             , <!--人脸Id(格式-->
        createBy            , <!--创建者-->
        createTime          , <!--创建时间-->
        updateBy            , <!--更新者-->
        updateTime          , <!--更新时间-->
        remarks             , <!--备注信息-->
        delFlag             , <!--逻辑删除标记(0-->
        rev_json1             <!--预留json格式字段1-->
        )
        values
        (
        #{id}               , <!--id-->
        #{orgId}            , <!--组织架构Id-->
        #{officeId}         , <!--部门Id-->
        #{no,jdbcType=VARCHAR}               ,<!--工卡、学生校徽等卡片编号-->
        #{cardId}           , <!--身份证号-->
        #{userId}           , <!--用户id-->
        #{userName}         , <!--用户名冗余-->
        #{name}             , <!--姓名-->
        #{mnemonicCode}        , <!--助记码-->
        #{gender}           , <!--性别-->
        #{nation}           , <!--民族-->
        #{phone}            , <!--电话-->
        #{type}             , <!--人员类型(学生、职工、校外)-->
        #{compactType,jdbcType=VARCHAR}        ,<!--教师合同类型-->
        #{registerAddress}  , <!--注册地址-->
        #{distributionIds}  , <!--分布节点IDs-->
        #{distributionNames}, <!--分布节点Names-->
        #{photos}           , <!--人员照片(格式-->
        #{faceIds}          , <!--人脸Id(格式-->
        #{createBy}         , <!--创建者-->
        #{createTime}       , <!--创建时间-->
        #{updateBy}         , <!--更新者-->
        #{updateTime}       , <!--更新时间-->
        #{remarks}          , <!--备注信息-->
        #{delFlag}          , <!--逻辑删除标记(0-->
        #{revJson1}           <!--预留json格式字段1-->
        )
    </insert>
 
    <insert id="addVisitor" parameterType="com.cloud.model.sys.BbEmployee" keyProperty="id" useGeneratedKeys="true">
        insert into <include refid="table" />
        (
        id                  , <!--id-->
        orgId               , <!--组织架构Id-->
        officeId            , <!--部门Id-->
        cardId              , <!--身份证号-->
        name                , <!--姓名-->
        mnemonicCode        , <!--助记码-->
        gender              , <!--性别-->
        nation              , <!--民族-->
        phone               , <!--电话-->
        type                , <!--人员类型(学生、职工、校外)-->
        registerAddress     , <!--注册地址-->
        distributionIds     , <!--分布节点IDs-->
        distributionNames   , <!--分布节点Names-->
        photos              , <!--人员照片(格式-->
        faceIds             , <!--人脸Id(格式-->
        createBy            , <!--创建者-->
        createTime          , <!--创建时间-->
        updateBy            , <!--更新者-->
        updateTime          , <!--更新时间-->
        remarks             , <!--备注信息-->
        delFlag             , <!--逻辑删除标记(0-->
        rev_json1             <!--预留json格式字段1-->
        )
        values
        (
        #{id}               , <!--id-->
        #{orgId}            , <!--组织架构Id-->
        #{officeId}         , <!--部门Id-->
        #{cardId}           , <!--身份证号-->
        #{name}             , <!--姓名-->
        #{mnemonicCode}        , <!--助记码-->
        #{gender}           , <!--性别-->
        #{nation}           , <!--民族-->
        #{phone}            , <!--电话-->
        #{type}             , <!--人员类型(学生、职工、校外)-->
        #{registerAddress}  , <!--注册地址-->
        #{distributionIds}  , <!--分布节点IDs-->
        #{distributionNames}, <!--分布节点Names-->
        #{photos}           , <!--人员照片(格式-->
        #{faceIds}          , <!--人脸Id(格式-->
        #{createBy}         , <!--创建者-->
        #{createTime}       , <!--创建时间-->
        #{updateBy}         , <!--更新者-->
        #{updateTime}       , <!--更新时间-->
        #{remarks}          , <!--备注信息-->
        #{delFlag}          , <!--逻辑删除标记(0-->
        #{revJson1}           <!--预留json格式字段1-->
        )
    </insert>
 
 
 
    <update id="update" parameterType="com.cloud.model.sys.BbEmployee">
        update
        <include refid="table" />
        set
        id                  = #{id}               , <!--id-->
        orgId               = #{orgId}            , <!--组织架构Id-->
        officeId            = #{officeId}         , <!--部门Id-->
        no                  = #{no}               ,<!--工卡、学生校徽等卡片编号-->
        cardId              = #{cardId}           , <!--身份证号-->
        userId              = #{userId}           , <!--用户id-->
        userName            = #{userName}         , <!--用户名-->
        name                = #{name}             , <!--姓名-->
        gender              = #{gender}           , <!--性别-->
        nation              = #{nation}           , <!--民族-->
        phone               = #{phone}            , <!--电话-->
        type                = #{type}             , <!--人员类型(学生、职工、校外)-->
        registerAddress     = #{registerAddress}  , <!--注册地址-->
        distributionIds     = #{distributionIds}  , <!--分布节点ID-->
        distributionNames   = #{distributionNames}, <!--分布节点Name-->
        photos              = #{photos}           , <!--人员照片(格式-->
        faceIds             = #{faceIds}          , <!--人脸Id(格式-->
        createBy            = #{createBy}         , <!--创建者-->
        createTime          = #{createTime}       , <!--创建时间-->
        updateBy            = #{updateBy}         , <!--更新者-->
        updateTime          = now()               , <!--更新时间-->
        remarks             = #{remarks}          , <!--备注信息-->
        delFlag             = #{delFlag}          , <!--逻辑删除标记(0-->
        rev_json1           = #{revJson1}           <!--预留json格式字段1-->
 
        <where>
            <if test="orgId != null and orgId != ''">
                and orgId = #{orgId}
            </if>
            <if test="id != null and id != ''">
                and id = #{id}
            </if>
        </where>
    </update>
 
    <update id="deleteById" parameterType="java.util.Map">
        update
        <include refid="table" />
        set
        delFlag = '1',
        updateTime = NOW()
        <where>
            <if test="orgId != null and orgId != ''">
                and orgId = #{orgId}
            </if>
            <if test="id != null and id != ''">
                and id = #{id}
            </if>
        </where>
    </update>
 
    <update id="deleteByIdFromTemp" parameterType="java.util.Map">
        update
        bb_person_temporary
        set
        delFlag = '1',
        updateTime = NOW()
        <where>
            id = #{id}
        </where>
    </update>
 
 
    <update id="deleteByIds" parameterType="java.util.Map">
        update
        <include refid="table" />
        set
        delFlag = '1'
        <where>
            <if test="orgId != null and orgId != ''">
                and orgId = #{orgId}
            </if>
            <if test="ids != null and ids != ''">
                and id in (${ids})
            </if>
        </where>
    </update>
 
    <update id="updateByPhone1" parameterType="com.cloud.model.sys.BbEmployee">
        update
        <include refid="table" />
        set
        orgId               = #{orgId}            , <!--组织架构Id-->
        officeId            = #{officeId}         , <!--部门Id-->
        no                  = #{no}               ,<!--工卡、学生校徽等卡片编号-->
        cardId              = #{cardId}           , <!--身份证号-->
        userId              = #{userId}           , <!--用户id-->
        userName            = #{userName}         , <!--用户Name-->
        name                = #{name}             , <!--姓名-->
        gender              = #{gender}           , <!--性别-->
        nation              = #{nation}           , <!--民族-->
        type                = #{type}             , <!--人员类型(学生、职工、校外)-->
        compactType         = #{compactType}      ,<!--教师合同类型-->
        registerAddress     = #{registerAddress}  , <!--注册地址-->
        distributionIds     = #{distributionIds}  , <!--分布节点ID-->
        distributionNames   = #{distributionNames}, <!--分布节点Name-->
        photos              = #{photos}           , <!--人员照片(格式-->
        faceIds             = #{faceIds}          , <!--人脸Id(格式-->
        createBy            = #{createBy}         , <!--创建者-->
        createTime          = #{createTime}       , <!--创建时间-->
        updateBy            = #{updateBy}         , <!--更新者-->
        updateTime          = #{updateTime}       , <!--更新时间-->
        remarks             = #{remarks}          , <!--备注信息-->
        delFlag             = #{delFlag}          , <!--逻辑删除标记(0-->
        rev_json1           = #{revJson1}           <!--预留json格式字段1-->
 
        <where>
            <if test="orgId != null and orgId != ''">
                and orgId = #{orgId}
            </if>
            <if test="phone != null and phone != ''">
                and phone = #{phone}
            </if>
        </where>
    </update>
 
    <update id="updateByPhone" parameterType="com.cloud.model.sys.BbEmployee">
        update bb_employee
        <set>
            <if test="orgId != null">
                orgId = #{orgId,jdbcType=INTEGER},
            </if>
            <if test="no != null">
                no = #{no,jdbcType=VARCHAR},
            </if>
            <if test="officeId != null">
                officeId = #{officeId,jdbcType=INTEGER},
            </if>
            <if test="cardId != null">
                cardId = #{cardId,jdbcType=VARCHAR},
            </if>
            <if test="userId != null">
                userId = #{userId,jdbcType=INTEGER},
            </if>
            <if test="userName != null">
                userName = #{userName,jdbcType=VARCHAR},
            </if>
            <if test="name != null">
                name = #{name,jdbcType=VARCHAR},
            </if>
            <if test="mnemonicCode != null">
                mnemonicCode = #{mnemonicCode,jdbcType=VARCHAR},
            </if>
            <if test="gender != null">
                gender = #{gender,jdbcType=VARCHAR},
            </if>
            <if test="nation != null">
                nation = #{nation,jdbcType=VARCHAR},
            </if>
            <if test="type != null">
                type = #{type,jdbcType=VARCHAR},
            </if>
            <if test="compactType != null">
                compactType = #{compactType,jdbcType=VARCHAR},
            </if>
            <if test="registerAddress != null">
                registerAddress = #{registerAddress,jdbcType=VARCHAR},
            </if>
            <if test="distributionIds != null">
                distributionIds = #{distributionIds,jdbcType=VARCHAR},
            </if>
            <if test="distributionNames != null">
                distributionNames = #{distributionNames,jdbcType=VARCHAR},
            </if>
 
            photos = #{photos,jdbcType=VARCHAR},
 
 
            faceIds = #{faceIds,jdbcType=VARCHAR},
 
            <if test="createBy != null">
                createBy = #{createBy,jdbcType=VARCHAR},
            </if>
            <if test="createTime != null">
                createTime = #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="updateBy != null">
                updateBy = #{updateBy,jdbcType=VARCHAR},
            </if>
            <if test="updateTime != null">
                updateTime = #{updateTime,jdbcType=TIMESTAMP},
            </if>
            <if test="remarks != null">
                remarks = #{remarks,jdbcType=VARCHAR},
            </if>
            <if test="delFlag != null">
                delFlag = #{delFlag,jdbcType=VARCHAR},
            </if>
            <if test="revJson1 != null">
                rev_json1 = #{revJson1,jdbcType=CHAR},
            </if>
        </set>
        <where>
            <if test="orgId != null and orgId != ''">
                and orgId = #{orgId}
            </if>
            <if test="phone != null and phone != ''">
                and phone = #{phone}
            </if>
        </where>
    </update>
 
 
    <!--人员修改判空-->
    <update id="updateBbEmpId" parameterType="com.cloud.model.sys.BbEmployee">
        update bb_person_base
        <set>
            <if test="no != null">
                no = #{no,jdbcType=VARCHAR},
            </if>
            <if test="officeId != null">
                officeId = #{officeId,jdbcType=INTEGER},
            </if>
            <if test="cardId != null">
                cardId = #{cardId,jdbcType=VARCHAR},
            </if>
            <if test="userId != null">
                userId = #{userId,jdbcType=INTEGER},
            </if>
            <if test="userName != null">
                userName = #{userName,jdbcType=VARCHAR},
            </if>
            <if test="name != null">
                name = #{name,jdbcType=VARCHAR},
            </if>
            <if test="phone != null">
                phone = #{phone,jdbcType=VARCHAR},
            </if>
            <if test="mnemonicCode != null">
                mnemonicCode = #{mnemonicCode,jdbcType=VARCHAR},
            </if>
            <if test="gender != null">
                gender = #{gender,jdbcType=VARCHAR},
            </if>
            <if test="nation != null">
                nation = #{nation,jdbcType=VARCHAR},
            </if>
            <if test="type != null">
                type = #{type,jdbcType=VARCHAR},
            </if>
 
            <if test="registerAddress != null">
                registerAddress = #{registerAddress,jdbcType=VARCHAR},
            </if>
            <if test="distributionIds != null">
                distributionIds = #{distributionIds,jdbcType=VARCHAR},
            </if>
            <if test="distributionNames != null">
                distributionNames = #{distributionNames,jdbcType=VARCHAR},
            </if>
            <if test="photos != null">
                photos = #{photos,jdbcType=VARCHAR},
            </if>
            <if test="faceIds != null">
                faceIds = #{faceIds,jdbcType=VARCHAR},
            </if>
            <if test="createBy != null">
                createBy = #{createBy,jdbcType=VARCHAR},
            </if>
            <if test="createTime != null">
                createTime = #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="updateBy != null">
                updateBy = #{updateBy,jdbcType=VARCHAR},
            </if>
            <if test="updateTime != null">
                updateTime = #{updateTime,jdbcType=TIMESTAMP},
            </if>
            <if test="remarks != null">
                remarks = #{remarks,jdbcType=VARCHAR},
            </if>
            <if test="delFlag != null">
                delFlag = #{delFlag,jdbcType=VARCHAR},
            </if>
            <if test="revJson1 != null">
                rev_json1 = #{revJson1,jdbcType=CHAR},
            </if>
        </set>
        <where>
            id = #{id}
        </where>
    </update>
 
    <sql id="base_column_list">
        id                  , <!--id-->
        orgId               , <!--组织架构Id-->
        officeId            , <!--部门Id-->
        no                     , <!--工卡、学生校徽等卡片编号-->
        cardId              , <!--身份证号-->
        userId              , <!--用户ID-->
        userName            , <!--用户名-->
        name                , <!--姓名-->
        gender              , <!--性别-->
        nation              , <!--民族-->
        phone               , <!--电话-->
        type                , <!--人员类型(学生、职工、校外)-->
        registerAddress     , <!--注册地址-->
        distributionIds     , <!--分布节点ids-->
        distributionNames   , <!--分布节点Names-->
        photos              , <!--人员照片(格式-->
        faceIds             , <!--人脸Id(格式-->
        createBy            , <!--创建者-->
        createTime          , <!--创建时间-->
        updateBy            , <!--更新者-->
        updateTime          , <!--更新时间-->
        remarks             , <!--备注信息-->
        delFlag             , <!--逻辑删除标记(0-->
        rev_json1             <!--预留json格式字段1-->
    </sql>
 
    <select id="findById" resultType="com.cloud.model.sys.BbEmployee">
        select  p.*,f.feature
        from
        <include refid="table" /> p inner join bb_face f
        on p.faceIds = f.resourceId
        <where>
            p.delFlag = '0'
            <if test="orgId != null and orgId != ''">
                and p.orgId = #{orgId}
            </if>
            <if test="id != null and id != ''">
                and p.id = #{id}
            </if>
        </where>
    </select>
 
    <select id="findByIdFromTemp" resultType="com.cloud.model.sys.BbEmployee">
        select  p.*,f.feature
        from
        bb_person_temporary p inner join bb_face f
        on p.faceIds = f.resourceId
        <where>
            and p.id = #{id}  and p.delFlag = '0'
        </where>
    </select>
    <!--除临时库以外的编辑回显方法-->
    <select id="anyThingToUpdate" resultType="Map">
        select  p.*,o.name as orgName,o.parentJson
        from
        <include refid="table" /> p left join sys_organization o on p.officeId = o.id
        <where>
            p.delFlag="0"
            and p.id = #{id}
        </where>
    </select>
 
    <select id="selectPersonDetailById" resultType="java.util.Map">
        select b.id id,b.name name,b.photos photos,b.gender gender,b.cardId cardId,b.phone phone,b.`no` no,b.type type,o.name orgName,b.delFlag delFlag
        from
        <include refid="table" /> b
        left join  sys_organization o
        on b.officeId = o.id  where
        <if test="personId != null and personId != ''">
             b.id = #{personId}
        </if>
        <if test=" delFlag == null or !delFlag">
            and b.delFlag != '1'
        </if>
            ORDER BY b.updateTime DESC
            LIMIT 1
    </select>
 
    <!--在临时库中查人,返回map-->
    <select id="tempToUpdate" resultType="Map">
        select  p.*
        from
        bb_person_temporary p
        <where>
            p.delFlag="0"
            and p.id = #{id}
        </where>
    </select>
 
    <select id="isRepeatIdCard" resultType="Integer">
        select  count(*)
        from
        <include refid="table" />
        <where>
            cardId = #{cardId}
            <if test=" id!=null and id!='' ">
                and id!=#{id}
            </if>
            and delFlag = 0
 
        </where>
    </select>
 
    <select id="findByPersonIds" resultType="com.cloud.user.model.PadPersonInfo">
        select p.id personId,p.name name,p.cardId idcard,p.photos personPic,f.feature byteFeature,
        p.phone phone,p.photos photos,p.orgId orgId,p.officeId officeId,p.no no,p.gender gender,p.nation nation,
        p.registerAddress registerAddress,p.distributionIds distributionIds
        from
        (SELECT *
        from <include refid="table" /> union        /* where delFlag = 0*/
        select *
        from <include refid="temp_person_table"/>
        ) p
        left join bb_face f on p.faceIds = f.resourceId
        where
         <foreach collection="personIds" index="index" item="perId" separator="or" close=")" open="(" >
        p.id  = #{perId,jdbcType=VARCHAR}
        </foreach>
            <if test="personLike != null and personLike != ''" >
                and ( p.name like CONCAT("%",#{personLike,jdbcType=VARCHAR},"%") or
                p.cardId like CONCAT("%",#{personLike,jdbcType=VARCHAR},"%") )
            </if>
        ORDER BY p.delFlag  limit 1
    </select>
 
    <select id="findAllMergePerson" resultType="com.cloud.user.model.MergePersonView">
        select p.id personId,p.name name,p.cardId idcard,p.photos personPic,mf.mergeFrom
        FROM merge_from mf
        inner JOIN  <include refid="table" /> p on mf.personId = p.id and p.delFlag = '0'
        WHERE mf.delFlag = '0'
    </select>
 
    <select id="queryUpdatingPersonCount" resultType="Integer">
        select count(id)
        FROM merge_from
        WHERE delFlag = '0'
    </select>
 
    <update id="deleteMergePerson" parameterType="String" >
        UPDATE merge_from
        SET delFlag = '1'
        WHERE personId = #{personId,jdbcType=VARCHAR}
    </update>
 
    <update id="updateBbPersonBaseForCluInfo" >
        update <include refid="table" />
        set distributionIds =
        CASE WHEN distributionIds is NULL or distributionIds = '' THEN
        CONCAT(""
        <foreach collection="cluInfos" item="cluInfo1" open="," separator="," close=")">
            #{cluInfo1,jdbcType=VARCHAR}
        </foreach>
        ELSE
        CONCAT(distributionIds
        <foreach collection="cluInfos" item="cluInfo2" open="," separator="," close=")">
        IF(distributionIds LIKE CONCAT('%',#{cluInfo2,jdbcType=VARCHAR},'%'),'',#{cluInfo2,jdbcType=VARCHAR})
        </foreach>
        END
        WHERE id = #{personId,jdbcType=VARCHAR}
    </update>
 
    <sql id="where">
        <where>
            1=1
            <if test=" phone!=null and phone!='' ">
                and phone=#{phone}
            </if>
            <if test=" orgId!=null ">
                and orgId=#{orgId}
            </if>
            <if test="type != null and type != ''">
                and type = #{type}
            </if>
            <if test="name != null and name != ''">
                and name = #{name}
            </if>
            and delFlag = 0
            <if test="start != null and start != '' and length != null and length != ''">
                LIMIT #{start}, #{length}
            </if>
        </where>
    </sql>
 
    <select id="count1" resultType="int">
        select count(*) from <include refid="table" /> t
        <where>
            1=1
            <if test="orgIds != null">
                and officeId in <foreach collection="orgIds" item="officeId" open="(" separator="," close=")">
                #{officeId}
            </foreach>
            </if>
            <if test=" phone!=null and phone!='' ">
                and phone=#{phone}
            </if>
            <if test="type != null and type != ''">
                and type = #{type}
            </if>
            <if test="name != null and name != ''">
                and name like '%${name}%'
            </if>
            <if test="orgId != null and orgId != null">
                and orgId = #{orgId}
            </if>
            and delFlag = 0
        </where>
    </select>
 
    <select id="findData1" resultType="com.cloud.model.sys.BbEmployee" parameterType="map">
        select * from <include refid="table" /> t
        <where>
            1=1
            <if test="orgIds != null">
                and officeId in <foreach collection="orgIds" item="officeId" open="(" separator="," close=")">
                #{officeId}
            </foreach>
            </if>
            <if test=" phone!=null and phone!='' ">
                and phone=#{phone}
            </if>
            <if test="type != null and type != ''">
                and type = #{type}
            </if>
            <if test="name != null and name != ''">
                and name like '%${name}%'
            </if>
            and delFlag = 0
            <if test="orgId != null and orgId != null">
                and orgId = #{orgId}
            </if>
            <if test="start != null and length != null">
                LIMIT #{start}, #{length}
            </if>
        </where>
    </select>
 
    <select id="count" resultType="int">
        select count(*) from <include refid="table" /> t
        <where> 1=1 and officeId in (
            SELECT id FROM sys_organization WHERE parentIds LIKE CONCAT("%,",#{id},",%")
            <if test="orgIds != null" >
                <foreach collection="orgIds" index="index" item="orgId" close=")" open="and(" separator="or" >
                    parentIds LIKE CONCAT("%,",#{orgId},",%")
                </foreach>
            </if>
            )
            <if test=" phone!=null and phone!='' ">
                and t.phone=#{phone}
            </if>
            <if test="type != null and type != ''">
                and t.type = #{type}
            </if>
            <if test="groupInformation != null and groupInformation != ''">
                and (t.name like concat('%', #{groupInformation}, '%') or cardId like concat('%', #{groupInformation}, '%') or no like concat('%', #{groupInformation}, '%'))
            </if>
            <if test="distributionIds != null ">
                and
                <foreach collection="distributionIds" index="index" item="distributionId" separator="or" open="(" close=")">
                    distributionIds like concat('%', #{distributionId}, '%')
                </foreach>
            </if>
            <if test="name != null and name != ''">
                and t.name like '%${name}%'
            </if>
            <if test="orgId != null and orgId != null">
                and t.orgId = #{orgId}
            </if>
            /*wp 添加 是否查询已上除*/
            <if test="delFlag == null or !delFlag ">
                and t.delFlag = 0
            </if>
        </where>
    </select>
 
    <select id="countTemp" resultType="int">
        select count(*) from bb_person_temporary t
        <where> 1=1
            <if test=" phone!=null and phone!='' ">
                and phone=#{phone}
            </if>
            <if test="type != null and type != ''">
                and type = #{type}
            </if>
            <if test="groupInformation != null and groupInformation != ''">
                and (t.name like concat('%', #{groupInformation}, '%') or cardId like concat('%', #{groupInformation}, '%') or no like concat('%', #{groupInformation}, '%'))
            </if>
            <if test="distributionIds != null ">
                and
                <foreach collection="distributionIds" index="index" item="distributionId" separator="or" open="(" close=")">
                    distributionIds like concat('%', #{distributionId}, '%')
                </foreach>
            </if>
            <if test="name != null and name != ''">
                and name like '%${name}%'
            </if>
            <if test="orgId != null and orgId != null">
                and orgId = #{orgId}
            </if>
            and t.delFlag = 0
        </where>
    </select>
 
    <select id="findData" resultType="com.cloud.model.sys.BbEmployee" parameterType="map">
        select t.*,concat(IFNULL(parnetOrg.name,"")," ",o.name) officeName,d.lable typeName from <include refid="table" /> t
        left JOIN sys_organization o on t.officeId = o.id
        left JOIN sys_organization parnetOrg on o.parentId = parnetOrg.id
        left join sys_dict d on t.type = d.value and d.orgId = t.orgId and d.type = 'PEO_TYPE' and d.delFlag= 0
        <where> 1=1 and t.officeId in (
            SELECT id FROM sys_organization WHERE parentIds LIKE CONCAT("%,",#{id},",%")
            <if test="orgIds != null" >
                <foreach collection="orgIds" index="index" item="orgId" close=")" open="and(" separator="or" >
                    parentIds LIKE CONCAT("%,",#{orgId},",%")
                </foreach>
                </if>
            )
            <!--<if test=" phone!=null and phone!='' ">
                and t.phone=#{phone}   wp  问过 panlei  此处可不用
            </if>-->
            <if test="type != null and type != ''">
                and t.type = #{type}
            </if>
            <if test="groupInformation != null and groupInformation != ''">
                and (t.name like concat('%', #{groupInformation}, '%') or cardId like concat('%', #{groupInformation}, '%')
                or no like concat('%', #{groupInformation}, '%')  )
            </if>
            <if test="distributionIds != null ">
                and
                <foreach collection="distributionIds" index="index" item="distributionId" separator="or" open="(" close=")">
                    t.distributionIds like concat('%', #{distributionId}, '%')
                </foreach>
            </if>
            /*wp 添加 是否查询已上除*/
            <if test="delFlag == null or !delFlag ">
                and t.delFlag = 0
            </if>
            <if test="orgId != null and orgId != ''">
                and t.orgId = #{orgId}
            </if>
            ORDER BY IFNULL(t.updateTime,t.createTime) DESC
            <if test="start != null and length != null">
                LIMIT #{start}, #{length}
            </if>
 
        </where>
    </select>
 
 
    <select id="findDataFromBase" resultType="com.cloud.model.sys.BbEmployee" parameterType="map">
        select t.*,concat(IFNULL(parentOrg.name,"")," ",o.name) officeName,d.lable typeName from <include refid="table" /> t
        left JOIN sys_organization o on t.officeId = o.id
        left JOIN sys_organization parentOrg on o.parentId = parentOrg.id
        left join sys_dict d on t.type = d.value and d.orgId = t.orgId and d.type = 'PEO_TYPE' and d.delFlag= 0
        <where>
            /*wp 添加 是否查询已上除*/
            <if test="delFlag != null and delFlag">
                1=1
            </if>
            <if test="delFlag == null or !delFlag ">
                t.delFlag = 0
            </if>
            <if test=" phone!=null and phone!='' ">
                and t.phone=#{phone}
            </if>
            <if test="type != null and type != ''">
                and t.type = #{type}
            </if>
            <if test="groupInformation != null and groupInformation != ''">
                and (t.name like concat('%', #{groupInformation}, '%') or t.cardId like concat('%', #{groupInformation}, '%')
                or t.no like concat('%', #{groupInformation}, '%')
                or t.phone like concat('%', #{groupInformation}, '%') or o.name like concat('%', #{groupInformation}, '%'))
            </if>
            <if test="distributionIds != null ">
                and
                <foreach collection="distributionIds" index="index" item="distributionId" separator="or" open="(" close=")">
                    t.distributionIds like concat('%', #{distributionId}, '%')
                </foreach>
            </if>
            <if test="name != null and name != ''">
                and t.name like '%${name}%'
            </if>
            ORDER BY IFNULL(t.updateTime,t.createTime) DESC
            <if test="start != null and length != null">
                LIMIT #{start}, #{length}
            </if>
        </where>
    </select>
 
    <select id="countBase" resultType="int" parameterType="map">
        select count(*) from <include refid="table" /> t
        left JOIN sys_organization o on t.officeId = o.id
        <where>
             /*wp 添加 是否查询已上除*/
         <if test="delFlag != null and delFlag">
             1=1
         </if>
            <if test="delFlag == null or !delFlag ">
                t.delFlag = 0
            </if>
            <if test=" phone!=null and phone!='' ">
                and t.phone=#{phone}
            </if>
            <if test="type != null and type != ''">
                and t.type = #{type}
            </if>
            <if test="groupInformation != null and groupInformation != ''">
                and (t.name like concat('%', #{groupInformation}, '%') or t.cardId like concat('%', #{groupInformation}, '%') or t.no like concat('%', #{groupInformation}, '%')
                or t.phone like concat('%', #{groupInformation}, '%') or o.name like concat('%', #{groupInformation}, '%'))
            </if>
            <if test="distributionIds != null ">
                and
                <foreach collection="distributionIds" index="index" item="distributionId" separator="or" open="(" close=")">
                    t.distributionIds like concat('%', #{distributionId}, '%')
                </foreach>
            </if>
            <if test="name != null and name != ''">
                and t.name like '%${name}%'
            </if>
        </where>
    </select>
 
    <select id="findDataFromTemp" resultType="com.cloud.model.sys.BbEmployee" parameterType="map">
        select t.* from bb_person_temporary t
        <where> 1=1
            <if test=" phone!=null and phone!='' ">
                and phone=#{phone}
            </if>
            <if test="type != null and type != ''">
                and type = #{type}
            </if>
            <if test="groupInformation != null and groupInformation != ''">
                and (t.name like concat('%', #{groupInformation}, '%') or cardId like concat('%', #{groupInformation}, '%') or no like concat('%', #{groupInformation}, '%'))
            </if>
            <if test="distributionIds != null ">
                and
                <foreach collection="distributionIds" index="index" item="distributionId" separator="or" open="(" close=")">
                    distributionIds like concat('%', #{distributionId}, '%')
                </foreach>
            </if>
            <if test="name != null and name != ''">
                and name like '%${name}%'
            </if>
            and t.delFlag = 0
            ORDER BY IFNULL(t.updateTime,t.createTime) DESC
            <if test="start != null and length != null">
                LIMIT #{start}, #{length}
            </if>
        </where>
    </select>
 
    <select id="findOrgEmployeeByTypeCount" parameterType="java.util.Map" resultType="int">
        SELECT count(emp.id) FROM bb_employee emp INNER JOIN sys_organization org ON emp.officeId = org.id
        WHERE emp.delFlag = 0 and org.parentIds LIKE '%${parentIds}%' AND emp.type = #{type}
        <if test="name != null and name != ''">
            and emp.name like '%${name}%'
        </if>
    </select>
 
    <select id="findOrgEmployeeByTypeData" parameterType="java.util.Map" resultType="com.cloud.model.sys.BbEmployee">
        SELECT emp.id,emp.name,emp.photos FROM bb_employee emp INNER JOIN sys_organization org ON emp.officeId = org.id
        WHERE  emp.delFlag = 0 AND org.parentIds LIKE '%${parentIds}%' AND emp.type = #{type}
        <if test="name != null and name != ''">
            and emp.name like '%${name}%'
        </if>
        <if test="start != null and length != null and length != ''" >
            LIMIT #{start}, #{length}
        </if>
    </select>
 
    <select id="findOrgEmpIds" parameterType="java.util.Map" resultType="int">
        SELECT emp.id FROM bb_employee emp INNER JOIN sys_organization org ON emp.officeId = org.id AND org.delFlag = 0
        AND org.parentIds LIKE '%${parentIds}%' AND emp.type = #{type}
    </select>
 
    <select id="findOrgEmpMap" parameterType="java.util.Map" resultType="map">
        SELECT emp.orgId,emp.id,emp.photos,emp.`name`,emp.compactType,emp.type,emp.phone,emp.createTime FROM bb_employee emp INNER JOIN sys_organization org ON emp.officeId = org.id
        AND emp.delFlag = 0
        AND org.parentIds LIKE '%${parentIds}%'
        <if test="orgId != null and orgId != ''">
            AND emp.orgId = #{orgId}
        </if>
        <if test="type != null and type != ''">
            AND emp.type = #{type}
        </if>
        <if test="compactType != null and compactType != ''">
            AND emp.compactType = #{compactType}
        </if>
        <if test="searchName != null and searchName != ''">
            AND emp.name like '%${searchName}%'
        </if>
        <if test="start != null and start != '' and length != null and length != ''">
            limit ${start},${length}
        </if>
    </select>
 
    <select id="findOrgEmpMap1" parameterType="java.util.Map" resultType="map">
        SELECT emp.orgId,emp.id,emp.photos,emp.`name`,emp.gender,emp.cardId,emp.compactType,emp.type,emp.phone,emp.createTime FROM bb_employee emp INNER JOIN sys_organization org ON emp.officeId = org.id
        WHERE emp.delFlag = 0
        AND org.parentIds LIKE CONCAT((select parentIds from sys_organization where id = #{id}),"%")
        <if test="orgId != null and orgId != ''">
            AND emp.orgId = #{orgId}
        </if>
        <if test="type != null and type != ''">
            AND emp.type = #{type}
        </if>
        <if test="compactType != null and compactType != ''">
            AND emp.compactType = #{compactType}
        </if>
        <if test="searchName != null and searchName != ''">
            AND emp.name like '%${searchName}%'
        </if>
        <if test="start != null and start != '' and length != null and length != ''">
            limit ${start},${length}
        </if>
    </select>
 
    <select id="findOrgEmpMapCount" resultType="int">
        SELECT COUNT(emp.id) FROM bb_employee emp INNER JOIN sys_organization org ON emp.officeId = org.id
        AND emp.delFlag = 0
        AND org.parentIds LIKE '%${parentIds}%'
        <if test="orgId != null and orgId != ''">
            AND emp.orgId = #{orgId}
        </if>
        <if test="type != null and type != ''">
            AND emp.type = #{type}
        </if>
        <if test="compactType != null and compactType != ''">
            AND emp.compactType = #{compactType}
        </if>
        <if test="searchName != null and searchName != ''">
            AND emp.name like '%${searchName}%'
        </if>
    </select>
 
    <select id="findInfoByEmployeeId" parameterType="java.util.Map" resultType="map">
        SELECT
        a.id,
        a.photos,
        a.`name`,
        b.relation,
        c.photos as parent_photos,
        c.`name` as parent_name
        FROM
        bb_employee a
        LEFT JOIN bb_employee_relation b ON a.id = b.employeeId
        LEFT JOIN bb_employee c ON c.id = b.relationoId
        <where>
            a.delFlag = #{delFlag}
            <if test="orgId != null">
                and a.orgId = #{orgId}
            </if>
            <if test="id != null">
                and a.id = #{id}
            </if>
        </where>
        LIMIT 1
    </select>
 
    <select id="findStudentAndTeachers" parameterType="java.util.Map" resultMap="beanMap">
        SELECT 
            a.id,
            a.orgId,
            a.officeId,
            a.cardId,
            a.`name`,
            a.gender,
            a.nation,
            a.phone,
            a.type,
            a.registerAddress,
            a.distributionIds,
            a.distributionNames,
            a.photos,
            a.faceIds,
            a.createBy,
            a.createTime,
            a.updateBy,
            a.updateTime,
            a.remarks,
            a.delFlag,
            a.rev_json1
        FROM
            bb_employee a
        LEFT JOIN sys_organization b on a.orgId = b.orgId
        <where>
            1=1
            <if test="orgId != null">
                and a.orgId = #{orgId}
                and b.orgId = #{orgId}
            </if>
            <if test="classId != null and classId != ''">
                and a.officeId = #{classId}
                and a.officeId = b.id
            </if>
            <if test="gradeId != null and gradeId != ''">
                and b.parentIds like  '%,${gradeId},%'
                a.officeId = b.id
            </if>
            and (a.type='学生' or a.type='教师')
            <if test="type != null and type != ''">
                and a.type = #{type}
            </if>
            and a.delFlag='0'
        </where>
    </select>
 
    <!--根据家长ID查询学生信息-->
    <select id="findStuByEmpId" parameterType="java.util.Map" resultMap="stuMap">
        SELECT be.id,be.orgId,be.officeId,be.name,be.gender,be.nation,be.photos,ber.relation as remarks from bb_employee be
        LEFT JOIN bb_employee_relation ber on be.id = ber.employeeId where be.delFlag = 0
        <if test="orgId != null and orgId != ''">
            and be.orgId = #{orgId}
        </if>
        and (ber.relation = '家长' or ber.relation = '父亲' or ber.relation = '母亲')
        and ber.relationoId = #{empId}
        and be.delFlag = 0
    </select>
 
    <!--教师模糊查询根据拼音-->
    <select id="findTeacherByPin" parameterType="java.util.Map" resultMap="beanMap">
        select be.id,be.name,be.photos,so.name as remarks from bb_employee be INNER JOIN sys_organization so
        on be.officeId = so.id where be.delFlag=0
        <if test="orgId != null and orgId != ''">
            and be.orgId = #{orgId}
        </if>
        <if test="namecode != null and namecode != ''">
            and be.mnemonicCode like '${namecode}%'
        </if>
        and be.type = '教师'
    </select>
    <!--教师模糊查询根据拼音-->
    <select id="findOfficeNameById" parameterType="java.util.Map" resultType="map">
        SELECT a.id, b.`name` from bb_employee a LEFT JOIN sys_organization b on a.officeId = b.id where
        a.delFlag = 0
        <if test="orgId != null">
            and a.orgId = #{orgId}
        </if>
        <if test="id != null">
            and a.id like #{id}
        </if>
    </select>
 
    <select id="isExistEmp" resultMap="beanMap">
        SELECT id,faceIds from bb_employee where delFlag = 0
        <if test="orgId != null">
            and orgId = #{orgId}
        </if>
        and phone = #{phone}
        limit 0,1
    </select>
 
    <select id="isExistEmployee" resultType="com.cloud.model.sys.BbEmployee">
        SELECT * from bb_employee where delFlag = 0
        <if test="orgId != null">
            and orgId = #{orgId}
        </if>
        and phone = #{phone}
        limit 0,1
    </select>
 
    <select id="findOrgTeaMap" parameterType="java.util.Map" resultType="map">
        SELECT emp.id,emp.name,emp.compactType FROM bb_employee emp INNER JOIN sys_organization org ON emp.officeId = org.id
        AND emp.delFlag = 0 AND org.parentIds LIKE '%${parentIds}%' AND emp.type = #{type}
        <if test="orgId != null and orgId != ''">
            AND emp.orgId = #{orgId}
        </if>
        <if test="compactType != null and compactType != ''">
            AND emp.compactType = #{compactType}
        </if>
    </select>
 
    <!--根据id查询人员详细信息-->
    <select id="findEmpById" resultType="com.cloud.model.sys.BbEmployee" parameterType="map">
        select * from bb_person_base WHERE delFlag = '0' and  id = #{id}
        <if test="orgId = null and orgId != ''">
            and orgId = #{orgId}
        </if>
        <if test="signDate!=null and signDate!=''">
            and DATE_FORMAT(createTime,'%Y-%m-%d') &lt;= #{signDate} and #{signDate} &lt;= DATE_FORMAT(now(),'%Y-%m-%d')
        </if>
    </select>
 
    <!--获取访客被访人数-->
    <select id="findOrgEmpInVisitCount" resultType="java.lang.Integer">
        SELECT count(emp.id) FROM bb_employee emp INNER JOIN sys_organization org ON emp.officeId = org.id
        WHERE emp.delFlag = 0 and org.parentIds LIKE CONCAT((select parentIds from sys_organization where delFlag = '0' and id = #{id}),"%")
        AND emp.type != #{type}
        <if test="name != null and name != ''">
            and emp.name like '%${name}%'
        </if>
    </select>
 
    <!--获取访客被访人-->
    <select id="findOrgEmpInVisitData" resultType="com.cloud.model.sys.BbEmployee">
        SELECT emp.id,emp.name,emp.type,emp.photos FROM bb_employee emp INNER JOIN sys_organization org ON emp.officeId = org.id
        WHERE  emp.delFlag = 0 AND org.parentIds LIKE CONCAT((select parentIds from sys_organization where delFlag = '0' and id = #{id}),"%")
        AND emp.type != #{type}
        <if test="name != null and name != ''">
            and emp.name like '%${name}%'
        </if>
        <if test="start != null and length != null and length != ''" >
            LIMIT #{start}, #{length}
        </if>
    </select>
 
    <select id="findDataByOfficeId"  resultType="com.cloud.model.sys.BbEmployee">
        select a.*
        from <include refid="table" /> a
        LEFT JOIN sys_organization b on a.officeId = b.id
        where b.parentIds like CONCAT("%,",#{id},",%")
        and a.delFlag = 0
        and b.delFlag = 0
    </select>
 
    <update id="updateOfficeId" parameterType="map">
        update bb_employee
        <set>
 
            <if test="updateOfficeId != null">
                officeId = #{updateOfficeId,jdbcType=CHAR},
            </if>
            <if test="updateOrgId != null">
                orgId = #{updateOrgId,jdbcType=CHAR},
            </if>
            <if test="orgNamesJson != null">
                orgNamesJson = #{orgNamesJson,jdbcType=CHAR},
            </if>
        </set>
        <where>
            <if test="officeId != null and officeId != ''">
                and officeId in (
                    SELECT id
                    from sys_organization
                    where parentIds LIKE CONCAT("%,",#{officeId},",%") and delFlag=0
                )
            </if>
            <if test="employeeIds != null and employeeIds != ''">
                and id in (${employeeIds})
            </if>
            <if test="orgId != null and orgId != ''">
                and orgId = #{orgId}
            </if>
        </where>
    </update>
</mapper>