public without sharing class NFM701ControllerHandler  extends Oly_TriggerHandler{
    private Map<Id, Account> newMap;
    private Map<Id, Account> oldMap;
    private List<Account> newList;
    private List<Account> oldList;
    // private List<String> accIdList;
    public NFM701ControllerHandler() {
        this.newMap = (Map<Id, Account>) Trigger.newMap;
        this.oldMap = (Map<Id, Account>) Trigger.oldMap;
        this.newList = (List<Account>) Trigger.new;
        this.oldList = (List<Account>) Trigger.old;
    }
    protected override void afterUpdate(){
        if (!StaticParameter.EscapeNFM701Trigger && !NFM701Controller.isRunning) {
            NFM701Controller.isRunning = true;
            updateAccount(this.newList , this.newMap , this.oldList , this.oldMap);
        }
    }
    public static void updateAccount(List<Account> newList, Map<Id, Account> newMap, List<Account> oldList, Map<Id, Account> oldMap){
        List<String> accIdList = new List<String>();
        List<String> IdList = new List<String>();

        String LOG_TYPE = 'NFM701';
        // List < String > IdList = new List < String >();
        // IdList.add('0011m00000VpPQk');
        // if (Trigger.isInsert) {
        if (newList.size()>0) {
            // iflog.Log__c += '进if';
            for (Account acc : newList) {
                    if(!acc.RecordType_DeveloperName__c.equals('Agency') && !acc.RecordType_DeveloperName__c.equals('AgencyContract') && !acc.RecordType_DeveloperName__c.contains('Department_')){
                        // iflog.Log__c += acc.RecordType.DeveloperName;
                        // iflog.Log__c += acc;
                        if(((acc.Is_Active__c != oldMap.get(acc.Id).Is_Active__c) && (acc.Is_Active__c.equals('有効') || acc.Is_Active__c.equals('無効'))) || ((acc.Name != oldMap.get(acc.Id).Name) && (acc.Is_Active__c.equals('有効')))){
                            // iflog.Log__c += '\n进来';
                            accIdList.add(acc.Id);
                        }
                    }
                // iflog.Log__c += '\n进for';

                // accIdList.add(acc.Id);
                // if((acc.Is_Active__c != oldMap.get(acc.Id).Is_Active__c) && (acc.Is_Active__c.equals('有效') || acc.Is_Active__c.equals('无效'))){
                // if((acc.Name != oldMap.get(acc.Id).Name) && (acc.Is_Active__c.equals('有効'))){
                //     iflog.Log__c += '\n进if2';
                // if(!'Agency'.equals(acc.RecordType.DeveloperName) || !'AgencyContract'.equals(acc.RecordType.DeveloperName)){
                //     iflog.Log__c += acc.RecordType;
                // if(((acc.Is_Active__c != oldMap.get(acc.Id).Is_Active__c) && (acc.Is_Active__c.equals('有効') || acc.Is_Active__c.equals('無効'))) || ((acc.Name != oldMap.get(acc.Id).Name) && (acc.Is_Active__c.equals('有効')))){
                    
                //     NFM701Controller.callout(iflog.Id, accIdList);
                // }
                // }
                // if(acc.Name != oldMap.get(acc.Id).Name){
                //     iflog.Log__c += '\n进if2-1';

                // }
                // if(acc.Is_Active__c.equals('有効')){
                //     iflog.Log__c += '\n进if2-2';

                // }
            }
            if(accIdList.size() > 0){
                BatchIF_Log__c iflog = new BatchIF_Log__c();
                iflog.Type__c = LOG_TYPE;
                iflog.Log__c = 'callout start\n';
                insert iflog;
                NFM701Controller.callout(iflog.Id, accIdList);
            }

            // List<Account> accList = [SELECT Id,
            //                             Name,
            //                             Address__c,
            //                             Is_Active__c,
            //                             RecordTypeId,
            //                             Parent_Management_Code__c,
            //                             Ban_On_Use_Reason__c,
            //                             State_Master__r.Name,
            //                             City_Master__r.Name,
            //                             RecordType.DeveloperName,
            //                             Is_Active_Formula__c,
            //                             Grade__c 
            //                         FROM Account 
            //                         WHERE  id IN: accIdList 
            //                     ];
            // if(accList.size() > 0){
            //     for (Account acc : accList) {
            //         if(!acc.RecordType.DeveloperName.equals('Agency') && !acc.RecordType.DeveloperName.equals('AgencyContract')){
            //             // iflog.Log__c += acc.RecordType.DeveloperName;
            //             // iflog.Log__c += acc;
            //             if(((acc.Is_Active__c != oldMap.get(acc.Id).Is_Active__c) && (acc.Is_Active__c.equals('有効') || acc.Is_Active__c.equals('無効'))) || ((acc.Name != oldMap.get(acc.Id).Name) && (acc.Is_Active__c.equals('有効')))){
            //                 // iflog.Log__c += '\n进来';
            //                 IdList.add(acc.Id);
            //             }
            //         }
            //     }
            // }
            // if(IdList.size() > 0){
            //     BatchIF_Log__c iflog = new BatchIF_Log__c();
            //     iflog.Type__c = LOG_TYPE;
            //     iflog.Log__c = 'callout start\n';
            //     insert iflog;
            //     NFM701Controller.callout(iflog.Id, IdList);
            // }

        }
        // upsert iflog;
        // }
    }
}