高章伟
2023-03-03 d8dc84a3d56df839895f1c417a4d9cbee763d262
force-app/main/default/classes/RentalApplyShareHandler.cls
@@ -36,24 +36,12 @@
        return ras;
    }
    //add by rentx 2020-12-03 end 新建共享数据
    private void addStrategiccShare() {
        //add by rentx 2020-11-16 SFDC-BVA5VJ start
        // List<Id> aids = new List<Id>();//20210728 ljh SFDC-C5645S start
        // List<Rental_Apply__c> ratList = new List<Rental_Apply__c>();//20210728 ljh SFDC-C5645S start
        // List<Rental_Apply__c> raoList = new List<Rental_Apply__c>();//20210728 ljh SFDC-C5645S start
        //add by rentx 2020-11-16 SFDC-BVA5VJ end
        List<Rental_Apply__c> raList = new List<Rental_Apply__c>();
        List<Rental_Apply__Share> delStrategList = new List<Rental_Apply__Share>();
        List<Rental_Apply__Share> addStrategList = new List<Rental_Apply__Share>();
        //20210728 ljh SFDC-C5645S start
        List<Rental_Apply__Share> addStrategListL = new List<Rental_Apply__Share>();
        // List<String> ParentIdList = new List<String>();
        // List<String> UserOrGroupIdList = new List<String>();
        // Map<String, String> PUMap = new Map<String, String>();
        Set<String> ParentIdSet = new Set<String>();
        Set<String> UserOrGroupIdSet = new Set<String>();
        Set<String> UserOrGroupIdOldSet = new Set<String>();
@@ -80,155 +68,43 @@
                    addStrategList.add(ras);
                }
                //20210728 ljh SFDC-C5645S start
                Rental_Apply__c ra = new Rental_Apply__c();
                ra.Id = nObj.Id;
                ra.ShareStrategicUser__c = nObj.Strategic_user__c;
                raList.add(ra);
                // Rental_Apply__c ra = new Rental_Apply__c();
                // ra.Id = nObj.Id;
                // ra.ShareStrategicUser__c = nObj.Strategic_user__c;
                // raList.add(ra);
                //20210728 ljh SFDC-C5645S end
            }
            //判断战略科室主担当是否发生更改
            if (nObj.ShareFlag__c == true && Trigger.isUpdate) {
                //删除原来的共享
                PUMap.put(nObj.Id, nObj);
                if (String.isNotBlank(nObj.ShareStrategicUser__c)) {
                    PUMap.put(nObj.Id, nObj);
                    ParentIdSet.add(nObj.Id);
                    UserOrGroupIdOldSet.add(nObj.ShareStrategicUser__c);
                }
            }
            //20210728 ljh SFDC-C5645S 加入共享前判断用户是否可用 start
            //如果 执行的Insert操作或者发生GI担当改变,设置共享\
            //如果执行的是insert操作
            //判断GI是否发生改变
            /*if (nObj.hospitalLeaderGIchange__c == true && String.isNotBlank(nobj.Strategic_userFSEGI__c) && !nObj.OwnerId.equals(nObj.Strategic_userFSEGI__c)) {
                //加入共享
                Rental_Apply__Share ras = makeData(nObj.Id,nObj.Strategic_userFSEGI__c);
                addStrategList.add(ras);
                //设置hospitalLeaderGI__c的值
                Rental_Apply__c ra = new Rental_Apply__c();
                ra.Id = nObj.Id;
                ra.hospitalLeaderGI__c = nObj.Strategic_userFSEGI__c;
                ratList.add(ra);
            }
            //判断SP是否发生改变
            if (nObj.hospitalLeaderSPchange__c && String.isNotBlank(nobj.Strategic_userFSESP__c) && !nObj.OwnerId.equals(nObj.Strategic_userFSESP__c)) {
                //加入共享
                Rental_Apply__Share ras = makeData(nObj.Id,nObj.Strategic_userFSESP__c);
                addStrategList.add(ras);
                //设置hospitalLeaderSP__c的值
                Rental_Apply__c ra = new Rental_Apply__c();
                ra.Id = nObj.Id;
                ra.hospitalLeaderSP__c = nObj.Strategic_userFSESP__c;
                raoList.add(ra);
            }
            //判断战略科室主担当是否和 SP/GI之前的值一样
            if ((nObj.hospitalLeaderSPchange__c && String.isNotBlank(nObj.hospitalLeaderSP__c) && String.isNotBlank(nObj.Strategic_user__c) && nObj.Strategic_user__c.equals(nObj.hospitalLeaderSP__c)) ||
                (nObj.hospitalLeaderGIchange__c && String.isNotBlank(nObj.hospitalLeaderGI__c) && String.isNotBlank(nObj.Strategic_user__c) && nObj.Strategic_user__c.equals(nObj.hospitalLeaderGI__c))) {
                Rental_Apply__Share ras = new Rental_Apply__Share(
                                RowCause = 'Manual',
                                ParentId = nObj.Id,
                                UserOrGroupId = nObj.Strategic_user__c,
                                AccessLevel = 'read'
                            );
                addStrategList.add(ras);
            }
            //如果是新建备品或者战略科室分类发生改变
            if (Trigger.isInsert || (Trigger.isUpdate && nObj.OCM_dept_category__c != oldMap.get(nObj.Id).OCM_dept_category__c) ) {
                //判断新的战略科室是什么
                String dept = nObj.OCM_dept_category__c;
                if(string.isNotBlank(dept)){
                    if ((nObj.Job_Category__c =='销售服务') && (dept.equals('消化科') ||dept.equals('呼吸科') || dept.equals('ET') || dept.equals('其他'))
                        && String.isNotBlank(nobj.Strategic_userFSEGI__c) && !nObj.OwnerId.equals(nObj.Strategic_userFSEGI__c)) {
                        //加入共享
                        Rental_Apply__Share ras = makeData(nObj.Id,nObj.Strategic_userFSEGI__c);
                        addStrategList.add(ras);
                    }
                    if ((nObj.Job_Category__c =='销售服务') &&
                        (dept.equals('普外科') ||dept.equals('泌尿科') || dept.equals('妇科') || dept.equals('耳鼻喉科') || dept.equals('其他'))
                        && String.isNotBlank(nobj.Strategic_userFSESP__c) && !nObj.OwnerId.equals(nObj.Strategic_userFSESP__c)) {
                        //加入共享
                        Rental_Apply__Share ras = makeData(nObj.Id,nObj.Strategic_userFSESP__c);
                        addStrategList.add(ras);
                    }
                }
            }
            //判断现在执行的操作是否为 更新
            if (Trigger.isUpdate) {
                //换换姐的
                //删除原来的共享 --战略科室主担当
                if(nObj.ShareFlag__c==true &&String.isNotBlank(nObj.ShareStrategicUser__c)){
                    PUMap.put(nObj.Id,nObj.ShareStrategicUser__c);
                    ParentIdList.add(nObj.Id);
                    UserOrGroupIdList.add(nObj.ShareStrategicUser__c);
                }
                //如果战略科室发生改变
                if (nObj.OCM_dept_category__c != oldMap.get(nObj.Id).OCM_dept_category__c) {
                    if (String.isNotBlank(nobj.hospitalLeaderGI__c)) {
                        PUMap.put(nObj.Id,nObj.hospitalLeaderGI__c);
                        UserOrGroupIdList.add(nObj.hospitalLeaderGI__c);
                    }
                    if (String.isNotBlank(nObj.hospitalLeaderSP__c)) {
                        PUMap.put(nObj.Id,nObj.hospitalLeaderSP__c);
                        UserOrGroupIdList.add(nObj.hospitalLeaderSP__c);
                    }
                    ParentIdList.add(nObj.Id);
                }
                //战略科室FSEGI担当,如果发生改变
                if (nObj.hospitalLeaderGIchange__c == true && String.isNotBlank(nObj.hospitalLeaderGI__c)) {
                    PUMap.put(nObj.Id,nObj.hospitalLeaderGI__c);
                    ParentIdList.add(nObj.Id);
                    UserOrGroupIdList.add(nObj.hospitalLeaderGI__c);
                }
                //战略科室FSESP担当,如果发生改变
                if (nObj.hospitalLeaderSPchange__c == true && String.isNotBlank(nObj.hospitalLeaderSP__c)) {
                    PUMap.put(nObj.Id,nObj.hospitalLeaderSP__c);
                    ParentIdList.add(nObj.Id);
                    UserOrGroupIdList.add(nObj.hospitalLeaderSP__c);
                }
                //判断战略科室主担当是否和 SP/GI之前的值一样
                if ((nObj.hospitalLeaderSPchange__c && String.isNotBlank(nObj.hospitalLeaderSP__c) && String.isNotBlank(nObj.Strategic_user__c) && nObj.Strategic_user__c.equals(nObj.hospitalLeaderSP__c)) ||
                    (nObj.hospitalLeaderGIchange__c && String.isNotBlank(nObj.hospitalLeaderGI__c) && String.isNotBlank(nObj.Strategic_user__c) && nObj.Strategic_user__c.equals(nObj.hospitalLeaderGI__c))) {
                    PUMap.put(nObj.Id,nObj.Strategic_user__c);
                    ParentIdList.add(nObj.Id);
                    UserOrGroupIdList.add(nObj.Strategic_user__c);
                }
            }20210728 ljh SFDC-C5645S 注释*/
            // System.debug('zheli00:'+nObj.OwnerId.equals(nObj.Strategic_userFSEGI__c)+'~'+nObj.Strategic_userFSEGI__c+'~'+nObj.OwnerId);
            // System.debug('zheli11:'+nObj.OwnerId.equals(nObj.Strategic_userFSESP__c)+'~'+nObj.Strategic_userFSESP__c+'~'+nObj.OwnerId+'||'+nObj.hospitalLeaderGIchange__c+'~'+nObj.hospitalLeaderSPchange__c);
            // System.debug('zheli22:'+nObj.hospitalLeaderGIchange__c+'~'+nObj.hospitalLeaderSPchange__c);
            // 20210924 ljh SFDC-C758NB update substring(0,15) start
            // if (
            //     (nObj.hospitalLeaderGIchange__c  && String.isNotBlank(nobj.Strategic_userFSEGI__c) && !nObj.OwnerId.equals(nObj.Strategic_userFSEGI__c))
            //     || (nObj.hospitalLeaderSPchange__c && String.isNotBlank(nobj.Strategic_userFSESP__c) && !nObj.OwnerId.equals(nObj.Strategic_userFSESP__c))
            // ) {
            if (
                (nObj.hospitalLeaderGIchange__c  && String.isNotBlank(nobj.Strategic_userFSEGI__c) && !String.valueOf(nObj.OwnerId).substring(0,15).equals(String.valueOf(nObj.Strategic_userFSEGI__c).substring(0,15)))
                || (nObj.hospitalLeaderSPchange__c && String.isNotBlank(nobj.Strategic_userFSESP__c) && !String.valueOf(nObj.OwnerId).substring(0,15).equals(String.valueOf(nObj.Strategic_userFSESP__c).substring(0,15)))
            ) {
            if ( nObj.hospitalLeaderGIchange__c || nObj.hospitalLeaderSPchange__c ) {
                // if (nObj.hospitalLeaderGIchange__c) {
                if (nObj.hospitalLeaderGIchange__c && !String.valueOf(nObj.OwnerId).substring(0,15).equals(String.valueOf(nObj.Strategic_userFSEGI__c).substring(0,15))) {
                    Rental_Apply__Share ras = makeData(nObj.Id, nObj.Strategic_userFSEGI__c);
                if (nObj.hospitalLeaderGIchange__c)  {
                    PUMap.put(nObj.Id, nObj);
                    ParentIdSet.add(nObj.Id);
                    UserOrGroupIdSet.add(nObj.Strategic_userFSEGI__c);
                    UserOrGroupIdOldSet.add(nObj.hospitalLeaderGI__c);
                    addStrategListL.add(ras);
                    if(String.isNotBlank(nobj.Strategic_userFSEGI__c) && !String.valueOf(nObj.OwnerId).substring(0,15).equals(String.valueOf(nObj.Strategic_userFSEGI__c).substring(0,15))){
                        Rental_Apply__Share ras = makeData(nObj.Id, nObj.Strategic_userFSEGI__c);
                        ParentIdSet.add(nObj.Id);
                        UserOrGroupIdSet.add(nObj.Strategic_userFSEGI__c);
                        UserOrGroupIdOldSet.add(nObj.hospitalLeaderGI__c);
                        addStrategListL.add(ras);
                    }
                }
                // if (nObj.hospitalLeaderSPchange__c) {
                if (nObj.hospitalLeaderSPchange__c && !String.valueOf(nObj.OwnerId).substring(0,15).equals(String.valueOf(nObj.Strategic_userFSESP__c).substring(0,15))) {
                    Rental_Apply__Share ras = makeData(nObj.Id, nObj.Strategic_userFSESP__c);
                if (nObj.hospitalLeaderSPchange__c) {
                    PUMap.put(nObj.Id, nObj);
                    ParentIdSet.add(nObj.Id);
                    UserOrGroupIdSet.add(nObj.Strategic_userFSESP__c);
                    UserOrGroupIdOldSet.add(nObj.hospitalLeaderSP__c);
                    addStrategListL.add(ras);
                    if (String.isNotBlank(nobj.Strategic_userFSESP__c) && !String.valueOf(nObj.OwnerId).substring(0,15).equals(String.valueOf(nObj.Strategic_userFSESP__c).substring(0,15))) {
                        Rental_Apply__Share ras = makeData(nObj.Id, nObj.Strategic_userFSESP__c);
                        ParentIdSet.add(nObj.Id);
                        UserOrGroupIdSet.add(nObj.Strategic_userFSESP__c);
                        UserOrGroupIdOldSet.add(nObj.hospitalLeaderSP__c);
                        addStrategListL.add(ras);
                    }
                }
            }
            //20210728 ljh SFDC-C5645S 加入共享前判断用户是否可用 end
@@ -260,7 +136,8 @@
            }
        }   
        //增加
        if (addStrategListL.size() > 0) {
        // if (addStrategListL.size() > 0) {
        if (PUMap.size() > 0) {
            //20210728 ljh SFDC-C5645S
            for (Rental_Apply__Share ras : addStrategListL) {
                String temp = (String)ras.UserOrGroupId;
@@ -269,24 +146,26 @@
                   ) {
                    addStrategList.add(ras);
                }
                Rental_Apply__c Ra = PUMap.get(ras.ParentId);
            }
            Set<String>  keySet = PUMap.keySet();
            for(Id key:keySet){
                Rental_Apply__c Ra = PUMap.get(key);
                Rental_Apply__c raU = new Rental_Apply__c();
                if (Ra != null ) {
                if (PUMap.get(key) != null ) {
                    // System.debug('zheli00:'+Ra.hospitalLeaderGIchange__c+'~'+Ra.hospitalLeaderSPchange__c);
                    raU.Id = Ra.Id;
                    String tempGI = Ra.Strategic_userFSEGI__c;
                    String tempSP = Ra.Strategic_userFSESP__c;
                    if (Ra.hospitalLeaderGIchange__c && String.isNotBlank(tempGI)) {
                    // String tempGI = Ra.Strategic_userFSEGI__c;
                    // String tempSP = Ra.Strategic_userFSESP__c;
                    // String tempSU = Ra.ShareStrategicUser__c;
                    if (Ra.hospitalLeaderGIchange__c) {
                        raU.hospitalLeaderGI__c = Ra.Strategic_userFSEGI__c;
                    } else {
                        raU.hospitalLeaderGI__c = '';
                    }
                    if (Ra.hospitalLeaderSPchange__c && String.isNotBlank(tempSP)) {
                    }
                    if (Ra.hospitalLeaderSPchange__c) {
                        raU.hospitalLeaderSP__c = Ra.Strategic_userFSESP__c;
                    } else {
                        raU.hospitalLeaderSP__c = '';
                    }
                    if (Ra.ShareFlag__c) {
                        raU.ShareStrategicUser__c = Ra.Strategic_user__c;
                    }
                    RAUMap.put(raU.Id, raU);
                }
            }
@@ -299,35 +178,27 @@
        }
        // 更新
        // 20210924 ljh SFDC-C758NB update 优化 start
        if (raList.size() > 0) {
            // update raList;
            for(Rental_Apply__c ra:raList){
                if(RAUMap.containsKey(ra.Id)){
                    RAUMap.get(ra.Id).ShareStrategicUser__c = ra.ShareStrategicUser__c;
                }else{
                    RAUMap.put(ra.Id, ra);
                }
            }
        }
        // if (raList.size() > 0) {
        //     // update raList;
        //     for(Rental_Apply__c ra:raList){
        //         if(RAUMap.containsKey(ra.Id)){
        //             RAUMap.get(ra.Id).ShareStrategicUser__c = ra.ShareStrategicUser__c;
        //         }else{
        //             RAUMap.put(ra.Id, ra);
        //         }
        //     }
        // }
        // 20210924 ljh SFDC-C758NB update 优化 end
        
        //更新
        if (RAUMap.size() > 0) {
            System.debug('AAA:'+RAUMap.values());
            update RAUMap.values();
        }
        /*
        //更新
        if(ratList.size()>0){
            update ratList;
        }
        //更新
        if(raoList.size()>0){
            update raoList;
        }//20210728 ljh SFDC-C5645S 注释*/
    }
    private void dataCheck() {
        System.debug('进入 dataCheck');
        Map<Id, Rental_Apply__c> dataCheckMap = new Map<Id, Rental_Apply__c>();
        List<OPDPlan__c> oPDPlanList = new List<OPDPlan__c>();
        Map<Id, OPDPlan__c> dataOPDMap = new Map<Id, OPDPlan__c>();
@@ -346,7 +217,7 @@
                //有31个字段的值不可修改
                if (newObj.SupplementCreated__c) {
                    changeFlag = RentalApplydataCheck(null, newObj, oldObj);
                    if (System.Test.isRunningTest() == false && changeFlag) {
                    if (System.Test.isRunningTest() == false && changeFlag && UserInfo.getUserId()!=System.Label.ByPassTrigger) {
                        newObj.addError('关联的OPD计划为补充OPD计划 不能编辑备品借用信息');
                    }
                    //system.debug('changeFlag---->'+changeFlag);
@@ -356,6 +227,7 @@
        if (dataCheckMap.size() > 0) {
            //查询 OPD计划
            //zhj 2022-04-19 修改联系电话与直送收货地址的比较改为Encrypt的比较 start
            oPDPlanList = [SELECT Id, Name, supplementaryApplication__c, originalOpdRentalApply__c,
                           OriginalOpdPlanApplication__c,
                           OriginalOpdPlanApplication__r.Rental_Apply2__c,
@@ -366,7 +238,7 @@
                           OriginalOpdPlanApplication__r.Rental_Apply2__r.Strategic_dept__c,
                           OriginalOpdPlanApplication__r.Rental_Apply2__r.Account__c,
                           OriginalOpdPlanApplication__r.Rental_Apply2__r.Loaner_medical_Staff__c,
                           OriginalOpdPlanApplication__r.Rental_Apply2__r.Phone_number__c,
                           OriginalOpdPlanApplication__r.Rental_Apply2__r.Phone_Number_Encrypt__c,
                           OriginalOpdPlanApplication__r.Rental_Apply2__r.Demo_purpose1__c ,
                           OriginalOpdPlanApplication__r.Rental_Apply2__r.demo_purpose2__c ,
                           OriginalOpdPlanApplication__r.Rental_Apply2__r.Product_category__c,
@@ -383,7 +255,7 @@
                           OriginalOpdPlanApplication__r.Rental_Apply2__r.Shipment_address__c,
                           OriginalOpdPlanApplication__r.Rental_Apply2__r.Dealer__c,
                           OriginalOpdPlanApplication__r.Rental_Apply2__r.Loaner_received_staff__c ,
                           OriginalOpdPlanApplication__r.Rental_Apply2__r.direct_shippment_address__c,
                           OriginalOpdPlanApplication__r.Rental_Apply2__r.Direct_Shippment_Address_Encrypt__c,
                           OriginalOpdPlanApplication__r.Rental_Apply2__r.direct_send__c ,
                           OriginalOpdPlanApplication__r.Rental_Apply2__r.pickup_time__c,
                           OriginalOpdPlanApplication__r.Rental_Apply2__r.Loaner_received_staff_phone__c ,
@@ -433,7 +305,7 @@
                            newObj.Request_return_day__c = opd.OriginalOpdPlanApplication__r.Rental_Apply2__r.Request_return_day__c;
                            changeFlag = RentalApplydataCheck(opd, newObj, null);
                            if (System.Test.isRunningTest() == false && changeFlag) {
                            if (System.Test.isRunningTest() == false && changeFlag && UserInfo.getUserId()!=System.Label.ByPassTrigger) {
                                newObj.addError('关联的OPD计划为补充OPD计划 不能编辑备品借用信息');
                            }
                            newObj.Old_Rental_Apply__c = opd.OriginalOpdPlanApplication__r.Rental_Apply2__c;
@@ -475,8 +347,8 @@
            boolean Loaner_medical_Staff = opd.OriginalOpdPlanApplication__r.Rental_Apply2__r.Loaner_medical_Staff__c != newObj.Loaner_medical_Staff__c;
            system.debug('Loaner_medical_Staff__c--->' + Loaner_medical_Staff);
            boolean Phone_number = opd.OriginalOpdPlanApplication__r.Rental_Apply2__r.Phone_number__c  != newObj.Phone_number__c;
            system.debug('Phone_number__c--->' + Phone_number);
            boolean Phone_number = opd.OriginalOpdPlanApplication__r.Rental_Apply2__r.Phone_Number_Encrypt__c  != newObj.Phone_Number_Encrypt__c;
            system.debug('Phone_Number_Encrypt__c--->' + Phone_number);
            boolean Demo_purpose1 = opd.OriginalOpdPlanApplication__r.Rental_Apply2__r.Demo_purpose1__c  != newObj.Demo_purpose1__c;
            system.debug('Demo_purpose1__c--->' + Demo_purpose1);
@@ -526,8 +398,12 @@
            boolean Loaner_received_staff = opd.OriginalOpdPlanApplication__r.Rental_Apply2__r.Loaner_received_staff__c  != newObj.Loaner_received_staff__c;
            system.debug('Loaner_received_staff__c--->' + Loaner_received_staff);
            boolean direct_shippment_address = opd.OriginalOpdPlanApplication__r.Rental_Apply2__r.direct_shippment_address__c  != newObj.direct_shippment_address__c;
            system.debug('direct_shippment_address__c--->' + direct_shippment_address);
            String dsaecnew = opd.OriginalOpdPlanApplication__r.Rental_Apply2__r.Direct_Shippment_Address_Encrypt__c;
            dsaecnew = String.isBlank(dsaecnew)||String.isEmpty(dsaecnew)?'':dsaecnew.length()>200?dsaecnew.substring(0,200):dsaecnew;
            String dsaecold = newObj.Direct_Shippment_Address_Encrypt__c;
            dsaecold =String.isBlank(dsaecold)||String.isEmpty(dsaecold)?'': dsaecold.length()>200?dsaecold.substring(0,200):dsaecold;
            boolean direct_shippment_address = dsaecnew  != dsaecold;
            system.debug('Direct_Shippment_Address_Encrypt__c--->' + direct_shippment_address);
            boolean direct_send = opd.OriginalOpdPlanApplication__r.Rental_Apply2__r.direct_send__c  != newObj.direct_send__c;
            system.debug('direct_send__c--->' + direct_send);
@@ -553,7 +429,7 @@
                           opd.OriginalOpdPlanApplication__r.Rental_Apply2__r.Strategic_dept__c != newObj.Strategic_dept__c ||
                           opd.OriginalOpdPlanApplication__r.Rental_Apply2__r.Account__c != newObj.Account__c ||
                           opd.OriginalOpdPlanApplication__r.Rental_Apply2__r.Loaner_medical_Staff__c != newObj.Loaner_medical_Staff__c ||
                           opd.OriginalOpdPlanApplication__r.Rental_Apply2__r.Phone_number__c  != newObj.Phone_number__c ||
                           opd.OriginalOpdPlanApplication__r.Rental_Apply2__r.Phone_Number_Encrypt__c  != newObj.Phone_Number_Encrypt__c ||
                           opd.OriginalOpdPlanApplication__r.Rental_Apply2__r.Demo_purpose1__c  != newObj.Demo_purpose1__c ||
                           opd.OriginalOpdPlanApplication__r.Rental_Apply2__r.demo_purpose2__c  != newObj.demo_purpose2__c ||
                           opd.OriginalOpdPlanApplication__r.Rental_Apply2__r.Product_category__c != newObj.Product_category__c ||
@@ -570,7 +446,7 @@
                           opd.OriginalOpdPlanApplication__r.Rental_Apply2__r.Shipment_address__c != newObj.Shipment_address__c ||
                           opd.OriginalOpdPlanApplication__r.Rental_Apply2__r.Dealer__c != newObj.Dealer__c ||
                           opd.OriginalOpdPlanApplication__r.Rental_Apply2__r.Loaner_received_staff__c  != newObj.Loaner_received_staff__c ||
                           opd.OriginalOpdPlanApplication__r.Rental_Apply2__r.direct_shippment_address__c  != newObj.direct_shippment_address__c ||
                           dsaecnew  != dsaecold ||
                           opd.OriginalOpdPlanApplication__r.Rental_Apply2__r.direct_send__c  != newObj.direct_send__c ||
                           opd.OriginalOpdPlanApplication__r.Rental_Apply2__r.pickup_time__c != newObj.pickup_time__c ||
                           opd.OriginalOpdPlanApplication__r.Rental_Apply2__r.Loaner_received_staff_phone__c  != newObj.Loaner_received_staff_phone__c ||
@@ -578,6 +454,10 @@
                           opd.OriginalOpdPlanApplication__r.Rental_Apply2__r.GI_Diff__c  != newObj.GI_Diff__c ||
                           opd.OriginalOpdPlanApplication__r.Rental_Apply2__r.Hope_Lonaer_date_Num__c != newObj.Hope_Lonaer_date_Num__c ;
        } else {
            String dsaecnew = newObj.Direct_Shippment_Address_Encrypt__c;
            dsaecnew = String.isBlank(dsaecnew)||String.isEmpty(dsaecnew)?'':  dsaecnew.length()>200?dsaecnew.substring(0,200):dsaecnew;
            String dsaecold = oldObj.Direct_Shippment_Address_Encrypt__c;
            dsaecold =  String.isBlank(dsaecold)||String.isEmpty(dsaecold)?'': dsaecold.length()>200?dsaecold.substring(0,200):dsaecold;
            changeFlag  =  newObj.Person_In_Charge__c != oldObj.Person_In_Charge__c ||
                           newObj.applyUser__c != oldObj.applyUser__c ||
                           newObj.ApplyPerson_Phone__c != oldObj.ApplyPerson_Phone__c ||
@@ -585,7 +465,7 @@
                           newObj.Strategic_dept__c != oldObj.Strategic_dept__c ||
                           newObj.Account__c != oldObj.Account__c ||
                           newObj.Loaner_medical_Staff__c != oldObj.Loaner_medical_Staff__c ||
                           newObj.Phone_number__c != oldObj.Phone_number__c ||
                           newObj.Phone_Number_Encrypt__c != oldObj.Phone_Number_Encrypt__c ||
                           newObj.Demo_purpose1__c  != oldObj.Demo_purpose1__c ||
                           newObj.demo_purpose2__c != oldObj.demo_purpose2__c ||
                           newObj.Product_category__c != oldObj.Product_category__c ||
@@ -602,7 +482,7 @@
                           newObj.Shipment_address__c != oldObj.Shipment_address__c ||
                           newObj.Dealer__c != oldObj.Dealer__c ||
                           newObj.Loaner_received_staff__c != oldObj.Loaner_received_staff__c ||
                           newObj.direct_shippment_address__c != oldObj.direct_shippment_address__c ||
                           dsaecnew  != dsaecold ||
                           newObj.direct_send__c != oldObj.direct_send__c ||
                           newObj.pickup_time__c != oldObj.pickup_time__c ||
                           newObj.Loaner_received_staff_phone__c != oldObj.Loaner_received_staff_phone__c ||
@@ -611,6 +491,6 @@
                           newObj.Hope_Lonaer_date_Num__c !=  oldObj.Hope_Lonaer_date_Num__c;
        }
        return changeFlag;
        //zhj 2022-04-19 修改联系电话与直送收货地址的比较改为Encrypt的比较 end
    }
}