123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346 |
- package utils
- import (
- "strings"
- )
- // 全量补充
- // 车辆类型大中小等定义
- const (
- KvehicleUnknow = 0
- KvehicleBig = 1
- KvehicleMiddle = 2
- KvehicleSmall = 3
- KvehicleMicro = 4
- )
- // 计算车辆类型(K类型)
- func calcKVehicleType(long, approvedPassenger, displacement int) int {
- if long == 0 || approvedPassenger == 0 {
- return KvehicleUnknow
- }
- if long >= 6000 || approvedPassenger >= 20 {
- return KvehicleBig
- } else if long < 6000 && (approvedPassenger >= 9 && approvedPassenger < 20) {
- return KvehicleMiddle
- } else if long <= 3500 && displacement <= 1000 {
- return KvehicleMicro
- } else if long <= 6000 && approvedPassenger < 9 {
- return KvehicleSmall
- }
- return KvehicleUnknow
- }
- // 计算车辆类型(H类型)
- func calcHVehicleType(long, TotalWeight int) int {
- if TotalWeight == 0 || (long == 0 && TotalWeight < 12000) {
- return KvehicleUnknow
- }
- if TotalWeight >= 12000 {
- return KvehicleBig
- } else if long < 3500 && TotalWeight <= 1800 {
- return KvehicleMicro
- } else if long < 6000 && TotalWeight < 4500 {
- return KvehicleSmall
- } else if long >= 6000 || TotalWeight >= 4500 {
- return KvehicleMiddle
- }
- return KvehicleUnknow
- }
- // 计算车辆类型(BG类型)
- func calcBGVehicleType(TotalWeight int) int {
- if TotalWeight == 0 {
- return KvehicleUnknow
- }
- if TotalWeight >= 12000 {
- return KvehicleBig
- } else if TotalWeight < 4500 {
- return KvehicleSmall
- } else if TotalWeight >= 4500 && TotalWeight < 12000 {
- return KvehicleMiddle
- }
- return KvehicleUnknow
- }
- // 计算车辆类型
- func CalcVehicleType(vehicleTypeDetail string, long, approvedPassenger, displacement, TotalWeight int) (vehicleType string) {
- if vehicleTypeDetail == "" {
- return
- }
- if vehicleTypeDetail == "货车" {
- vehicleTypeDetail = "普通货车"
- }
- vehicleTypeDetail = strings.ToUpper(vehicleTypeDetail)
- switch {
- case strings.Contains(vehicleTypeDetail, "旅行车") || strings.Contains(vehicleTypeDetail, "乘用车") ||
- strings.Contains(vehicleTypeDetail, "MPV"):
- ret := calcKVehicleType(long, approvedPassenger, displacement)
- switch ret {
- case KvehicleBig:
- vehicleType = "K11"
- case KvehicleMiddle:
- vehicleType = "K21"
- case KvehicleSmall:
- vehicleType = "K31"
- case KvehicleMicro:
- vehicleType = "K41"
- }
- case strings.Contains(vehicleTypeDetail, "双层客车"):
- ret := calcKVehicleType(long, approvedPassenger, displacement)
- switch ret {
- case KvehicleBig:
- vehicleType = "K12"
- case KvehicleMiddle:
- vehicleType = "K22"
- }
- case strings.Contains(vehicleTypeDetail, "卧铺客车"):
- ret := calcKVehicleType(long, approvedPassenger, displacement)
- switch ret {
- case KvehicleBig:
- vehicleType = "K13"
- case KvehicleMiddle:
- vehicleType = "K23"
- }
- case strings.Contains(vehicleTypeDetail, "铰接客车"):
- ret := calcKVehicleType(long, approvedPassenger, displacement)
- switch ret {
- case KvehicleBig:
- vehicleType = "K14"
- case KvehicleMiddle:
- vehicleType = "K24"
- }
- case strings.Contains(vehicleTypeDetail, "越野") || strings.Contains(vehicleTypeDetail, "SUV"):
- ret := calcKVehicleType(long, approvedPassenger, displacement)
- switch ret {
- case KvehicleBig:
- vehicleType = "K15"
- case KvehicleMiddle:
- vehicleType = "K25"
- case KvehicleSmall:
- vehicleType = "K32"
- case KvehicleMicro:
- vehicleType = "K42"
- }
- case strings.Contains(vehicleTypeDetail, "轿车") ||
- strings.Contains(vehicleTypeDetail, "小型车") ||
- strings.Contains(vehicleTypeDetail, "大型车") ||
- strings.Contains(vehicleTypeDetail, "中型车") ||
- strings.Contains(vehicleTypeDetail, "中大型车") ||
- strings.Contains(vehicleTypeDetail, "微型车"):
- ret := calcKVehicleType(long, approvedPassenger, displacement)
- switch ret {
- case KvehicleBig:
- vehicleType = "K16"
- case KvehicleMiddle:
- vehicleType = "K26"
- case KvehicleSmall:
- vehicleType = "K33"
- case KvehicleMicro:
- vehicleType = "K43"
- }
- case strings.Contains(vehicleTypeDetail, "专用客车"):
- ret := calcKVehicleType(long, approvedPassenger, displacement)
- switch ret {
- case KvehicleBig:
- vehicleType = "K17"
- case KvehicleMiddle:
- vehicleType = "K27"
- case KvehicleSmall:
- vehicleType = "K34"
- }
- case strings.Contains(vehicleTypeDetail, "校车"):
- ret := calcKVehicleType(long, approvedPassenger, displacement)
- switch ret {
- case KvehicleBig:
- vehicleType = "K18"
- case KvehicleMiddle:
- vehicleType = "K28"
- case KvehicleSmall:
- vehicleType = "K38"
- case KvehicleMicro:
- vehicleType = "K11"
- }
- case strings.Contains(vehicleTypeDetail, "面包车") || strings.Contains(vehicleTypeDetail, "微面"):
- ret := calcKVehicleType(long, approvedPassenger, displacement)
- switch ret {
- case KvehicleSmall:
- vehicleType = "K39"
- case KvehicleMicro:
- vehicleType = "K49"
- }
- case strings.Contains(vehicleTypeDetail, "客车") || strings.Contains(vehicleTypeDetail, "轻客"):
- ret := calcKVehicleType(long, approvedPassenger, displacement)
- switch ret {
- case KvehicleBig:
- vehicleType = "K10"
- case KvehicleMiddle:
- vehicleType = "K20"
- case KvehicleSmall:
- vehicleType = "K30"
- case KvehicleMicro:
- vehicleType = "K40"
- }
- case strings.Contains(vehicleTypeDetail, "厢式货车") || strings.Contains(vehicleTypeDetail, "厢式运输车"):
- ret := calcHVehicleType(long, TotalWeight)
- switch ret {
- case KvehicleBig:
- vehicleType = "H12"
- case KvehicleMiddle:
- vehicleType = "H22"
- case KvehicleSmall:
- vehicleType = "H32"
- case KvehicleMicro:
- vehicleType = "H42"
- }
- case strings.Contains(vehicleTypeDetail, "封闭货车") || strings.Contains(vehicleTypeDetail, "封闭运输车"):
- ret := calcHVehicleType(long, TotalWeight)
- switch ret {
- case KvehicleBig:
- vehicleType = "H13"
- case KvehicleMiddle:
- vehicleType = "H23"
- case KvehicleSmall:
- vehicleType = "H33"
- case KvehicleMicro:
- vehicleType = "H43"
- }
- case strings.Contains(vehicleTypeDetail, "罐式货车") || strings.Contains(vehicleTypeDetail, "罐式运输车"):
- ret := calcHVehicleType(long, TotalWeight)
- switch ret {
- case KvehicleBig:
- vehicleType = "H14"
- case KvehicleMiddle:
- vehicleType = "H24"
- case KvehicleSmall:
- vehicleType = "H34"
- case KvehicleMicro:
- vehicleType = "H44"
- }
- case strings.Contains(vehicleTypeDetail, "平板货车") || strings.Contains(vehicleTypeDetail, "平板运输车"):
- ret := calcHVehicleType(long, TotalWeight)
- switch ret {
- case KvehicleBig:
- vehicleType = "H15"
- case KvehicleMiddle:
- vehicleType = "H25"
- case KvehicleSmall:
- vehicleType = "H35"
- }
- case strings.Contains(vehicleTypeDetail, "集装厢车") || strings.Contains(vehicleTypeDetail, "集装运输车"):
- ret := calcHVehicleType(long, TotalWeight)
- switch ret {
- case KvehicleBig:
- vehicleType = "H16"
- case KvehicleMiddle:
- vehicleType = "H26"
- }
- case strings.Contains(vehicleTypeDetail, "自卸汽车") || strings.Contains(vehicleTypeDetail, "自卸货车") || strings.Contains(vehicleTypeDetail, "自卸运输车"):
- ret := calcHVehicleType(long, TotalWeight)
- switch ret {
- case KvehicleBig:
- vehicleType = "H17"
- case KvehicleMiddle:
- vehicleType = "H27"
- case KvehicleSmall:
- vehicleType = "H37"
- case KvehicleMicro:
- vehicleType = "H45"
- }
- case strings.Contains(vehicleTypeDetail, "特殊结构货车") || strings.Contains(vehicleTypeDetail, "特殊结构运输车"):
- ret := calcHVehicleType(long, TotalWeight)
- switch ret {
- case KvehicleBig:
- vehicleType = "H18"
- case KvehicleMiddle:
- vehicleType = "H28"
- case KvehicleSmall:
- vehicleType = "H38"
- case KvehicleMicro:
- vehicleType = "H46"
- }
- case strings.Contains(vehicleTypeDetail, "仓栅式货车") || strings.Contains(vehicleTypeDetail, "仓栅式运输车"):
- ret := calcHVehicleType(long, TotalWeight)
- switch ret {
- case KvehicleBig:
- vehicleType = "H19"
- case KvehicleMiddle:
- vehicleType = "H29"
- case KvehicleSmall:
- vehicleType = "H39"
- case KvehicleMicro:
- vehicleType = "H47"
- }
- case strings.Contains(vehicleTypeDetail, "载货汽车") || strings.Contains(vehicleTypeDetail, "普通货车"):
- ret := calcHVehicleType(long, TotalWeight)
- switch ret {
- case KvehicleBig:
- vehicleType = "H11"
- case KvehicleMiddle:
- vehicleType = "H21"
- case KvehicleSmall:
- vehicleType = "H31"
- case KvehicleMicro:
- vehicleType = "H41"
- }
- case strings.Contains(vehicleTypeDetail, "垃圾车") || strings.Contains(vehicleTypeDetail, "冷藏车") || strings.Contains(vehicleTypeDetail, "除雪车"):
- ret := calcHVehicleType(long, TotalWeight)
- switch ret {
- case KvehicleBig:
- vehicleType = "Z51"
- case KvehicleMiddle:
- vehicleType = "Z21"
- case KvehicleSmall:
- vehicleType = "Z71"
- case KvehicleMicro:
- vehicleType = "Z41"
- }
- /*case strings.Contains(vehicleTypeDetail, "半挂车"):
- ret := calcBGVehicleType(TotalWeight)
- switch ret {
- case KvehicleBig:
- vehicleType = "Z51"
- case KvehicleMiddle:
- vehicleType = "Z21"
- case KvehicleSmall:
- vehicleType = "Z71"
- }
- case strings.Contains(vehicleTypeDetail, "全挂车"):
- ret := calcBGVehicleType(TotalWeight)
- switch ret {
- case KvehicleBig:
- vehicleType = "Z51"
- case KvehicleMiddle:
- vehicleType = "Z21"
- case KvehicleSmall:
- vehicleType = "Z71"
- }
- */
- default:
- if strings.Contains(vehicleTypeDetail, "货车") {
- ret := calcHVehicleType(long, TotalWeight)
- switch ret {
- case KvehicleBig:
- vehicleType = "H11"
- case KvehicleMiddle:
- vehicleType = "H21"
- case KvehicleSmall:
- vehicleType = "H31"
- case KvehicleMicro:
- vehicleType = "H41"
- }
- }
- }
- return
- }
|