public with sharing class OCSMHandler extends Oly_TriggerHandler {
    //LY          2021/11/12                  start
    //平台窗口1、2、3任何一个有变更都会触发客户人员接口，向共通平台发送
	public static void OCSMToUser(List<OCM_Management_Province__c> newList, Map<Id, OCM_Management_Province__c> newMap, List<OCM_Management_Province__c> oldList, Map<Id, OCM_Management_Province__c> oldMap){
    
        OCM_Management_Province__c old = null;
        List<String> noList = new List<String>();
        //Add By Li Jun 20230420 Start OCSM省的【营业窗口】人员发生变动时，需要更新现有的未完成的签收单的【营业助理】值 
        Set<String> changedWindowProvince = new set<String>();
        //Add By Li Jun 20230420 End 
        for (OCM_Management_Province__c local : newList) {

            if (Trigger.isInsert) {
                if (String.isNotBlank(local.OnlinePlatformWindow1__c)) {
                    noList.add(local.OnlinePlatformWindow1__c);
                }
                if (String.isNotBlank(local.OnlinePlatformWindow2__c)) {
                    noList.add(local.OnlinePlatformWindow2__c);
                }
                if (String.isNotBlank(local.OnlinePlatformWindow3__c)) {
                    noList.add(local.OnlinePlatformWindow3__c);
                }
            }

            if (Trigger.isUpdate) {
                old = oldMap.get(local.Id);
                if (old.OnlinePlatformWindow1__c != local.OnlinePlatformWindow1__c) {
                    if (String.isNotBlank(local.OnlinePlatformWindow1__c)) {
                        noList.add(local.OnlinePlatformWindow1__c);
                    }
                    if (String.isNotBlank(old.OnlinePlatformWindow1__c)) {
                        noList.add(old.OnlinePlatformWindow1__c);
                    }
                }
                if (old.OnlinePlatformWindow2__c != local.OnlinePlatformWindow2__c) {
                    if (String.isNotBlank(local.OnlinePlatformWindow2__c)) {
                        noList.add(local.OnlinePlatformWindow2__c);
                    }
                    if (String.isNotBlank(old.OnlinePlatformWindow2__c)) {
                        noList.add(old.OnlinePlatformWindow2__c);
                    }
                }
                if (old.OnlinePlatformWindow3__c != local.OnlinePlatformWindow3__c) {
                    if (String.isNotBlank(local.OnlinePlatformWindow3__c)) {
                        noList.add(local.OnlinePlatformWindow3__c);
                    }
                    if (String.isNotBlank(old.OnlinePlatformWindow3__c)) {
                        noList.add(old.OnlinePlatformWindow3__c);
                    }
                }
                //Add By Li Jun 20230420 Start 
                if (local.Window1__c != null &&  local.Window1__c != old.Window1__c) {
                    changedWindowProvince.add(local.Name);   
                }                
                //Add By Li Jun 20230420 End
            
            }

        }
        if (noList.size() > 0) {
            NFM621Controller.callout('',  noList);
        }
        //Add By Li Jun 20230420 Start 
        if(changedWindowProvince.size() > 0){
            SyncProvinceWIndowToSignForm.syncProvinceWIndow(changedWindowProvince);
        }
        //Add By Li Jun 20230420 End
    }
}
//LY          2021/11/12                  end