public without sharing class NFM701ControllerHandler {
    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;
    }
    public static void insertAccount(List<Account> newList, Map<Id, Account> newMap, List<Account> oldList, Map<Id, Account> oldMap){
        List<String> accIdList = new List<String>();

        String LOG_TYPE = 'NFM701';
        // List < String > IdList = new List < String >();
        // IdList.add('0011m00000VpPQk');
        BatchIF_Log__c iflog = new BatchIF_Log__c();
        iflog.Type__c = LOG_TYPE;
        iflog.Log__c = 'callout start\n';
        insert iflog;
        // if (Trigger.isInsert) {
        if (newList.size()>0) {
            // iflog.Log__c += '进if';
            for (Account acc : newList) {
            // 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';

                // }
            }

            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) {
                    accIdList.add(acc.Id);
                    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进来';
                            
                            NFM701Controller.callout(iflog.Id, accIdList);
                        }
                    }
                }
            }

        }
        upsert iflog;
        // }
    }
}