游畅
2022-04-29 0d5e86be0672e62989491f8f36176ca38204d119
force-app/main/default/classes/ControllerUtil.cls
@@ -2845,7 +2845,7 @@
                                  Visitor1__c, Visitor2__c, Visitor3__c, Visitor4__c, Visitor5__c, Visitor1_ID__c, Visitor2_ID__c, Visitor3_ID__c, Visitor4_ID__c, Visitor5_ID__c,
                                  Purpose_Type__c, Location, Related_Opportunity1__c, Related_Service1__c, Related_Opportunity1_ID__c, Related_Service1_ID__c, WS_flg__c,
                                  Related_Opportunity2__c, Related_Opportunity3__c, Related_Opportunity4__c, Related_Opportunity5__c,OPDPlan_Flag__c,
                                  Related_Opportunity2_ID__c, Related_Opportunity3_ID__c, Related_Opportunity4_ID__c, Related_Opportunity5_ID__c,
                                  Related_Opportunity2_ID__c, Related_Opportunity3_ID__c, Related_Opportunity4_ID__c, Related_Opportunity5_ID__c,Opd_Plan__c,
                                  Activity_Purpose__c, Activity_PurposeFSE__c, Activity_PurposeEscFSE__c, Purpose_TypeFSE__c, Purpose_TypeEscFSE__c,EventStatus__c,cancelReason__c,cancelReasonOther__c,cancelReasonSelect__c,cancelReasonSelectFSE__c,delayReason__c,delayReasonOther__c,delayReasonSelect__c,delayReasonSelectFSE__c,delayToDate__c  
                                  from Event where WS_flg__c = false and ActivityDate = :whereDate and OwnerId = :ur.Id and EventStatus__c not in ('04 取消','05 延期','06 关闭','07 未执行') order by StartDateTime];
        return calenderList;
@@ -2880,6 +2880,7 @@
        return new Map<Id, Contact>([Select Id, User__c From Contact Where Id IN: contactIds and User__r.isActive = true]);
    }
    /**
     * add      2021/12/23        wangweipeng                 satrt
     * [updateFutureOds 更新ods的user__c字段]
@@ -2910,17 +2911,20 @@
    }
    //@future
    public static void upsertFutureContactInterface(List<String> userEmployeeNoList) {
        // 社内员工のレコードタイプ
        Id rtId = '01210000000Qtky';
        // 现有联系人
        Map<String, Contact> conMap = new Map<String, Contact>();
        // UserToContact の 変更したか にて判断した項目です
        List<User> usrList = [select Id, Notes_File_Name__c,FirstName, LastName, Email, Mobile_Phone__c, Employee_No__c, Work_Location__c, Post__c, Job_Category__c, Hire_Date__c, Gender__c, Dept__c, Pregnant_Rest__c, Salesdepartment__c, Stay_or_not__c,IsMEBG__c, Work_Location_HR__c from User where Employee_No__c IN :userEmployeeNoList];
        //20220425  LLIU-CCY9TA you 查询post的地方换成 HR_Post__c
        List<User> usrList = [select Id,PositionSubsequence__c, Notes_File_Name__c,FirstName, LastName, Email, Mobile_Phone__c, Employee_No__c, Work_Location__c, HR_Post__c,Post__c, Job_Category__c, Hire_Date__c, Gender__c, Dept__c, Pregnant_Rest__c, Salesdepartment__c, Stay_or_not__c,IsMEBG__c, Work_Location_HR__c from User where Employee_No__c IN :userEmployeeNoList];
        List<Contact> conList = [select Id,Notes_File_Name__c, User__c, Employee_No_manual__c,Isactive__c,IsMEBG__c, Work_Location_HR__c from Contact where Employee_No_manual__c IN :userEmployeeNoList and RecordTypeId = :rtId];
        for (Contact con : conList) {
            //conMap.put(con.Employee_No_manual__c, con);
            conMap.put(con.Employee_No_manual__c.toLowerCase(), con);
        }
        system.debug('youchangtest1');
        List<Contact> upsertList = new List<Contact>();
        for (User local : usrList) {
            //update                          wangweipeng                2021/11/19  
@@ -2954,7 +2958,8 @@
                //用户的工作地(人事)改变更新到联系人上 thh 2022-02-16 start
                tmp.Work_Location_HR__c = local.Work_Location_HR__c;
                //用户的工作地(人事)改变更新到联系人上 thh 2022-02-16 end
                tmp.Post_picklist__c = local.Post__c;
                tmp.Post_picklist__c = local.Post__c; //20220426  LLIU-CCY9TA you用户的 Post__c ,还是对应联系人
                tmp.HR_Post__c = local.HR_Post__c;//HR通用职级 //20220425  LLIU-CCY9TA you
                tmp.Job_Category_picklist__c = local.Job_Category__c;
                tmp.Hire_date_text__c = local.Hire_Date__c; 
                tmp.Gender_text__c = local.Gender__c; 
@@ -2963,10 +2968,15 @@
                tmp.Salesdepartment_Text__c = local.Salesdepartment__c;
                tmp.Stay_or_not__c = local.Stay_or_not__c;
                tmp.IsMEBG__c = local.IsMEBG__c;//是否MEBG
                //20220428 LLIU-CDW5ZW you start
                tmp.PositionSubsequence__c = local.PositionSubsequence__c;
                //20220428 LLIU-CDW5ZW you end
                if(String.isNotBlank(local.Stay_or_not__c)){
                    tmp.Isactive__c = local.Stay_or_not__c == '在职' ? '有效':'无效';
                }
                upsertList.add(tmp);
                system.debug('youchangtest2'+tmp.HR_Post__c);
            } else {
                // 新做联系人
                Contact tmp = new Contact();
@@ -2984,7 +2994,8 @@
                tmp.Work_Location_HR__c = local.Work_Location__c;
                tmp.Work_Location_picklist__c = local.Work_Location__c;
                //如果根据HR信息新建用户,则把HR信息的工作地传给用户的工作地和工作地(人事) thh 2022-02-16 end
                tmp.Post_picklist__c = local.Post__c;
                tmp.Post_picklist__c = local.Post__c;//20220426  LLIU-CCY9TA you用户的 Post__c ,还是对应联系人
                tmp.HR_Post__c = local.HR_Post__c;//HR通用职级 //20220425  LLIU-CCY9TA you
                tmp.Job_Category_picklist__c = local.Job_Category__c;
                tmp.Hire_date_text__c = local.Hire_Date__c; 
                tmp.Gender_text__c = local.Gender__c; 
@@ -2993,15 +3004,19 @@
                tmp.Salesdepartment_Text__c = local.Salesdepartment__c;
                tmp.Stay_or_not__c = local.Stay_or_not__c;
                tmp.IsMEBG__c = local.IsMEBG__c;//是否MEBG
                //20220428 LLIU-CDW5ZW you start
                tmp.PositionSubsequence__c = local.PositionSubsequence__c;
                //20220428 LLIU-CDW5ZW you end
                if(String.isNotBlank(local.Stay_or_not__c)){
                    tmp.Isactive__c = '在职'.equals(local.Stay_or_not__c) ? '有效':'无效';
                }
                upsertList.add(tmp);
                system.debug('youchangtest3'+tmp.HR_Post__c);
            }
        }
        upsert upsertList;
    }
// 20220425 you 经查看 此对象应该是没有任何地方用到了,可以注释掉
    public static void updateFutureUserByContact(List<String> userEmployeeNoList) {
        // 现有用户
        Map<String, User> usrMap = new Map<String, User>();
@@ -3045,13 +3060,31 @@
    //add   wangweipeng                      2021/11/18               start
    //根据ods的员工编码,更新或新增 user表的数据
    public static void updateFutureOdsByUser(List<String> userEmployeeNoList) {
        //20220426  LLIU-CCY9TA you start 通用职衔和user上的职位互相映射,
        SS_BatchColumnMapping__c mpdMapping = SS_BatchColumnMapping__c.getValues('HR_Post_To_UserAndContact__c');
            Map<String,String> UserAndContactMap = new Map<String,String>();
            for (Integer i = 1; i <= 30; i++) {
                String lpadI = ('00' + i).right(3);
                String fromColumn = 'From_Column_' + lpadI + '__c';
                if(mpdMapping!=null){
                    String apiStr = String.valueOf(mpdMapping.get(fromColumn));
                    if (String.isBlank(apiStr) == false) {
                        String ssColumn = 'SS_Column_' + lpadI + '__c';
                        String ssApiStr = String.valueOf(mpdMapping.get(ssColumn));
                        UserAndContactMap.put(apiStr,ssApiStr);
                    }
                }
         }
         //20220426  LLIU-CCY9TA you end
        system.debug(mpdMapping+'==UserAndContactMap=='+UserAndContactMap);
        //获取自定义标签,自己定义,用来空更新数据或处理历史数据
        //在处理历史记录时:职位和职种 如果ods的值为空,那么user对象的这两个字段就不需要更新
        Integer buffer = Integer.valueOf(System.Label.ODS_Null_Update_Sign);
        // 现有用户
        Map<String, User> usrMap = new Map<String, User>();
        // ContactToUser の 変更したか にて判断した項目です
        List<ODS__c> conList = [select id,Alias__c,Branch__c,Category3__c,Category4__c,Category5__c,Category6__c,Employee_No__c,Hire_Date__c,FirstName__c,LastName__c,Name__c,Email__c,MobilePhone__c,Post__c,Job_Category__c,Job_Type__c,Product_specialist_incharge_product__c,Sales_Speciality__c,Work_Location__c,Stay_or_not__c,LeaveDate__c,UniqueId__c,Null_Update__c from ODS__c where Employee_No__c in :userEmployeeNoList];
        List<ODS__c> conList = [select id,Alias__c,Branch__c,PositionSubsequence__c,Category3__c,Category4__c,Category5__c,Category6__c,Employee_No__c,Hire_Date__c,FirstName__c,LastName__c,Name__c,Email__c,MobilePhone__c,Post__c,Job_Category__c,Job_Type__c,Product_specialist_incharge_product__c,Sales_Speciality__c,Work_Location__c,Stay_or_not__c,LeaveDate__c,UniqueId__c,Null_Update__c from ODS__c where Employee_No__c in :userEmployeeNoList];
        List<User> usrList = [select Id, PBI_Enable__c ,PBIAuthorizedSetting__c,Employee_No__c from User where Employee_No__c IN :userEmployeeNoList];
        for (User usr : usrList) {
@@ -3084,9 +3117,22 @@
                //userData.Email = odsc.Email__c;//电子邮件
                userData.Mobile_Phone__c = odsc.MobilePhone__c;//手机号码
                //如果自定义变迁的值为1,那么证明现在是在处理历史数据,而历史数据规定,如果ods的职位为空,那么就不需要更新user的职种
               //20220425  LLIU-CCY9TA you ods 的 通用职衔   对应用户上新创建的 HR通用职级     断开跟职位的关系
                if(String.isNotBlank(odsc.Post__c) || buffer != 1){
                    userData.Post__c = odsc.Post__c;//职位
                    //userData.Post__c = odsc.Post__c;//职位
                     userData.HR_Post__c = odsc.Post__c;//HR通用职级
                     system.debug(odsc.Post__c+'===='+UserAndContactMap.containsKey(odsc.Post__c));
                     if(null!=UserAndContactMap && UserAndContactMap.containsKey(odsc.Post__c)){
                         userData.Post__c =  UserAndContactMap.get(odsc.Post__c);
                      }
                }
                //20220426  LLIU-CCY9TA you end
                //20220428 LLIU-CDW5ZW you start
                userData.PositionSubsequence__c = odsc.PositionSubsequence__c;
                //20220428 LLIU-CDW5ZW you end
                String zz = '';
                if(odsc.Job_Category__c == '服务'){
                    zz = '销售服务';
@@ -3129,9 +3175,19 @@
                userData.Username = '_'+odsc.Email__c;//用户名
                userData.Mobile_Phone__c = odsc.MobilePhone__c;//手机号码
                //如果自定义变迁的值为1,那么证明现在是在处理历史数据,而历史数据规定,如果ods的职位为空,那么就不需要更新user的职种
                //20220426  LLIU-CCY9TA you start
                if(String.isNotBlank(odsc.Post__c) || buffer != 1){
                    userData.Post__c = odsc.Post__c;//职位
                    //userData.Post__c = odsc.Post__c;//职位
                    userData.HR_Post__c = odsc.Post__c;//HR通用职级
                    if(null!=UserAndContactMap && UserAndContactMap.containsKey(odsc.Post__c)){
                         userData.Post__c =  UserAndContactMap.get(odsc.Post__c);
                      }
                }
                //20220426  LLIU-CCY9TA you end
                //20220428 LLIU-CDW5ZW you start
                userData.PositionSubsequence__c = odsc.PositionSubsequence__c;
                //20220428 LLIU-CDW5ZW you end
                String zz = '';
                if(odsc.Job_Category__c == '服务'){
                    zz = '销售服务';
@@ -4463,6 +4519,7 @@
                      
                    ,eventStatus__c, CancelReason__c, delayToDate__c, delayReason__c,DurationInMinutes__c,cancelReasonSelect__c,cancelReasonSelectFSE__c,cancelReasonOther__c,delayReasonOther__c,delayReasonSelect__c,delayReasonSelectFSE__c,BeforeActivityDate__c,OPDPlan_Flag__c,IsScheduled__c,AppCdId__c,SyncCreatedDate__c
                    // 20200420 任务日报管理 add gzw end
                    ,OPD_plan__c // 2022-4-14 yjk 增加OPD计划
            from Event__c where ActivityDate__c =:whereDate and Daily_Report__c = :oya.Id order by StartDateTime__c
        ];
    }