// Copyright 2019 getensh.com. All rights reserved. // Use of this source code is governed by getensh.com. package utils import ( "adm-data/errors" "strings" "fmt" "time" ) const ( //营运载客汽车5年以内每年检验1次;超过5年的,每6个月检验1次 rule1 = iota //载货汽车和大型、中型非营运载客汽车10年以内每年检验1次;超过10年的,每6个月检验1次 rule2 //小型、微型非营运载客汽车6年以内每2年检验1次;超过6年的,每年检验1次;超过15年的,每6个月检验1次 rule3 //摩托车4年以内每2年检验1次;超过4年的,每年检验1次 rule4 //拖拉机和其他机动车每年检验1次 rule5 //校车每半年检验1次 rule6 //非营运轿车、非营运小型和微型载客汽车6年免检 6年以内每2年免上线检验1次,超过6年的,每年检验1次;超过15年的,每6个月检验1次 rule7 ) /* rule1:营运载客汽车5年以内每年检验1次;超过5年的,每6个月检验1次 rule2:载货汽车和大型、中型非营运载客汽车10年以内每年检验1次;超过10年的,每6个月检验1次 rule3:小型、微型非营运载客汽车6年以内每2年检验1次;超过6年的,每年检验1次;超过15年的,每6个月检验1次 rule4:摩托车4年以内每2年检验1次;超过4年的,每年检验1次 rule5:拖拉机和其他机动车每年检验1次 rule6:校车每半年检验1次 rule7:非营运轿车、非营运小型和微型载客汽车6年免检 6年以内每2年免上线检验1次,超过6年的,每年检验1次;超过15年的,每6个月检验1次 */ type AnnualExamDetail struct { Desc string `json:"desc"` //车龄+几年年检+ 1次 NumYear int64 `json:"num"` //第几年 } type ItemTime struct { Date string `json:"date"` //时间 Day int64 `json:"day"` //还剩多少天 } type GetAnnualInspectionTimeInfo struct { TimeRemain string `json:"time_remain" description:"年检到期剩余时间"` TimeDate string `json:"time_date" description:"年检到期时间"` Rule string `json:"rule" description:"年检规则"` TimeYear string `json:"time_year" description:"第几年"` CanBeUncheck bool `json:"can_be_uncheck" description:"是否可免检年审"` CanBeInspection bool `json:"can_be_inspection" description:"是否到达年审时间"` } //获取月份的天数 func DayCount(year int, month int) (days int) { if month != 2 { if month == 4 || month == 6 || month == 9 || month == 11 { days = 30 } else { days = 31 } } else { if ((year%4) == 0 && (year%100) != 0) || (year%400) == 0 { days = 29 } else { days = 28 } } return days } //计算 start 到 end 还有多少天 func DeltaTimeByDay(start time.Time, end time.Time) int64 { sub := start.Truncate(24 * time.Hour).Sub(end.Truncate(24 * time.Hour)) return int64(sub.Hours() / 24) } //营运载客汽车 func CalcAnnualExamTimeOperation(nowTime time.Time, cdrqTime time.Time, examTime int64, isExpire bool) (ItemTime, AnnualExamDetail, error) { var item ItemTime var detail AnnualExamDetail // 年检时间 annualExamString := "" var annualExamYear int64 = 0 annualExamDesc := "" if examTime != 0 { tempTime := time.Unix(examTime/1000, 0) annualExamString = fmt.Sprintf("%d-%0.2d-%0.2d", cdrqTime.Year(), tempTime.Month(), DayCount(int(tempTime.Year()), int(tempTime.Month()))) } else { annualExamString = fmt.Sprintf("%d-%0.2d-%0.2d", cdrqTime.Year(), cdrqTime.Month(), DayCount(int(cdrqTime.Year()), int(cdrqTime.Month()))) } annualExamTime, err := time.Parse("2006-01-02", annualExamString) if err != nil { return item, detail, errors.TimeCalcFailed } for i := 0; i < 5; i++ { annualExamYear += 1 annualExamTime = annualExamTime.AddDate(1, 0, 0) annualExamDesc = "5年车龄1年年检1次" if annualExamTime.After(nowTime) { if isExpire { annualExamTime = annualExamTime.AddDate(-1, 0, 0) } goto CALCANNUALEXAMTIME } } for i := 0; i < 30; i++ { if i%2 == 0 { annualExamYear += 1 } annualExamTime = annualExamTime.AddDate(0, 6, 0) annualExamDesc = "5年以上车龄每6个月年检1次" if annualExamTime.After(nowTime) { if isExpire { annualExamTime = annualExamTime.AddDate(0, -6, 0) } goto CALCANNUALEXAMTIME } } CALCANNUALEXAMTIME: item.Date = annualExamTime.Format("2006-01-02 15:04:05") item.Day = DeltaTimeByDay(annualExamTime, nowTime) detail.NumYear = annualExamYear detail.Desc = annualExamDesc return item, detail, nil } //载货汽车和大型、中型非营运载客汽车10年以内每年检验1次;超过10年的每6个月检验1次 func CalcAnnualExamTimeBigVehicle(nowTime time.Time, cdrqTime time.Time, examTime int64, isExpire bool) (ItemTime, AnnualExamDetail, error) { var item ItemTime var detail AnnualExamDetail // 年检时间 annualExamString := "" var annualExamYear int64 = 0 annualExamDesc := "" if examTime != 0 { tempTime := time.Unix(examTime/1000, 0) annualExamString = fmt.Sprintf("%d-%0.2d-%0.2d", cdrqTime.Year(), tempTime.Month(), DayCount(int(tempTime.Year()), int(tempTime.Month()))) } else { annualExamString = fmt.Sprintf("%d-%0.2d-%0.2d", cdrqTime.Year(), cdrqTime.Month(), DayCount(int(cdrqTime.Year()), int(cdrqTime.Month()))) } annualExamTime, err := time.Parse("2006-01-02", annualExamString) if err != nil { return item, detail, errors.TimeCalcFailed } for i := 0; i < 10; i++ { annualExamYear += 1 annualExamTime = annualExamTime.AddDate(1, 0, 0) annualExamDesc = "10年车龄1年年检1次" if annualExamTime.After(nowTime) { if isExpire { annualExamTime = annualExamTime.AddDate(-1, 0, 0) } goto CALCANNUALEXAMTIME } } for i := 0; i < 30; i++ { if i%2 == 0 { annualExamYear += 1 } annualExamTime = annualExamTime.AddDate(0, 6, 0) annualExamDesc = "10年以上车龄每6个月年检1次" if annualExamTime.After(nowTime) { if isExpire { annualExamTime = annualExamTime.AddDate(0, -6, 0) } goto CALCANNUALEXAMTIME } } CALCANNUALEXAMTIME: item.Date = annualExamTime.Format("2006-01-02 15:04:05") item.Day = DeltaTimeByDay(annualExamTime, nowTime) detail.NumYear = annualExamYear detail.Desc = annualExamDesc return item, detail, nil } //摩托车 func CalcAnnualExamTimeMotor(nowTime time.Time, cdrqTime time.Time, examTime int64, isExpire bool) (ItemTime, AnnualExamDetail, error) { var item ItemTime var detail AnnualExamDetail // 年检时间 annualExamString := "" var annualExamYear int64 = 0 annualExamDesc := "" if examTime != 0 { tempTime := time.Unix(examTime/1000, 0) annualExamString = fmt.Sprintf("%d-%0.2d-%0.2d", cdrqTime.Year(), tempTime.Month(), DayCount(int(tempTime.Year()), int(tempTime.Month()))) } else { annualExamString = fmt.Sprintf("%d-%0.2d-%0.2d", cdrqTime.Year(), cdrqTime.Month(), DayCount(int(cdrqTime.Year()), int(cdrqTime.Month()))) } annualExamTime, err := time.Parse("2006-01-02", annualExamString) if err != nil { return item, detail, errors.TimeCalcFailed } for i := 0; i < 2; i++ { annualExamYear += 2 annualExamTime = annualExamTime.AddDate(2, 0, 0) annualExamDesc = "4年车龄2年年检1次" if annualExamTime.After(nowTime) { if isExpire { annualExamTime = annualExamTime.AddDate(-2, 0, 0) } goto CALCANNUALEXAMTIME } } for i := 0; i < 30; i++ { annualExamYear += 1 annualExamTime = annualExamTime.AddDate(1, 0, 0) annualExamDesc = "4年以上车龄1年年检1次" if annualExamTime.After(nowTime) { if isExpire { annualExamTime = annualExamTime.AddDate(-1, 0, 0) } goto CALCANNUALEXAMTIME } } CALCANNUALEXAMTIME: item.Date = annualExamTime.Format("2006-01-02 15:04:05") item.Day = DeltaTimeByDay(annualExamTime, nowTime) detail.NumYear = annualExamYear detail.Desc = annualExamDesc return item, detail, nil } func CalcAnnualExamTimeRule1(nowTime time.Time, cdrqTime time.Time, examTime int64, isExpire bool) (ItemTime, AnnualExamDetail, error) { return CalcAnnualExamTimeOperation(nowTime, cdrqTime, examTime, isExpire) } func CalcAnnualExamTimeRule2(nowTime time.Time, cdrqTime time.Time, examTime int64, isExpire bool) (ItemTime, AnnualExamDetail, error) { return CalcAnnualExamTimeBigVehicle(nowTime, cdrqTime, examTime, isExpire) } func CalcAnnualExamTimeRule3(nowTime time.Time, cdrqTime time.Time, examTime int64, isExpire bool) (ItemTime, AnnualExamDetail, error) { return CalcAnnualExamTime(nowTime, cdrqTime, examTime, isExpire) } func CalcAnnualExamTimeRule4(nowTime time.Time, cdrqTime time.Time, examTime int64, isExpire bool) (ItemTime, AnnualExamDetail, error) { return CalcAnnualExamTimeMotor(nowTime, cdrqTime, examTime, isExpire) } func CalcAnnualExamTimeRule5(nowTime time.Time, cdrqTime time.Time, examTime int64, isExpire bool) (ItemTime, AnnualExamDetail, error) { var item ItemTime var detail AnnualExamDetail // 年检时间 annualExamString := "" var annualExamYear int64 = 0 annualExamDesc := "" if examTime != 0 { tempTime := time.Unix(examTime/1000, 0) annualExamString = fmt.Sprintf("%d-%0.2d-%0.2d", cdrqTime.Year(), tempTime.Month(), DayCount(int(tempTime.Year()), int(tempTime.Month()))) } else { annualExamString = fmt.Sprintf("%d-%0.2d-%0.2d", cdrqTime.Year(), cdrqTime.Month(), DayCount(int(cdrqTime.Year()), int(cdrqTime.Month()))) } annualExamTime, err := time.Parse("2006-01-02", annualExamString) if err != nil { return item, detail, errors.TimeCalcFailed } for i := 0; i < 30; i++ { annualExamYear += 1 annualExamTime = annualExamTime.AddDate(1, 0, 0) annualExamDesc = "每年年检1次" if annualExamTime.After(nowTime) { if isExpire { annualExamTime = annualExamTime.AddDate(-1, 0, 0) } goto CALCANNUALEXAMTIME } } CALCANNUALEXAMTIME: item.Date = annualExamTime.Format("2006-01-02 15:04:05") item.Day = DeltaTimeByDay(annualExamTime, nowTime) detail.NumYear = annualExamYear detail.Desc = annualExamDesc return item, detail, nil } func CalcAnnualExamTimeRule6(nowTime time.Time, cdrqTime time.Time, examTime int64, isExpire bool) (ItemTime, AnnualExamDetail, error) { var item ItemTime var detail AnnualExamDetail // 年检时间 annualExamString := "" var annualExamYear int64 = 0 annualExamDesc := "" if examTime != 0 { tempTime := time.Unix(examTime/1000, 0) annualExamString = fmt.Sprintf("%d-%0.2d-%0.2d", cdrqTime.Year(), tempTime.Month(), DayCount(int(tempTime.Year()), int(tempTime.Month()))) } else { annualExamString = fmt.Sprintf("%d-%0.2d-%0.2d", cdrqTime.Year(), cdrqTime.Month(), DayCount(int(cdrqTime.Year()), int(cdrqTime.Month()))) } annualExamTime, err := time.Parse("2006-01-02", annualExamString) if err != nil { return item, detail, errors.TimeCalcFailed } for i := 0; i < 30; i++ { if i%2 == 0 { annualExamYear += 1 } annualExamTime = annualExamTime.AddDate(0, 6, 0) annualExamDesc = "每6个月年检1次" if annualExamTime.After(nowTime) { if isExpire { annualExamTime = annualExamTime.AddDate(0, -6, 0) } goto CALCANNUALEXAMTIME } } CALCANNUALEXAMTIME: item.Date = annualExamTime.Format("2006-01-02 15:04:05") item.Day = DeltaTimeByDay(annualExamTime, nowTime) detail.NumYear = annualExamYear detail.Desc = annualExamDesc return item, detail, nil } func CalcAnnualExamTime(nowTime time.Time, cdrqTime time.Time, examTime int64, isExpire bool) (ItemTime, AnnualExamDetail, error) { var item ItemTime var detail AnnualExamDetail // 年检时间 annualExamString := "" var annualExamYear int64 = 0 annualExamDesc := "" if examTime != 0 { tempTime := time.Unix(examTime/1000, 0) annualExamString = fmt.Sprintf("%d-%0.2d-%0.2d", cdrqTime.Year(), tempTime.Month(), DayCount(int(tempTime.Year()), int(tempTime.Month()))) } else { annualExamString = fmt.Sprintf("%d-%0.2d-%0.2d", cdrqTime.Year(), cdrqTime.Month(), DayCount(int(cdrqTime.Year()), int(cdrqTime.Month()))) } annualExamTime, err := time.Parse("2006-01-02", annualExamString) if err != nil { return item, detail, errors.TimeCalcFailed } for i := 0; i < 5; i++ { annualExamYear += 2 annualExamTime = annualExamTime.AddDate(2, 0, 0) annualExamDesc = "10年车龄2年年检1次" if annualExamTime.After(nowTime) { if isExpire { annualExamTime = annualExamTime.AddDate(-2, 0, 0) } goto CALCANNUALEXAMTIME } } for i := 0; i < 5; i++ { annualExamYear += 1 annualExamTime = annualExamTime.AddDate(1, 0, 0) annualExamDesc = "10年以上车龄1年年检1次" if annualExamTime.After(nowTime) { if isExpire { annualExamTime = annualExamTime.AddDate(-1, 0, 0) } goto CALCANNUALEXAMTIME } } for i := 0; i < 30; i++ { if i%2 == 0 { annualExamYear += 1 } annualExamTime = annualExamTime.AddDate(0, 6, 0) annualExamDesc = "15年以上车龄每6个月年检1次" if annualExamTime.After(nowTime) { if isExpire { annualExamTime = annualExamTime.AddDate(0, -6, 0) } goto CALCANNUALEXAMTIME } } CALCANNUALEXAMTIME: item.Date = annualExamTime.Format("2006-01-02 15:04:05") item.Day = DeltaTimeByDay(annualExamTime, nowTime) detail.NumYear = annualExamYear detail.Desc = annualExamDesc return item, detail, nil } func CalcAnnualExamTimeRule7(nowTime time.Time, cdrqTime time.Time, examTime int64, isExpire bool) (ItemTime, AnnualExamDetail, error) { return CalcAnnualExamTime(nowTime, cdrqTime, examTime, isExpire) } func calcAnnualExamTimeByRule(nowTime time.Time, cdrqTime time.Time, rule int, isExpire bool) (ItemTime, AnnualExamDetail, error) { if rule == rule1 { return CalcAnnualExamTimeRule1(nowTime, cdrqTime, 0, isExpire) } if rule == rule2 { return CalcAnnualExamTimeRule2(nowTime, cdrqTime, 0, isExpire) } if rule == rule3 { return CalcAnnualExamTimeRule3(nowTime, cdrqTime, 0, isExpire) } if rule == rule4 { return CalcAnnualExamTimeRule4(nowTime, cdrqTime, 0, isExpire) } if rule == rule5 { return CalcAnnualExamTimeRule5(nowTime, cdrqTime, 0, isExpire) } if rule == rule6 { return CalcAnnualExamTimeRule6(nowTime, cdrqTime, 0, isExpire) } return CalcAnnualExamTimeRule7(nowTime, cdrqTime, 0, isExpire) } var OperationProperty = map[string]string{"B": "", "C": "", "D": "", "E": "", "F": "", "G": "", "R": "", "T": ""} var UnoperationProperty = map[string]string{"A": "", "H": "", "I": "", "J": "", "K": "", "L": "", "M": "", "N": "", "U": ""} func isOperation(usePropery string) bool { if usePropery == "" { return false } bytes := []byte(usePropery) for _, v := range bytes { s := fmt.Sprintf("%c", v) if _, ok := OperationProperty[s]; ok == false { return false } } return true } func isUnoperation(usePropery string) bool { if usePropery == "" { return false } bytes := []byte(usePropery) for _, v := range bytes { s := fmt.Sprintf("%c", v) if _, ok := UnoperationProperty[s]; ok == false { return false } } return true } func isRule1(useProperty string, vehicleType string, seat int, reg time.Time) bool { if isOperation(useProperty) == false { return false } if vehicleType == "K10" || vehicleType == "K11" || vehicleType == "K12" || vehicleType == "K13" || vehicleType == "K14" || vehicleType == "K15" || vehicleType == "K16" || vehicleType == "K17" || vehicleType == "K20" || vehicleType == "K21" || vehicleType == "K22" || vehicleType == "K23" || vehicleType == "K24" || vehicleType == "K25" || vehicleType == "K26" || vehicleType == "K27" || vehicleType == "K30" || vehicleType == "K31" || vehicleType == "K32" || vehicleType == "K33" || vehicleType == "K34" || vehicleType == "K39" || vehicleType == "K40" || vehicleType == "K41" || vehicleType == "K42" || vehicleType == "K43" { return true } return false } func isRule2(useProperty string, vehicleType string, seat int, reg time.Time) bool { if strings.Contains(vehicleType, "G") || strings.Contains(vehicleType, "Q") || strings.Contains(vehicleType, "B") || strings.Contains(vehicleType, "H") { return true } if isUnoperation(useProperty) == false { return false } if vehicleType == "K10" || vehicleType == "K11" || vehicleType == "K12" || vehicleType == "K13" || vehicleType == "K14" || vehicleType == "K15" || vehicleType == "K16" || vehicleType == "K17" || vehicleType == "K20" || vehicleType == "K21" || vehicleType == "K22" || vehicleType == "K23" || vehicleType == "K24" || vehicleType == "K25" || vehicleType == "K26" || vehicleType == "K27" { return true } return false } func isRule3(useProperty string, vehicleType string, seat int, reg time.Time) bool { if isUnoperation(useProperty) == false { return false } if vehicleType == "K30" || vehicleType == "K31" || vehicleType == "K32" || vehicleType == "K33" || vehicleType == "K34" || vehicleType == "K40" || vehicleType == "K41" || vehicleType == "K42" || vehicleType == "K43" || vehicleType == "K39" || vehicleType == "K49" { return true } return false } func isRule4(useProperty string, vehicleType string, seat int, reg time.Time) bool { if strings.Contains(vehicleType, "M") { return true } return false } func isRule5(useProperty string, vehicleType string, seat int, reg time.Time) bool { if strings.Contains(vehicleType, "T") || strings.Contains(vehicleType, "J") || strings.Contains(vehicleType, "X") || strings.Contains(vehicleType, "Z") { return true } return false } func isRule6(useProperty string, vehicleType string, seat int, reg time.Time) bool { if useProperty == "O" || useProperty == "P" || useProperty == "Q" || useProperty == "S" { return true } if vehicleType == "K18" || vehicleType == "K28" || vehicleType == "K38" { return true } return false } func isRule7(useProperty string, vehicleType string, seat int, reg time.Time, casualty bool) bool { if useProperty != "A" { return false } if seat >= 10 || seat <= 0 { return false } if casualty == true { return false } if reg.Year() < 2010 { return false } if reg.Year() == 2010 && reg.Month() < 9 { return false } if vehicleType == "K16" || vehicleType == "K26" || vehicleType == "K30" || vehicleType == "K31" || vehicleType == "K32" || vehicleType == "K33" || vehicleType == "K34" || vehicleType == "K40" || vehicleType == "K41" || vehicleType == "K42" || vehicleType == "K43" { return true } return false } func getRule(useProperty string, vehicleType string, seat int, reg time.Time, casualty bool) int { if isRule7(useProperty, vehicleType, seat, reg, casualty) { return rule7 } if isRule1(useProperty, vehicleType, seat, reg) { return rule1 } if isRule2(useProperty, vehicleType, seat, reg) { return rule2 } if isRule3(useProperty, vehicleType, seat, reg) { return rule3 } if isRule4(useProperty, vehicleType, seat, reg) { return rule4 } if isRule5(useProperty, vehicleType, seat, reg) { return rule5 } if isRule6(useProperty, vehicleType, seat, reg) { return rule6 } return -1 } func getAnnualInsepctionTimeInfoNew(vehicleType,initialRegistrationDate string,approvedNumber int,useProperty string,casualty,isExpire bool) (annualInfo GetAnnualInspectionTimeInfo ,err error) { vehicleType = strings.ToUpper(vehicleType) useProperty = strings.ToUpper(useProperty) timeLayout := "2006-01-02" nowTime := time.Now() loc, _ := time.LoadLocation("Local") array := strings.Split(initialRegistrationDate, " ") if len(array) > 0 { initialRegistrationDate = array[0] } cdrqTime, err := time.ParseInLocation(timeLayout, initialRegistrationDate, loc) if err != nil { return annualInfo,err } rule := getRule(useProperty, vehicleType, approvedNumber, cdrqTime, casualty) if rule < 0 { return annualInfo,errors.AnnualRuleError } iterm, detail, err := calcAnnualExamTimeByRule(nowTime, cdrqTime, rule, isExpire) if err != nil { return annualInfo,err } array = strings.Split(iterm.Date, " ") annualInfo.TimeDate = fmt.Sprintf("%s到期", array[0]) annualInfo.TimeRemain = fmt.Sprintf("剩%d天", iterm.Day) annualInfo.TimeYear = fmt.Sprintf("第%d年", detail.NumYear) annualInfo.Rule = detail.Desc if rule == rule7 { //可免检 if strings.Contains(detail.Desc, "10年车龄2年年检1次") && !casualty { annualInfo.CanBeUncheck = true } } if iterm.Day < 90 { //距年审90天内可年审 annualInfo.CanBeInspection = true } return annualInfo,nil } // 年检时间计算 func calcAnnualExamTimeNew(reqMap map[string]interface{}, isExpire bool) { vehicleType ,_:= getMapValueString("vehicle_type",reqMap) initialRegistrationDate,_ := getMapValueString("initial_registration_date",reqMap) insuranceFirstDate ,_:= getMapValueString("insurance_first_date",reqMap) useProperty,_ := getMapValueString("use_property",reqMap) approvedNumber := getMapValueInt("approved_number",reqMap) if initialRegistrationDate != "" || insuranceFirstDate != "" { VehicleType := "K33" if vehicleType != "" { VehicleType = vehicleType } InitialRegistrationDate := "" if initialRegistrationDate == "" { InitialRegistrationDate = insuranceFirstDate } else { InitialRegistrationDate = initialRegistrationDate } if len(InitialRegistrationDate) > DataLen { InitialRegistrationDate = InitialRegistrationDate[:DataLen] } annualInfo,err := getAnnualInsepctionTimeInfoNew(VehicleType,InitialRegistrationDate,approvedNumber,useProperty,false,isExpire) if err == nil { reqMap["inspection_result_effective_to"] = annualInfo.TimeDate[:DataLen] + " 00:00:00" } /*vReq := gd_service.ServiceGetAnnualInspectionTimeNewReq{VehicleType: VehicleType, RegDate: InitialRegistrationDate, SeatNumber: vehicle.ApprovedNumber, UseProperty: vehicle.UseProperty, Casualty: false, IsExpire: isExpire} vReply, err := rpc_apis.Service.ServiceGetAnnualInspectionTimeNew(context.Background(), &vReq) if err != nil || vReply.ErrCode != 0 { } else { vehicle.InspectionResultEffectiveTo = vReply.Info.TimeDate[:dutils.DataLen] + " 00:00:00" }*/ } } func CalcAnnualExamExpireTime(reqMap map[string]interface{}){ inspectionResultEffectiveTo,isExist := getMapValueString("inspection_result_effective_to",reqMap) if !isExist{ return } state ,_:= getMapValueString("state",reqMap) if inspectionResultEffectiveTo != "" { lastTime, _ := time.Parse(DaySecLayout, inspectionResultEffectiveTo) if strings.Contains(state, "E") || strings.Contains(state, "K") || strings.Contains(state, "P") || strings.Contains(state, "Q") { if lastTime.After(time.Now()) { calcAnnualExamTimeNew(reqMap, true) } } else if lastTime.Before(time.Now()) { calcAnnualExamTimeNew(reqMap, false) } } else { if strings.Contains(state, "E") || strings.Contains(state, "K") || strings.Contains(state, "P") || strings.Contains(state, "Q") { calcAnnualExamTimeNew(reqMap, true) } else { calcAnnualExamTimeNew(reqMap, false) } } }