public without sharing class RepairTriggerHandler { public static void setdate(List newList, Map newMap, List oldList, Map oldMap) { for(Repair__c rep : newList){ if(rep.RecordTypeId == '0120K000000wOGe'){ // if(rep.RecordTypeId == '0120l000000WwBL'){ if(rep.ServicePlace__c == '现场'){ if( rep.CustomerRequestDate__c == null || rep.ServiceStartDate__c== null){ rep.StartDatenwb__c = null; }else{ Map dateMap = calendarUtil.getCalendarMap(rep.CustomerRequestDate__c,rep.ServiceStartDate__c); rep.StartDatenwb__c = (calendarUtil.getNumfromCalendarMap(dateMap,rep.CustomerRequestDate__c,rep.ServiceStartDate__c)-1)+''; } } if(rep.ServiceType__c=='维修' ){ if(rep.ServiceProperty__c =='有偿'){ if( rep.QuotationAgreeDate__c == null || rep.CompletionDate__c== null){ rep.MaintenanceDatewb__c = null; }else{ Map dateMap = calendarUtil.getCalendarMap(rep.QuotationAgreeDate__c,rep.CompletionDate__c); rep.MaintenanceDatewb__c = (calendarUtil.getNumfromCalendarMap(dateMap,rep.QuotationAgreeDate__c,rep.CompletionDate__c)-1)+''; } }else if(rep.ServiceProperty__c =='无偿'){ if( rep.ServiceStartDate__c == null || rep.CompletionDate__c== null){ rep.MaintenanceDatewb__c = null; }else{ Map dateMap = calendarUtil.getCalendarMap(rep.ServiceStartDate__c,rep.CompletionDate__c); rep.MaintenanceDatewb__c = (calendarUtil.getNumfromCalendarMap(dateMap,rep.ServiceStartDate__c,rep.CompletionDate__c)-1)+''; } }else{ rep.MaintenanceDatewb__c = null; } }else{ rep.MaintenanceDatewb__c = null; } if(rep.ServiceType__c=='维修' ){ if(rep.QuotationAgreeDate__c == null ){ if( rep.BugDate__c == null || rep.CompletionDate__c == null){ rep.Downtime__c = null; }else{ Map dateMap = calendarUtil.getCalendarMap(rep.BugDate__c,rep.CompletionDate__c); rep.Downtime__c = (calendarUtil.getNumfromCalendarMap(dateMap,rep.BugDate__c,rep.CompletionDate__c)-1)+''; } }else{ if(rep.QuotationDate__c == null || rep.QuotationAgreeDate__c == null || rep.BugDate__c == null || rep.CompletionDate__c == null){ rep.Downtime__c = null; }else{ Integer num1 = 0; Integer num2 = 0; Map dateMap = calendarUtil.getCalendarMap(rep.QuotationDate__c,rep.QuotationAgreeDate__c); num1 = calendarUtil.getNumfromCalendarMap(dateMap,rep.QuotationDate__c,rep.QuotationAgreeDate__c)-1; Map dateMap1 = calendarUtil.getCalendarMap(rep.BugDate__c,rep.CompletionDate__c); num2 = calendarUtil.getNumfromCalendarMap(dateMap1,rep.BugDate__c,rep.CompletionDate__c)-1; rep.Downtime__c = (num2 - num1)+''; } } }else{ rep.Downtime__c = null; } }else if(rep.RecordTypeId == '0120K000000wOGg'){ //else if(rep.RecordTypeId == '0120l000000WwBQ'){ if(rep.ServicePlace__c == '现场'){ if( rep.QuotationAgreeDate__c == null || rep.ReciveRepairDay__c== null){ rep.StartDatenwb__c = null; }else{ Map dateMap = calendarUtil.getCalendarMap(rep.ReciveRepairDay__c,rep.QuotationAgreeDate__c); rep.StartDatenwb__c = (calendarUtil.getNumfromCalendarMap(dateMap,rep.ReciveRepairDay__c,rep.QuotationAgreeDate__c)-1)+''; } } if(rep.ServiceType__c=='维修' ||rep.ServiceType__c=='维护' ){ if( rep.CompletionDate__c == null || rep.QuotationAgreeDate__c== null){ rep.MaintenanceDatewb__c = null; }else{ Map dateMap = calendarUtil.getCalendarMap(rep.QuotationAgreeDate__c,rep.CompletionDate__c); rep.MaintenanceDatewb__c = (calendarUtil.getNumfromCalendarMap(dateMap,rep.QuotationAgreeDate__c,rep.CompletionDate__c)-1)+''; } }else{ rep.MaintenanceDatewb__c = null; } if(rep.ServiceType__c=='维修'||rep.ServiceType__c=='维护' ){ if(rep.ReciveRepairDay__c == null || rep.CompletionDate__c == null ){ rep.Downtime__c = null; }else{ if( rep.ReciveRepairDay__c == rep.CompletionDate__c){ rep.Downtime__c ='0'; }else{ if(rep.QuotationDate__c == null || rep.QuotationAgreeDate__c == null || rep.ReciveRepairDay__c == null || rep.CompletionDate__c == null){ rep.Downtime__c = null; }else{ Integer num1 = 0; Integer num2 = 0; Map dateMap = calendarUtil.getCalendarMap(rep.QuotationDate__c,rep.QuotationAgreeDate__c); num1 = calendarUtil.getNumfromCalendarMap(dateMap,rep.QuotationDate__c,rep.QuotationAgreeDate__c)-1; Map dateMap1 = calendarUtil.getCalendarMap(rep.ReciveRepairDay__c,rep.CompletionDate__c); num2 = calendarUtil.getNumfromCalendarMap(dateMap1,rep.ReciveRepairDay__c,rep.CompletionDate__c)-1; rep.Downtime__c = (num2 - num1)+''; } } } }else{ rep.Downtime__c = null; } } } } }