许鹏程
2023-05-25 213cc37cbf0b2515a4de56cc1e01813211bad183
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
package com.product.org.admin.service;
 
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
 
import com.product.admin.service.CodeService;
import com.product.common.lang.StringUtils;
import com.product.core.cache.DataPoolCacheImpl;
import com.product.core.dao.BaseDao;
import com.product.core.entity.DataTableEntity;
import com.product.core.entity.FieldMetaEntity;
import com.product.core.entity.FieldSetEntity;
import com.product.core.exception.BaseException;
import com.product.core.service.support.AbstractBaseService;
import com.product.core.spring.context.SpringBeanUtil;
import com.product.core.spring.context.SpringMVCContextHolder;
import com.product.core.transfer.Transactional;
import com.product.org.admin.config.CmnConst;
import com.product.org.admin.config.SystemCode;
import com.product.org.admin.service.idel.ITimeTaskService;
import com.product.org.admin.util.InternationalLanguage;
import com.product.util.BaseUtil;
 
 
/**
 * 
 * Copyright LX-BASE
 * 
 * @Title: LX-BASE-
 * @Project: TimeTaskChangeService
 * @Date: 2020-06-10 15:24
 * @Author: 杜洪波
 * @Description:定时任务变更(部门变更,人员变更,人员离职,人员工转正),每日扫描
 */
@Component("task-service")
public class TimeTaskChangeService extends AbstractBaseService implements ITimeTaskService{
 
    @Autowired
    private BaseDao baseDao;
 
    @Autowired
    private CodeService codeService;
 
    @Autowired
    ApplicationContext applicationContext;
    
    @Autowired
    TimeTaskChangeService timeTaskChangeServices;
    @Autowired
    private StaffManagerService staffManagerService;
    
    static final String RESULT="result";
 
    
    /**
     *     定时任务按天执行汇总(员工状态刷新,员工转正,员工离职,员工变更,组织机构变更)
     * 
     * @throws BaseException
     */
    public void timeTaskForDay() throws BaseException {
        Date date = new Date();
        long currentTime = date.getTime();
 
        staffStatusChange(currentTime);    //员工状态变更
        staffBecomeRegular(currentTime);//员工转正
        staffChange(currentTime);        //员工变更
        staffDimission(currentTime);    //员工离职
        deptChange(currentTime);        //部门变更
    }
 
    /**
     *     员工状态定时任务变更
     * @param currentTime
     * @throws BaseException
     */
    public void staffStatusChange(long currentTime) throws BaseException{
        DataTableEntity dtNoChange=baseDao.listTable("SELECT * FROM product_sys_staff_employment_info WHERE staff_uuid IN (SELECT uuid FROM product_sys_staffs WHERE staff_status=0 OR staff_status=1)", new Object[] {});
        if (dtNoChange != null && dtNoChange.getRows() > 0) {
            for (int i = 0; i < dtNoChange.getRows(); i++) {
                FieldSetEntity fseNoChange = dtNoChange.getFieldSetEntity(i);
                String staff_uuid = fseNoChange.getString(CmnConst.STAFF_UUID); // 转正员工uuid
                Date entryTime=fseNoChange.getDate("employment_date"); // 加入公司日期时间
                Date probationTime = fseNoChange.getDate("probation_end_date"); // 试用结束日期
                int timeZone = getStaffForCompanyTimeZone(staff_uuid);
                
                boolean isMatch1=matchTime(currentTime, entryTime, timeZone, 4);
                boolean isMatch2=matchTime(currentTime, probationTime, timeZone, 4);
                if (isMatch2) {
                    baseDao.executeUpdate("UPDATE product_sys_staffs SET staff_status=2 WHERE uuid=?",new Object[] {staff_uuid});
                    autoCreateApplicationForm(staff_uuid,entryTime,probationTime);
                }else {
                    if (isMatch1) {
                        baseDao.executeUpdate("UPDATE product_sys_staffs SET staff_status=1 WHERE uuid=?",new Object[] {staff_uuid});
                    }
                }
            }
        }
    }
    
    
    /**
     *     自动生成转正申请单
     * @param staff_uuid
     * @param probationTime
     */
    public void autoCreateApplicationForm(String staff_uuid,Date entryTime, Date probationTime) {
        FieldSetEntity fseStaff=baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_STAFFS, staff_uuid, false);
        if (fseStaff!=null) {
            FieldSetEntity fse=new FieldSetEntity();
            FieldMetaEntity fseMate=new FieldMetaEntity();
            fseMate.setTableName(new String[] {CmnConst.PRODUCT_SYS_STAFF_COMPLETE_PROBATION});
            fse.setMeta(fseMate);
            fse.setValue(CmnConst.ORG_LEVEL_UUID, fseStaff.getString(CmnConst.ORG_LEVEL_UUID));
            fse.setValue(CmnConst.STAFF_UUID, staff_uuid);
            fse.setValue("employment_date", entryTime);
            fse.setValue(CmnConst.PROBATION_END_DATE, automaticDateGrowth(probationTime));
            fse.setValue(CmnConst.RESULT_STATUS, 0);
            baseDao.add(fse);
        }
     }
    
    /**
     *     日期自增+1天
     * @param probationTime
     */
    public Date automaticDateGrowth(Date probationTime) {
        
        Calendar cal = Calendar.getInstance();
        cal.setTime(probationTime);
        cal.add(Calendar.DATE,1);
        probationTime =cal.getTime();
        return probationTime;
    }
    
    
    /**
     *     员工转正 
     *     timeZone==-1 找不到员工对应公司信息,或者公司配置时区错误,跳过 timeZone==0 公司未配置时区信息,则按照系统标准时区匹配
     * @param currentTime 当前时间
     * @throws BaseException
     */
    public void staffBecomeRegular(long currentTime) throws BaseException  {
        // 获取员工转正未执行数据
        DataTableEntity dtNoExecute = baseDao.listTable(CmnConst.PRODUCT_SYS_STAFF_COMPLETE_PROBATION,"result_status=0 ");
        if (dtNoExecute != null && dtNoExecute.getRows() > 0) {
            //遍历员工转正未执行数据
            for (int i = 0; i < dtNoExecute.getRows(); i++) {
                FieldSetEntity fseNoExecute = dtNoExecute.getFieldSetEntity(i);
                String staff_uuid = fseNoExecute.getString(CmnConst.STAFF_UUID); // 转正员工uuid
                Date excutedateTime = fseNoExecute.getDate("probation_end_date"); // 执行时间
                int timeZone = getStaffForCompanyTimeZone(staff_uuid);
                if (timeZone == -1) {
                    continue;
                }
        
                //判断时间是否匹配
                boolean isMatch = matchTime(currentTime, excutedateTime, timeZone, 4);
        
                if (isMatch) {
                    //执行转正
                    try {
                        ITimeTaskService service=(ITimeTaskService)getProxyInstance(timeTaskChangeServices);
                        isMatch = service.changeRegular(fseNoExecute,staff_uuid);
                    } catch (BaseException e) {
                        e.printStackTrace();
                        SpringMVCContextHolder.getSystemLogger().error(e);
                        isMatch=false;
                    } catch (Exception e) {
                        e.printStackTrace();
                        SpringMVCContextHolder.getSystemLogger().error(e);
                        isMatch=false;
                    }
                }
                if (isMatch) {
                    DataPoolCacheImpl.getInstance().reFreshCacheDataByPermission(fseNoExecute.getString(CmnConst.STAFF_UUID));
                    executeServiceChange(fseNoExecute,CmnConst.PRODUCT_SYS_STAFF_COMPLETE_PROBATION);
                }
            }
        }
    }
 
    
    /**
     *     员工离职
     * @param currentTime
     * @throws BaseException
     */
    public void staffDimission(long currentTime) throws BaseException {
        DataTableEntity dtNoExecute = baseDao.listTable(CmnConst.PRODUCT_SYS_STAFF_TERMINATION,"result_status = 0 OR result_status = 1 ");
        if (dtNoExecute != null && dtNoExecute.getRows() > 0) {
            for (int i = 0; i < dtNoExecute.getRows(); i++) {
                FieldSetEntity fseNoExecute = dtNoExecute.getFieldSetEntity(i);
                int result_status = fseNoExecute.getInteger(CmnConst.RESULT_STATUS);    //执行状态
                String staff_uuid = fseNoExecute.getString(CmnConst.APP_STAFF_UUID); //转正员工uuid
                Date excutedateTime = fseNoExecute.getDate("change_effective"); //执行时间
                int timeZone = getStaffForCompanyTimeZone(staff_uuid);    //时区误差
 
                //判断时间是否匹配
                boolean isMatch = matchTime(currentTime, excutedateTime, timeZone, 4);
                if (isMatch) {
                    if (result_status == 0) {
                        //执行变更
                        try {
                            ITimeTaskService service =(ITimeTaskService)getProxyInstance(timeTaskChangeServices);
                            isMatch=service.changeDimission(fseNoExecute);
                        } catch (BaseException e) {
                            SpringMVCContextHolder.getSystemLogger().error(e);
                            isMatch=false;
                        } catch (Exception e) {
                            SpringMVCContextHolder.getSystemLogger().error(e);
                            isMatch=false;
                        }
                    }
                    if (isMatch) {
                        DataPoolCacheImpl.getInstance().reFreshCacheDataByPermission(fseNoExecute.getString(CmnConst.APP_STAFF_UUID));
                        executeServiceChange(fseNoExecute,CmnConst.PRODUCT_SYS_STAFF_TERMINATION);
                    }
                }
            }
        }
    }
 
    /**
     *     员工变更
     * @param currentTime
     * @throws BaseException
     */
    public void staffChange(long currentTime) throws BaseException {
 
        DataTableEntity dtNoExecute = baseDao.listTable(CmnConst.PRODUCT_SYS_STAFF_MOVEMENT,"result_status =0 OR result_status=1 ");
        if (dtNoExecute != null && dtNoExecute.getRows() > 0) {
            for (int i = 0; i < dtNoExecute.getRows(); i++) {
                FieldSetEntity fseNoExecute = dtNoExecute.getFieldSetEntity(i);
                int result_status = fseNoExecute.getInteger(CmnConst.RESULT_STATUS);
                String org_level_uuid = fseNoExecute.getString("original_org_level_uuid");
                Date excutedateTime = fseNoExecute.getDate("movement_effective_utc_date"); // 执行时间
                int timeZone = getcompanyTImeZone(org_level_uuid);
 
                // 判断时间是否匹配
                boolean isMatch = matchTime(currentTime, excutedateTime, timeZone, 4);
 
                if (isMatch) {
                    if (result_status == 0) {
                        try {
                            ITimeTaskService service =(ITimeTaskService)getProxyInstance(timeTaskChangeServices);
                            isMatch=service.staffChange(fseNoExecute);
                        } catch (BaseException e) {
                            SpringMVCContextHolder.getSystemLogger().error(e);
                            isMatch=false;
                        } catch (Exception e) {
                            SpringMVCContextHolder.getSystemLogger().error(e);
                            isMatch=false;
                        }
                    }
                    if (isMatch) {
                        DataPoolCacheImpl.getInstance().reFreshCacheDataByPermission(fseNoExecute.getString(CmnConst.STAFF_UUID));
                        executeServiceChange(fseNoExecute,CmnConst.PRODUCT_SYS_STAFF_MOVEMENT);
                    }
                }
            }
        }
 
    }
 
    /**
     *     执行时间匹配
     * 
     * @param currentTime    系统标准时间戳
     * @param excutedateTime 数据执行时间戳
     * @param timeZone       时区时间差(分钟)
     * @param type           执行周期类型(1:年 2:月 3:日 4:时 5:分 6:秒)
     * @return
     */
    public boolean matchTime(long currentTime, Date excutedateTime, int timeZone, int type) {
 
        timeZone = timeZone * 60 * 1000; // 时间差(分钟)-->时间戳
        long endTime = currentTime + timeZone; // 执行数据最终时间戳
/*        
        int errorTime = 0; // 执行周期误差
 
        switch (type) {
        case 1:
            errorTime = 365 * 30 * 24 * 60 * 60 * 1000; // 一年误差
            break;
        case 2:
            errorTime = 30 * 24 * 60 * 60 * 1000; // 一月误差
            break;
        case 3:
            errorTime = 7 * 24 * 60 * 60 * 100; // 一星期误差
            break;
        case 4:
            errorTime = 24 * 60 * 60 * 1000; // 一天误差
            break;
        case 5:
            errorTime = 60 * 60 * 1000; // 一小时误差
            break;
        case 6:
            errorTime = 60 * 1000; // 一分钟误差
            break;
        default:
            break;
        }
 
        if (endTime - excutedateTime.getTime() < errorTime && endTime >= excutedateTime.getTime()) {
*/
        if (endTime >= excutedateTime.getTime()) {
            return true;
        }
        return false;
    }
 
    /**
     * 获取员工所属公司
     * 
     * @param uuid
     * @return
     * @throws BaseException
     */
    public int getStaffForCompanyTimeZone(String staff_uuid) throws BaseException {
        // 获取staff信息
        FieldSetEntity fseStaffInfo = baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_STAFFS, staff_uuid, false);
        if (fseStaffInfo == null) {
            return -1;
        }
        return getcompanyTImeZone(fseStaffInfo.getString(CmnConst.ORG_LEVEL_UUID));
    }
 
    /**
     * 根据公司uuid获取公司所属时区
     * 
     * @param org_level_uuid
     * @return
     * @throws BaseException
     */
    public int getcompanyTImeZone(String org_level_uuid) throws BaseException {
 
        // 获取公司配置时区信息
        FieldSetEntity fseCompanyTimeZone = baseDao.getFieldSetEntityByFilter(CmnConst.PRODUCT_SYS_COMPANY_TIME_ZONE,"org_level_uuid=?", new Object[] { org_level_uuid }, false);
        if (fseCompanyTimeZone == null) {
            return 0;
        }
 
        // 获取时区信息
        FieldSetEntity fseTimeZone = baseDao.getFieldSetEntity(CmnConst.PRODUCT_COMMON_TIME_ZONE,fseCompanyTimeZone.getString("zone_uuid"), false);
        if (fseTimeZone == null) {
            return -1;
        }
        return fseTimeZone.getInteger("utc_time_zone");
 
    }
 
    /**
     *     执行业务代码变更
     * @param fseNoExecute
     * @param table_name
     * @throws BaseException
     */
    public void executeServiceChange(FieldSetEntity fseNoExecute,String table_name) throws BaseException {
        FieldSetEntity fseServiceCode = baseDao.getFieldSetEntityByFilter("product_sys_org_levels_change_process", "is_used=1 and change_table_uuid =?",new Object[] { table_name }, false);
        if (fseServiceCode != null) {
            
            String serviceBeanName = fseServiceCode.getString("server_component_bean");
            String seriveMethodNmae = fseServiceCode.getString("bean_method");
            String methodParam = fseServiceCode.getString("in_paras_fields");
            String changeType=fseServiceCode.getString("chang_type");
            String resultInfo=null;
 
            try {
                boolean succ=serviceBean(serviceBeanName, seriveMethodNmae, methodParam, fseNoExecute);
                if (succ) {
                    fseNoExecute.setValue(CmnConst.RESULT_STATUS, 2);
                    baseDao.update(fseNoExecute);
                }else {
                    SpringMVCContextHolder.getSystemLogger().error("业务逻辑处理不成功!");
                }
                resultInfo="succ";
            } catch (Exception e) {
                fseNoExecute.setValue("logic_table_name", table_name);
                SpringMVCContextHolder.getSystemLogger().error(e);
                resultInfo=e.getMessage();
            } finally {
                FieldSetEntity fseChangHistory=new FieldSetEntity();
                FieldMetaEntity fseMate=new FieldMetaEntity();
                fseMate.setTableName(new Object[] {"product_sys_change_history"});
                fseChangHistory.setMeta(fseMate);
                fseChangHistory.setValue("change_table_uuid", table_name);
                fseChangHistory.setValue("chang_type", changeType);
                fseChangHistory.setValue("json_value", "");
                fseChangHistory.setValue("change_uuid", fseNoExecute.getUUID());
                fseChangHistory.setValue("remark", resultInfo);
                baseDao.add(fseChangHistory);
            }
        }
    }
    
    /**
     *     解析bean
     * @param serviceBeanName  beanName
     * @param seriveMethodNmae methodNmae
     * @param methodParam      传入参数
     * @param fseNoExecute     业务数据
     * @return
     * @throws InvocationTargetException 
     * @throws IllegalArgumentException 
     * @throws IllegalAccessException 
     * @throws Exception 
     */
    public boolean serviceBean(String serviceBeanName, String seriveMethodNmae, String methodParam,FieldSetEntity fseNoExecute) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
        
        boolean succ=true;
        Object bbean=SpringBeanUtil.getBean(serviceBeanName);
        SpringMVCContextHolder.getSystemLogger().error("1找到业务逻辑处理bean1:"+bbean);
        Object bean = applicationContext.getBean(serviceBeanName);
        SpringMVCContextHolder.getSystemLogger().error("找到业务逻辑处理bean:"+bean);
//        List<String> parameterList = new ArrayList<>();
//        String[] fields = methodParam.split(",");
//        int fieldLength = fields.length;
//        for (int i = 0; i < fieldLength; i++) {
//            parameterList.add(fseNoExecute.getString(fields[i]));
//        }
        // 判断执行方法
//        Method method = getMethod(bean, seriveMethodNmae, methodParam, fieldLength);
        Method method = getMethod(bean, seriveMethodNmae);
        if (method!=null) {
            SpringMVCContextHolder.getSystemLogger().error("找到业务逻辑处理方法:"+seriveMethodNmae);
            method.invoke(bean,fseNoExecute);
            SpringMVCContextHolder.getSystemLogger().error("业务逻辑处理完成");
        }else {
            SpringMVCContextHolder.getSystemLogger().error("未找到spring bean 方法:"+seriveMethodNmae);
            succ=false;
        }
        return succ;
    }
    /**
     *     解析方法
     * @param bean
     * @param methodName
     * @param parameterType
     * @param paramCOunt
     * @return
     * @throws Exception
     */
    public Method getMethod(Object bean, String methodName) {
        Class class1 = bean.getClass();
        Method[] methods = class1.getMethods();
        for (int j = 0; j < methods.length; j++) {
            Method method = methods[j];
            if (method.getName().equalsIgnoreCase(methodName) && method.getParameterTypes().length == 1) {
                Class parameterType = method.getParameterTypes()[0];
                SpringMVCContextHolder.getSystemLogger().info("找到"+methodName+"的参数:"+parameterType.getName());
                return method;
            }
        }
        return null;
    }
    /**
     *     解析方法
     * @param bean
     * @param methodName
     * @param parameterType
     * @param paramCOunt
     * @return
     * @throws Exception
     */
    public Method getMethod(Object bean, String methodName, String parameterType, int paramCOunt) {
        Class class1 = bean.getClass();
        Method[] methods = class1.getMethods();
        for (int j = 0; j < methods.length; j++) {
            Method method = methods[j];
            if (method.getName().equalsIgnoreCase(methodName) && method.getParameterTypes().length == paramCOunt) {
                Class[] parameterTypes = method.getParameterTypes();
                for (int i = 0; i < parameterTypes.length; i++) {
                    Class parameterTypeioy = parameterTypes[i];
                    if (parameterTypeioy == null) {
                        break;
                    }
                    if (parameterTypeioy instanceof Object) {
                        continue;
                    }
                    break;
                }
                return method;
            }
        }
        return null;
    }
    
    /**
     *     员工转正
     * @param fseNoExecute
     * @param staff_uuid
     * @throws
     * @return
     */
    @Transactional
    public boolean changeRegular(FieldSetEntity fseNoExecute,String staff_uuid) throws BaseException,Exception{
        baseDao.executeUpdate("update product_sys_staffs set staff_status=3 where uuid='"+staff_uuid+"'");
        String sql = "update product_sys_staffs set staff_status=3 where uuid=?";
        baseDao.executeUpdate(sql, new Object[] { staff_uuid });
        fseNoExecute.setValue(CmnConst.RESULT_STATUS, 1);
        baseDao.update(fseNoExecute);
        return true;
    }
    
    /**
     *     员工离职
     *     1.获取离职原因,变更员工状态
     *     2.变更员工账户状态
     *     3.变更员工下级员工上级领导
     *     4.变更执行状态
     * @param fs
     * @return
     * @throws BaseException
     */
    @Transactional
    public boolean changeDimission(FieldSetEntity fs) throws BaseException,Exception {
 
        String staff_uuid = fs.getString(CmnConst.APP_STAFF_UUID); // 离职申请人uuid
        String handover_staff_uuid = fs.getString(CmnConst.HANDOVER_STAFF_UUID); // 交接人uuid
 
        
        // 获取离职申请人信息
        FieldSetEntity staffsFS = baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_STAFFS, staff_uuid, false);
        if (staffsFS==null) {
            throw new BaseException(SystemCode.SYSTEM_DIMISSION_FAIL.getValue(),SystemCode.SYSTEM_DIMISSION_FAIL.getText(), this.getClass(), "changeDimission");
        }else {
            baseDao.listInternationDataTable(staffsFS, null);
        }
        
        //判断交接人是否为空
        if(!StringUtils.isEmpty(handover_staff_uuid)) {
            // 获取交接人信息
            FieldSetEntity handover_staffFS = baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_STAFFS, handover_staff_uuid, false);
            if (handover_staffFS==null) {
                throw new BaseException(SystemCode.SYSTEM_DIMISSION_FAIL.getValue(),SystemCode.SYSTEM_DIMISSION_FAIL.getText(), this.getClass(), "changeDimission");
            }
            //获取离职申请人编码
            String tricode = staffsFS.getString(CmnConst.TRICODE);
            String handOverTricode=handover_staffFS.getString(CmnConst.TRICODE);
            
            boolean update2=baseDao.executeUpdate("update product_sys_staffs set direct_leader_code=? where direct_leader_code=?", new Object[] {handOverTricode,tricode});
            if (!update2) {
                throw new BaseException(SystemCode.SYSTEM_DIMISSION_FAIL.getValue(),SystemCode.SYSTEM_DIMISSION_FAIL.getText(), this.getClass(), "changeDimission");
            }
        }
        
        //获取离职原因
        String dimission_reason = fs.getString("dimission_reason");
        if (CmnConst.RESIGN_REASON_RETIREMENT.equals(dimission_reason)) {
            staffsFS.setValue("staff_status", 7);
        } else {
            staffsFS.setValue("staff_status", 6);
        }
        
        //修改员工状态
        boolean update = baseDao.update(staffsFS);
        
        if (!update) {
            throw new BaseException(SystemCode.SYSTEM_DIMISSION_FAIL.getValue(),SystemCode.SYSTEM_DIMISSION_FAIL.getText(), this.getClass(), "changeDimission");
        }
        
        
        
        //获取对应user登录信息
        String user_id = staffsFS.getString("user_id");
        FieldSetEntity userFS = baseDao.getFieldSetEntityByFilter("product_sys_users", "user_id=?",new String[] { user_id }, false);
        if (userFS == null) {
            throw new BaseException(SystemCode.SYSTEM_DIMISSION_FAIL.getValue(),SystemCode.SYSTEM_DIMISSION_FAIL.getText(), this.getClass(), "changeDimission");
        }
        //禁用登录账户
        userFS.setValue("status", 0);
        boolean updateUser = baseDao.update(userFS);
        
        if (!updateUser) {
            throw new BaseException(SystemCode.SYSTEM_DIMISSION_FAIL.getValue(),SystemCode.SYSTEM_DIMISSION_FAIL.getText(), this.getClass(), "changeDimission");
        }
        
        //修改定时任务执行状态
        fs.setValue(CmnConst.RESULT_STATUS, "1");
        boolean update3 = baseDao.update(fs);
        if (!update3) {
            throw new BaseException(SystemCode.SYSTEM_DIMISSION_FAIL.getValue(),SystemCode.SYSTEM_DIMISSION_FAIL.getText(), this.getClass(), "changeDimission");
        }
        return update3;
    }
 
    /**
     *     员工变更
     *     1.变更员工信息
     *     2.变更执行状态
     * @param fseStaffChange
     * @return
     * @throws BaseException
     */
    @Transactional
    public boolean staffChange(FieldSetEntity fseStaffChange) throws BaseException,Exception {
        boolean flag = true;
        
        //查询变更员工信息
        FieldSetEntity fseStaff = baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_STAFFS, fseStaffChange.getString(CmnConst.STAFF_UUID), false);
        
        
        if (fseStaff==null) {
            throw new BaseException(SystemCode.SYSTEM_STAFF_INFO_NO_EXIST.getValue(), SystemCode.SYSTEM_STAFF_INFO_NO_EXIST.getText());
        }else {
            baseDao.listInternationDataTable(fseStaff, null);
        }
        
        //公司是否变化
        if (!fseStaffChange.getString("original_org_level_uuid").equals(fseStaffChange.getString("transferred_org_level_uuid"))) {
            fseStaff.setValue(CmnConst.ORG_LEVEL_UUID, fseStaffChange.getString("transferred_org_level_uuid"));
        }
        
        //部门是否变化
        if (!fseStaffChange.getString("original_staff_dept_uuid").equals(fseStaffChange.getString(CmnConst.TRANSFERRED_STAFF_DEPT_UUID))) {
            fseStaff.setValue("dept_uuid", fseStaffChange.getString(CmnConst.TRANSFERRED_STAFF_DEPT_UUID));
            
            //获取新部门信息
            FieldSetEntity fseOrgLevel = baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_ORG_LEVELS,fseStaffChange.getString(CmnConst.TRANSFERRED_STAFF_DEPT_UUID), false);
            if (fseOrgLevel==null) {
                throw new BaseException(SystemCode.SYSTEM_GET_DEPARTMENTINFO_FAIL.getValue(), SystemCode.SYSTEM_GET_DEPARTMENTINFO_FAIL.getText());
            }
            String orgLevelCode = fseOrgLevel.getString(CmnConst.ORG_LEVEL_CODE);
            
            fseStaff.setValue(CmnConst.TRICODE, codeService.createCode(CmnConst.PRODUCT_SYS_STAFFS, CmnConst.TRICODE, orgLevelCode));
        }
        
        //岗位是否变化
        if (!fseStaffChange.getString("original_staff_post_uuid").equals(fseStaffChange.getString("transferred_staff_post_uuid"))) {
            fseStaff.setValue("job_post_uuid", fseStaffChange.getString("transferred_staff_post_uuid"));
        }
        
        //岗位等级是否变化
        if (!fseStaffChange.getString("original_staff_grade_uuid").equals(fseStaffChange.getString("transferred_staff_grade_uuid"))) {
            fseStaff.setValue("job_post_grade_uuid", fseStaffChange.getString("transferred_staff_grade_uuid"));
        }
        
        //判断角色是否变化
        if (!fseStaffChange.getString("original_role_uuid").equals(fseStaffChange.getString("transferred_role_uuid"))) {
            fseStaff.setValue("role_uuids", fseStaffChange.getString("transferred_role_uuid"));
        }
        
        //上级领导变化
        String originLeaderUUID=fseStaffChange.getString("original_leader_uuid");
        String newLeaderUUID=fseStaffChange.getString("transferred_leader_uuid");
        //判断直属领导是否变化
//        if (!fseStaffChange.getString("original_leader_uuid").equals(fseStaffChange.getString("transferred_leader_uuid"))) {
//            fseStaff.setValue(CmnConst.DIRECT_LEADER_CODE, fseStaffChange.getString(CmnConst.DIRECT_LEADER_CODE));
            
            if (!originLeaderUUID.equals(newLeaderUUID)) {
                FieldSetEntity fseNewLeader=null;        //新领导
                String newLeaderCode="";
                String originLeaderCode=fseStaff.getString(CmnConst.LEADER_TRICODE);
                if (!StringUtils.isEmpty(originLeaderUUID) && StringUtils.isEmpty(newLeaderUUID)) {    //上级领导 有-->无
                    newLeaderCode=codeService.createCode(CmnConst.PRODUCT_SYS_STAFFS, CmnConst.LEADER_TRICODE, "");
                } else {    //上级领导 无-->有 或  旧-->新
                    fseNewLeader=baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_STAFFS, newLeaderUUID, false);
                    newLeaderCode=codeService.createCode(CmnConst.PRODUCT_SYS_STAFFS, CmnConst.LEADER_TRICODE, fseNewLeader.getString(CmnConst.LEADER_TRICODE));
                }
                fseStaff.setValue(CmnConst.LEADER_TRICODE, newLeaderCode);
                staffManagerService.changeSubLeaderTricode(originLeaderCode,newLeaderCode);
            }
//        }
        
        if (!StringUtils.isEmpty(fseStaffChange.getString("original_cost_center_uuid")) && !StringUtils.isEmpty(fseStaffChange.getString(CmnConst.COST_CENTER_UUID))) {
            fseStaff.setValue(CmnConst.COST_CENTER_UUID, fseStaffChange.getString(CmnConst.COST_CENTER_UUID));
            baseDao.executeUpdate("update product_sys_staff_cost_center set cost_center_uuid=? where staff_uuid=?", new Object[] {fseStaffChange.getString(CmnConst.COST_CENTER_UUID),fseStaffChange.getString(CmnConst.STAFF_UUID)});
        }
        //人员信息变更
        flag = baseDao.update(fseStaff);
        if (!flag) {
            throw new BaseException(SystemCode.SYSTEM_STAFF_UPDATE_FIAL.getValue(), SystemCode.SYSTEM_STAFF_UPDATE_FIAL.getText());
        }
        
        //设置人员变更数据状态
        fseStaffChange.setValue(CmnConst.RESULT_STATUS, "1");
        //变更数据状态
        flag = baseDao.update(fseStaffChange);
        
        return flag;
    }
 
    /**
     *     部门变更
     * @param fse
     * @return
     * @throws BaseException
     */
    public void deptChange(long currentTime) throws BaseException {
        
        DataTableEntity dtNoExecute=baseDao.listTable(CmnConst.PRODUCT_SYS_ORG_LEVELS_CHANGE, "result_status=0 OR result_status=1");
        if (dtNoExecute!=null && dtNoExecute.getRows()>0) {
            for (int i = 0; i < dtNoExecute.getRows(); i++) {
                FieldSetEntity fseNoExecute=dtNoExecute.getFieldSetEntity(i);
                int result_status = fseNoExecute.getInteger(CmnConst.RESULT_STATUS);
                String org_level_uuid = fseNoExecute.getString(CmnConst.ORG_LEVEL_UUID);
                Date excutedateTime = fseNoExecute.getDate("change_effective"); // 执行时间
                int timeZone = getcompanyTImeZone(org_level_uuid);
                
                // 判断时间是否匹配
                boolean isMatch = matchTime(currentTime, excutedateTime, timeZone, 4);
 
                if (isMatch) {
                    
                    String deptChangeType = fseNoExecute.getString("change_status_uuid");
                    
                    if (result_status == 0) {
                        try {
                            ITimeTaskService service =(ITimeTaskService)getProxyInstance(timeTaskChangeServices);
                            if ("1".equals(deptChangeType)) {
                                isMatch = service.deptCancel(fseNoExecute);
                            } else if ("2".equals(deptChangeType)) {
                                isMatch = service.deptMerge(fseNoExecute);
                            } else if ("3".equals(deptChangeType)) {
                                isMatch = service.deptMove(fseNoExecute);
                            }
                        } catch (BaseException e) {
                            SpringMVCContextHolder.getSystemLogger().error(e);
                            isMatch=false;
                        } catch (Exception e) {
                            SpringMVCContextHolder.getSystemLogger().error(e);
                            isMatch=false;
                        }
                    }
                    if (isMatch) {
                        DataPoolCacheImpl.getInstance().reFreshCacheDataByPermission(fseNoExecute.getString(CmnConst.ORG_LEVEL_UUID));
                        executeServiceChange(fseNoExecute, CmnConst.PRODUCT_SYS_ORG_LEVELS_CHANGE);
                    }
                }
            }
        }
    }
    
    /**
     *     部门撤消
     * @param fse
     * @return
     * @throws BaseException
     */
    @Transactional
    public boolean deptCancel(FieldSetEntity fse) throws BaseException {
 
        String originDeptUuid=fse.getString(CmnConst.ORIGIN_DEPT_UUID);
        FieldSetEntity fseOriginDept=baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_ORG_LEVELS, originDeptUuid, false);
        if (fseOriginDept==null) {
            throw new BaseException(SystemCode.SYSTEM_DEPT_CAHNGE_FIND_FAIL.getValue(), SystemCode.SYSTEM_DEPT_CAHNGE_FIND_FAIL.getText());
        }
        String originDeptCode=fseOriginDept.getString(CmnConst.ORG_LEVEL_CODE);
        
        //获取所有相关部门信息
        DataTableEntity dtDepts=baseDao.listTable(CmnConst.PRODUCT_SYS_ORG_LEVELS, "org_level_code like '"+originDeptCode+"%'", new Object[] {});
        baseDao.listInternationDataTable(dtDepts, null);
        if (dtDepts!=null && dtDepts.getRows()>0) {
            Object [] uuids = dtDepts.getUuids();
            List<Object> params = new ArrayList<Object>();
            params.addAll(Arrays.asList(uuids));
            
            //判断是否包含员工未移动
            DataTableEntity dtstaff=baseDao.listTable(CmnConst.PRODUCT_SYS_STAFFS, BaseUtil.buildQuestionMarkFilter("dept_uuid", params.size(), true), params.toArray());
            if (dtstaff!=null && dtstaff.getRows()>0) {
                return false;
            }
 
            //遍历相关部门
            for (int i = 0; i < dtDepts.getRows(); i++) {
                //标记相关部门未撤消
                FieldSetEntity fseDept=dtDepts.getFieldSetEntity(i);
                fseDept.setValue("org_level_status", 1);
            }
            baseDao.update(dtDepts);
        }
        fse.setValue(CmnConst.RESULT_STATUS, 1);
        
        return baseDao.update(fse);
    }
 
    /**
     *     部门合并
     *  1:变更后代部门国际化全称  
     *  2:变更后代部门组织机构编码  
     *  3:变更原部门岗位至合并部门  
     *  4:变更原部门员工至合并部门  
     *  5:重新生成相关部门下员工的员工编码
     *     6.将原部门标记为被合并
     *     7.将变更标识为1
     * @param fse
     * @return
     * @throws BaseException
     */
    @Transactional
    public boolean deptMerge(FieldSetEntity fse) throws BaseException {
        
        boolean flag = true;
        
        
        String originOrgUuid = fse.getString(CmnConst.ORG_LEVEL_UUID);        //合并部门所属公司UUID
        String mergeOrgUuid = fse.getString("new_org_level_uuid");    //保留部门所属公司UUID
        String originDeptUuid = fse.getString(CmnConst.ORIGIN_DEPT_UUID);    //获取原部门UUID
        String mergeDeptUuid = fse.getString("new_dept_uuid");    //获取保留部门UUID
        
        //获取原部门国际化信息
        FieldSetEntity fseOriginDept = baseDao.listInternationDataTable(baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_ORG_LEVELS, originDeptUuid, false),null);
        
        //获取保留部门国际化信息
        FieldSetEntity fseMergeDept = baseDao.listInternationDataTable(baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_ORG_LEVELS, mergeDeptUuid, false),null);
        
        if (fseMergeDept == null || fseOriginDept==null) {
            throw new BaseException(SystemCode.SYSTEM_DEPT_MERGE_NO_EXIST.getValue(), SystemCode.SYSTEM_DEPT_MERGE_NO_EXIST.getText());
        }
 
        //原部门国际化全称
        Map<String, String> originDeptNameLanguage = InternationalLanguage.parseLanguage(fseOriginDept.getSubDataTable(CmnConst.ORG_LEVEL_ALL));
        //新部门国际化全称
        Map<String, String> mergeDeptParentAllLanguage = InternationalLanguage.parseLanguage(fseMergeDept.getSubDataTable(CmnConst.ORG_LEVEL_ALL));
        
        //创建国际化语言变更对象
        Map<String, String> changeLanguage=InternationalLanguage.replacelanguage(originDeptNameLanguage, mergeDeptParentAllLanguage);
        
        String originDeptCode = fseOriginDept.getString(CmnConst.ORG_LEVEL_CODE);    //获取原部门编码
        String mergeDeptCode = fseMergeDept.getString(CmnConst.ORG_LEVEL_CODE);    //获取保留部门编码
        
        //获取所有后代部门信息
        DataTableEntity dtDepts=baseDao.listTable(CmnConst.PRODUCT_SYS_ORG_LEVELS, "org_level_code_parent like'"+originDeptCode+"%'", new Object[]{});
        if (dtDepts!=null && dtDepts.getRows()>0) {
            Object[] uuids = dtDepts.getUuids();
            if (uuids != null) {
                // 变更所有下级组织机构国际化全称
                for ( Map.Entry<String, String> entries : originDeptNameLanguage.entrySet() ){
                    String key = entries.getKey();
                    String originAll = originDeptNameLanguage.get(key);
                    String newAll = changeLanguage.get(key);
                    List<Object> params = new ArrayList<>();
                    params.add(originAll);
                    params.add(newAll);
                    params.addAll(Arrays.asList(uuids));
                    params.add(key);
                    String sql = "update product_sys_language_cont_values set field_value=replace(field_value,?,?) where table_name= 'product_sys_org_levels' and field_name='org_level_all' and "
                            + BaseUtil.buildQuestionMarkFilter(CmnConst.DATA_UUID, uuids.length, true) + " and language_code=?";
                    baseDao.executeUpdate(sql, params.toArray());
                }
            }
        }
        
        //map(变更部门uuid,新编码) or map("result","true or false"),变更合并部门所有子部门的组织机构编码,及员工编码
        Map<String, Object> orgLevelCodeMap = new HashMap<String, Object>();
        orgLevelCodeMap = changeDeptSub(originDeptCode, mergeDeptCode, orgLevelCodeMap);
        
 
        //判断修改是出现否错误
        if (!(Boolean) orgLevelCodeMap.get(RESULT)) {
            throw new BaseException(SystemCode.SYSTEM_CODE_CREATE_FIAL.getValue(), SystemCode.SYSTEM_CODE_CREATE_FIAL.getText());
        }
 
        //变更合并部门的岗位至保留部门
        if (!originOrgUuid.equals(mergeOrgUuid)) {
            baseDao.executeUpdate("update product_sys_job_posts set org_level_uuid=? where dept_uuid=?", new Object[] {mergeOrgUuid,originOrgUuid});
        }
        baseDao.executeUpdate("update product_sys_job_posts set dept_uuid=? where dept_uuid=?", new Object[] {mergeDeptUuid,originDeptUuid});
        
        //变更合并部门的人员至保留部门
        if (!originOrgUuid.equals(mergeOrgUuid)) {
            baseDao.executeUpdate("update product_sys_staffs set org_level_uuid=? where dept_uuid=?", new Object[] {mergeOrgUuid,originOrgUuid});
        }
        baseDao.executeUpdate("update product_sys_staffs set dept_uuid=? where dept_uuid=?", new Object[] {mergeDeptUuid,originDeptUuid});
        
        
        //变更合并部门的人员组织机构编码
        orgLevelCodeMap.put(originDeptCode, mergeDeptCode);
        flag = changStaffCode(orgLevelCodeMap);
 
        //变更当前部门状态为被合并
        if (flag == true) {
            fseOriginDept.setValue("org_level_status", 2);
            flag = baseDao.update(fseOriginDept);
        }
        fse.setValue(CmnConst.RESULT_STATUS, 1);
        
        return baseDao.update(fse);
    }
 
    /**
     *     部门迁移
     *     1.变更原部门及后代部门国际化全称
     *     2.判断是否跨公司迁移(变更岗位和员工所属公司UUID)
     *     3.变更原部门及后代部门的组织机构编码及父编码
     *     4.变更原部门及后代部门下的员工编码
     *     5.将变更标识为1
     * @param fse
     * @param originDeptCode 原部门编码
     * @param originDeptUuid 原部门uuid
     * @return
     * @throws BaseException
     */
    @Transactional
    public boolean deptMove(FieldSetEntity fse) throws BaseException {
        boolean flag = true;
        
        String originDeptUuid=fse.getString(CmnConst.ORIGIN_DEPT_UUID);    //获取原部门UUID
        String moveDeptUuid = fse.getString("new_dept_uuid");        //获取迁入部门uuid
        String originOrgUuid=fse.getString(CmnConst.ORG_LEVEL_UUID);        //原部门所属公司
        String moveOrgUuid=fse.getString("new_org_level_uuid");    //迁入部门所属公司
        if (StringUtils.isEmpty(moveDeptUuid)) {    //杜洪波 updateTime 2020-12-17 09:48:00
            moveDeptUuid=moveOrgUuid;
        }
        
        //获取原部门国际化信息
        FieldSetEntity fseOriginDept=baseDao.listInternationDataTable(baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_ORG_LEVELS, originDeptUuid, false),null);
        
        //获取迁入部门国际化信息
        FieldSetEntity fseMoveDept = baseDao.listInternationDataTable(baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_ORG_LEVELS, moveDeptUuid, false),null);
        if (fseMoveDept == null || fseOriginDept==null) {
            return false;
        }
 
        String originDeptCode = fseOriginDept.getString(CmnConst.ORG_LEVEL_CODE);    //获取原部门编码
        String originDeptParentCode = fseOriginDept.getString(CmnConst.ORG_LEVEL_CODE_PARENT);    //获取原部门父级编码
        String moveDeptCode = fseMoveDept.getString(CmnConst.ORG_LEVEL_CODE);    //获取迁入部门编码
        
        //获取原部门上级国际化信息
        FieldSetEntity fseOriginDeptParent = baseDao.listInternationDataTable(baseDao.getFieldSetEntityByFilter(CmnConst.PRODUCT_SYS_ORG_LEVELS, "org_level_code=?", new Object[] {originDeptParentCode}, false),null);
        if (fseOriginDeptParent==null) {
            return false;
        }
        
        //原部门父级组织机构国际化全称
        Map<String, String> originDeptParentLanguage = InternationalLanguage.parseLanguage(fseOriginDeptParent.getSubDataTable(CmnConst.ORG_LEVEL_ALL));
        //新迁入部门国际化全称
        Map<String, String> moveDeptParentAllLanguage = InternationalLanguage.parseLanguage(fseMoveDept.getSubDataTable(CmnConst.ORG_LEVEL_ALL));
                
        //创建国际化语言变更对象
        Map<String, String> changeLanguage=InternationalLanguage.replacelanguage(originDeptParentLanguage, moveDeptParentAllLanguage);
                
        //获取所有后代部门信息
        DataTableEntity dtDepts=baseDao.listTable(CmnConst.PRODUCT_SYS_ORG_LEVELS, "org_level_code like'"+originDeptCode+"%'", new Object[]{});
        if (dtDepts!=null && dtDepts.getRows()>0) {
            Object[] uuids = dtDepts.getUuids();
            if (uuids != null) {
                //变更所有下级组织机构国际化全称
                for ( Map.Entry<String, String> entries : originDeptParentLanguage.entrySet() ){
                    String key = entries.getKey();
                    String originAll = originDeptParentLanguage.get(key);
                    String newAll = changeLanguage.get(key);
                    List<Object> params = new ArrayList<Object>();
                    params.add(originAll);
                    params.add(newAll);
                    params.addAll(Arrays.asList(uuids));
                    params.add(key);
                    String sql = "update product_sys_language_cont_values set field_value=REPLACE(field_value,?,?) where table_name= 'product_sys_org_levels' and field_name='org_level_all' and "
                            + BaseUtil.buildQuestionMarkFilter(CmnConst.DATA_UUID, uuids.length, true) + " and language_code=? ";
                    baseDao.executeUpdate(sql, params.toArray());
                }
                
                //判断迁移前后公司是否修改,如已修改,则变更员工所属公司,岗位所属公司
                if (!originOrgUuid.equals(moveOrgUuid)) {
                    baseDao.executeUpdate("update product_sys_staffs set org_level_uuid=? where " +  BaseUtil.buildQuestionMarkFilter(CmnConst.DATA_UUID, uuids.length, true), new Object[] {moveOrgUuid,Arrays.asList(uuids)});
                    baseDao.executeUpdate("update product_sys_job_posts set org_level_uuid=? where " +  BaseUtil.buildQuestionMarkFilter(CmnConst.DATA_UUID, uuids.length, true), new Object[] {moveOrgUuid,Arrays.asList(uuids)});
                }
            }
        }
        
        //生成新部门编码
        String newMoveCode = codeService.createCode(CmnConst.PRODUCT_SYS_ORG_LEVELS, CmnConst.ORG_LEVEL_CODE, moveDeptCode);
        fseOriginDept.setValue(CmnConst.ORG_LEVEL_CODE, newMoveCode);
        fseOriginDept.setValue(CmnConst.ORG_LEVEL_CODE_PARENT, moveDeptCode);
        baseDao.update(fseOriginDept);
        
        //变更迁移部门及后代部门组织机构编码及父编码
        StringBuilder sqlSubDeptChangeCode=new StringBuilder();
        sqlSubDeptChangeCode.append(" update product_sys_org_levels ");
        sqlSubDeptChangeCode.append(" set org_level_code=concat(replace(substring(org_level_code,1,locate(?,org_level_code)+length(?)),?,?),substring(org_level_code,locate(?,org_level_code)+length(?)+1)), ");
        sqlSubDeptChangeCode.append(" org_level_code_parent=concat(replace(substring(org_level_code_parent,1,locate(?,org_level_code_parent)+length(?)),?,?),substring(org_level_code_parent,locate(?,org_level_code_parent)+length(?)+1)) ");
        sqlSubDeptChangeCode.append(" where org_level_code like ? ");
        
        baseDao.executeUpdate(sqlSubDeptChangeCode.toString(), new Object[] {originDeptCode,originDeptCode,originDeptCode,newMoveCode,originDeptCode,originDeptCode,
                originDeptCode,originDeptCode,originDeptCode,newMoveCode,originDeptCode,originDeptCode,originDeptCode+"-%"});
        
        //变更迁移部门及后代部门的员工编码和上级领导编码
        StringBuilder sqlStaffChangeCode=new StringBuilder();
        sqlStaffChangeCode.append(" update product_sys_staffs ");
        sqlStaffChangeCode.append(" set tricode=concat(replace(substring(tricode,1,locate(?,tricode)+length(?)),?,?),substring(tricode,locate(?,tricode)+length(?)+1)), ");
        sqlStaffChangeCode.append(" direct_leader_code=concat(replace(substring(direct_leader_code,1,locate(?,direct_leader_code)+length(?)),?,?),substring(direct_leader_code,locate(?,direct_leader_code)+length(?)+1)) ");
        sqlStaffChangeCode.append(" where tricode like ? ");
        
        flag=baseDao.executeUpdate(sqlStaffChangeCode.toString(), new Object[] {originDeptCode,originDeptCode,originDeptCode,newMoveCode,originDeptCode,originDeptCode,originDeptCode,originDeptCode,originDeptCode,newMoveCode,originDeptCode,originDeptCode,originDeptCode+"%"});
        
        if (flag) {
            fse.setValue(CmnConst.RESULT_STATUS, 1);
        }
        
        return baseDao.update(fse);
    }        
 
    /**
     *     更改子部门的部门编码和父级部门编码(部门合并)
     * @param originDeptCode 原部门编码
     * @param newDeptCode    保留部门编码
     * @param orgLevelCodeMap    相关部门集合<uuid,code>
     * @return
     * @throws BaseException
     */
    @Transactional
    public Map<String, Object> changeDeptSub(String originDeptCode, String newDeptCode,Map<String, Object> orgLevelCodeMap) throws BaseException {
        
        //根据部门编码,查找相应子级部门
        boolean flag = true;
        DataTableEntity dtOrgLevelSub = baseDao.listInternationDataTable(baseDao.listTable(CmnConst.PRODUCT_SYS_ORG_LEVELS, "org_level_code_parent=?",new Object[] { originDeptCode }),null);
        FieldSetEntity fseOrgLevelSub = null;
        if (dtOrgLevelSub.getRows() > 0) {
            for (int i = 0; i < dtOrgLevelSub.getRows(); i++) {
                fseOrgLevelSub = dtOrgLevelSub.getData().get(i);
                // 获取子部门合并前的编码
                String originDeptSubCode = fseOrgLevelSub.getString(CmnConst.ORG_LEVEL_CODE);
                // 创建子部门新编码
                String newDeptSubCode = codeService.createCode(CmnConst.PRODUCT_SYS_ORG_LEVELS, CmnConst.ORG_LEVEL_CODE, newDeptCode);
                fseOrgLevelSub.setValue(CmnConst.ORG_LEVEL_CODE, newDeptSubCode);
                fseOrgLevelSub.setValue("org_level_code_parent", newDeptCode);
                // 执行修改
                flag = baseDao.update(fseOrgLevelSub);
                DataPoolCacheImpl.getInstance().reloadCodeManager(CmnConst.PRODUCT_SYS_ORG_LEVELS, CmnConst.ORG_LEVEL_CODE);
                if (!flag) {
                    orgLevelCodeMap.put(RESULT, flag);
                    return orgLevelCodeMap;
                }
                orgLevelCodeMap.put(originDeptSubCode, newDeptSubCode);
                // 递归调用,遍历下级子部门
                orgLevelCodeMap = changeDeptSub(originDeptSubCode, newDeptSubCode, orgLevelCodeMap);
            }
        }
        orgLevelCodeMap.put(RESULT, flag);
        return orgLevelCodeMap;
    }
 
    /**
     *     更改人员编码(部门合并)
     * @return boolean
     * @throws BaseException
     */
    @Transactional
    public boolean changStaffCode(Map<String, Object> orgLevelCodeMap) throws BaseException {
        boolean flag = true;
        for ( Map.Entry<String, Object> entries : orgLevelCodeMap.entrySet() ){
            String key = entries.getKey();
            if (RESULT.equals(key)) {
                String originDeptCode=key;    //原部门编码
                String newDeptCode=orgLevelCodeMap.get(key).toString();    //新部门编码
                
                StringBuilder sqlStaffChangeCode=new StringBuilder();
                sqlStaffChangeCode.append(" update product_sys_staffs ");
                sqlStaffChangeCode.append(" set tricode=concat(replace(substring(tricode,1,locate(?,tricode)+length(?)),?,?),substring(tricode,locate(?,tricode)+length(?)+1)), ");
                sqlStaffChangeCode.append(" direct_leader_code=concat(replace(substring(direct_leader_code,1,locate(?,direct_leader_code)+length(?)),?,?),substring(direct_leader_code,locate(?,direct_leader_code)+length(?)+1)) ");
                sqlStaffChangeCode.append(" where tricode like ? ");
                
                flag=baseDao.executeUpdate(sqlStaffChangeCode.toString(), new Object[] {originDeptCode,newDeptCode,originDeptCode,newDeptCode,originDeptCode,newDeptCode,originDeptCode,newDeptCode,originDeptCode,newDeptCode,originDeptCode,newDeptCode,originDeptCode+"%"});
            }
        }
        return flag;
    }
}