public without sharing class UserViolationsTriggerHandler {
        
    /**
     *   解冻时将所有该用户下的违规记录的是否有效设置为"否",并将用户中有效违规数和违规信息ID记录为清空.
    */  
    public static void setOK(List<User_Violations__c> newList, Map<Id, User_Violations__c> newMap, List<User_Violations__c> oldList, Map<Id, User_Violations__c> oldMap){
        List<User_Violations__c> uvList = new List<User_Violations__c>();
        List<String> uvIdList = new List<String>();
        Set<String> userIdSet = new Set<String>();
        
        for(User_Violations__c uv : newList){
            User_Violations__c old = oldMap.get(uv.Id);
            if(uv.Is_locking__c != old.Is_locking__c && uv.Is_locking__c == false && uv.is_Alone__c == false){
                uvIdList.add(uv.Violations_User__c);
            }
        }
        System.debug(uvIdList);
        uvList = [SELECT Id,Is_effective__c,Violations_User__c,Is_locking__c FROM User_Violations__c WHERE Violations_User__c in :uvIdList AND Is_effective__c = true];
        System.debug(uvList);
         if(uvList.size() > 0){
            for(User_Violations__c uv : uvList){
                uv.Is_effective__c = false;
                if(uv.Is_locking__c == true){
                    uv.Is_locking__c = false;
                    uv.Violations_Stop_Date__c = Date.today();
                }
                userIdSet.add(uv.Violations_User__c);
            }
            List<User> userList = [SELECT Id FROM User WHERE Id in :userIdSet];
            for(User user : userList){
                user.Return_Timeout_Number__c = 0;
                user.Automatic_Received_Number__c = 0;
                user.ViolationsID__c = null;
            }
            System.debug(uvList);
            System.debug(userList);
            update uvList;
            update userList;
        }
    }


}