vehicle_type.go 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. package utils
  2. import (
  3. "strings"
  4. )
  5. // 全量补充
  6. // 车辆类型大中小等定义
  7. const (
  8. KvehicleUnknow = 0
  9. KvehicleBig = 1
  10. KvehicleMiddle = 2
  11. KvehicleSmall = 3
  12. KvehicleMicro = 4
  13. )
  14. // 计算车辆类型(K类型)
  15. func calcKVehicleType(long, approvedPassenger, displacement int) int {
  16. if long == 0 || approvedPassenger == 0 {
  17. return KvehicleUnknow
  18. }
  19. if long >= 6000 || approvedPassenger >= 20 {
  20. return KvehicleBig
  21. } else if long < 6000 && (approvedPassenger >= 9 && approvedPassenger < 20) {
  22. return KvehicleMiddle
  23. } else if long <= 3500 && displacement <= 1000 {
  24. return KvehicleMicro
  25. } else if long <= 6000 && approvedPassenger < 9 {
  26. return KvehicleSmall
  27. }
  28. return KvehicleUnknow
  29. }
  30. // 计算车辆类型(H类型)
  31. func calcHVehicleType(long, TotalWeight int) int {
  32. if TotalWeight == 0 || (long == 0 && TotalWeight < 12000) {
  33. return KvehicleUnknow
  34. }
  35. if TotalWeight >= 12000 {
  36. return KvehicleBig
  37. } else if long < 3500 && TotalWeight <= 1800 {
  38. return KvehicleMicro
  39. } else if long < 6000 && TotalWeight < 4500 {
  40. return KvehicleSmall
  41. } else if long >= 6000 || TotalWeight >= 4500 {
  42. return KvehicleMiddle
  43. }
  44. return KvehicleUnknow
  45. }
  46. // 计算车辆类型(BG类型)
  47. func calcBGVehicleType(TotalWeight int) int {
  48. if TotalWeight == 0 {
  49. return KvehicleUnknow
  50. }
  51. if TotalWeight >= 12000 {
  52. return KvehicleBig
  53. } else if TotalWeight < 4500 {
  54. return KvehicleSmall
  55. } else if TotalWeight >= 4500 && TotalWeight < 12000 {
  56. return KvehicleMiddle
  57. }
  58. return KvehicleUnknow
  59. }
  60. // 计算车辆类型
  61. func CalcVehicleType(vehicleTypeDetail string, long, approvedPassenger, displacement, TotalWeight int) (vehicleType string) {
  62. if vehicleTypeDetail == "" {
  63. return
  64. }
  65. if vehicleTypeDetail == "货车" {
  66. vehicleTypeDetail = "普通货车"
  67. }
  68. vehicleTypeDetail = strings.ToUpper(vehicleTypeDetail)
  69. switch {
  70. case strings.Contains(vehicleTypeDetail, "旅行车") || strings.Contains(vehicleTypeDetail, "乘用车") ||
  71. strings.Contains(vehicleTypeDetail, "MPV"):
  72. ret := calcKVehicleType(long, approvedPassenger, displacement)
  73. switch ret {
  74. case KvehicleBig:
  75. vehicleType = "K11"
  76. case KvehicleMiddle:
  77. vehicleType = "K21"
  78. case KvehicleSmall:
  79. vehicleType = "K31"
  80. case KvehicleMicro:
  81. vehicleType = "K41"
  82. }
  83. case strings.Contains(vehicleTypeDetail, "双层客车"):
  84. ret := calcKVehicleType(long, approvedPassenger, displacement)
  85. switch ret {
  86. case KvehicleBig:
  87. vehicleType = "K12"
  88. case KvehicleMiddle:
  89. vehicleType = "K22"
  90. }
  91. case strings.Contains(vehicleTypeDetail, "卧铺客车"):
  92. ret := calcKVehicleType(long, approvedPassenger, displacement)
  93. switch ret {
  94. case KvehicleBig:
  95. vehicleType = "K13"
  96. case KvehicleMiddle:
  97. vehicleType = "K23"
  98. }
  99. case strings.Contains(vehicleTypeDetail, "铰接客车"):
  100. ret := calcKVehicleType(long, approvedPassenger, displacement)
  101. switch ret {
  102. case KvehicleBig:
  103. vehicleType = "K14"
  104. case KvehicleMiddle:
  105. vehicleType = "K24"
  106. }
  107. case strings.Contains(vehicleTypeDetail, "越野") || strings.Contains(vehicleTypeDetail, "SUV"):
  108. ret := calcKVehicleType(long, approvedPassenger, displacement)
  109. switch ret {
  110. case KvehicleBig:
  111. vehicleType = "K15"
  112. case KvehicleMiddle:
  113. vehicleType = "K25"
  114. case KvehicleSmall:
  115. vehicleType = "K32"
  116. case KvehicleMicro:
  117. vehicleType = "K42"
  118. }
  119. case strings.Contains(vehicleTypeDetail, "轿车") ||
  120. strings.Contains(vehicleTypeDetail, "小型车") ||
  121. strings.Contains(vehicleTypeDetail, "大型车") ||
  122. strings.Contains(vehicleTypeDetail, "中型车") ||
  123. strings.Contains(vehicleTypeDetail, "中大型车") ||
  124. strings.Contains(vehicleTypeDetail, "微型车"):
  125. ret := calcKVehicleType(long, approvedPassenger, displacement)
  126. switch ret {
  127. case KvehicleBig:
  128. vehicleType = "K16"
  129. case KvehicleMiddle:
  130. vehicleType = "K26"
  131. case KvehicleSmall:
  132. vehicleType = "K33"
  133. case KvehicleMicro:
  134. vehicleType = "K43"
  135. }
  136. case strings.Contains(vehicleTypeDetail, "专用客车"):
  137. ret := calcKVehicleType(long, approvedPassenger, displacement)
  138. switch ret {
  139. case KvehicleBig:
  140. vehicleType = "K17"
  141. case KvehicleMiddle:
  142. vehicleType = "K27"
  143. case KvehicleSmall:
  144. vehicleType = "K34"
  145. }
  146. case strings.Contains(vehicleTypeDetail, "校车"):
  147. ret := calcKVehicleType(long, approvedPassenger, displacement)
  148. switch ret {
  149. case KvehicleBig:
  150. vehicleType = "K18"
  151. case KvehicleMiddle:
  152. vehicleType = "K28"
  153. case KvehicleSmall:
  154. vehicleType = "K38"
  155. case KvehicleMicro:
  156. vehicleType = "K11"
  157. }
  158. case strings.Contains(vehicleTypeDetail, "面包车") || strings.Contains(vehicleTypeDetail, "微面"):
  159. ret := calcKVehicleType(long, approvedPassenger, displacement)
  160. switch ret {
  161. case KvehicleSmall:
  162. vehicleType = "K39"
  163. case KvehicleMicro:
  164. vehicleType = "K49"
  165. }
  166. case strings.Contains(vehicleTypeDetail, "客车") || strings.Contains(vehicleTypeDetail, "轻客"):
  167. ret := calcKVehicleType(long, approvedPassenger, displacement)
  168. switch ret {
  169. case KvehicleBig:
  170. vehicleType = "K10"
  171. case KvehicleMiddle:
  172. vehicleType = "K20"
  173. case KvehicleSmall:
  174. vehicleType = "K30"
  175. case KvehicleMicro:
  176. vehicleType = "K40"
  177. }
  178. case strings.Contains(vehicleTypeDetail, "厢式货车") || strings.Contains(vehicleTypeDetail, "厢式运输车"):
  179. ret := calcHVehicleType(long, TotalWeight)
  180. switch ret {
  181. case KvehicleBig:
  182. vehicleType = "H12"
  183. case KvehicleMiddle:
  184. vehicleType = "H22"
  185. case KvehicleSmall:
  186. vehicleType = "H32"
  187. case KvehicleMicro:
  188. vehicleType = "H42"
  189. }
  190. case strings.Contains(vehicleTypeDetail, "封闭货车") || strings.Contains(vehicleTypeDetail, "封闭运输车"):
  191. ret := calcHVehicleType(long, TotalWeight)
  192. switch ret {
  193. case KvehicleBig:
  194. vehicleType = "H13"
  195. case KvehicleMiddle:
  196. vehicleType = "H23"
  197. case KvehicleSmall:
  198. vehicleType = "H33"
  199. case KvehicleMicro:
  200. vehicleType = "H43"
  201. }
  202. case strings.Contains(vehicleTypeDetail, "罐式货车") || strings.Contains(vehicleTypeDetail, "罐式运输车"):
  203. ret := calcHVehicleType(long, TotalWeight)
  204. switch ret {
  205. case KvehicleBig:
  206. vehicleType = "H14"
  207. case KvehicleMiddle:
  208. vehicleType = "H24"
  209. case KvehicleSmall:
  210. vehicleType = "H34"
  211. case KvehicleMicro:
  212. vehicleType = "H44"
  213. }
  214. case strings.Contains(vehicleTypeDetail, "平板货车") || strings.Contains(vehicleTypeDetail, "平板运输车"):
  215. ret := calcHVehicleType(long, TotalWeight)
  216. switch ret {
  217. case KvehicleBig:
  218. vehicleType = "H15"
  219. case KvehicleMiddle:
  220. vehicleType = "H25"
  221. case KvehicleSmall:
  222. vehicleType = "H35"
  223. }
  224. case strings.Contains(vehicleTypeDetail, "集装厢车") || strings.Contains(vehicleTypeDetail, "集装运输车"):
  225. ret := calcHVehicleType(long, TotalWeight)
  226. switch ret {
  227. case KvehicleBig:
  228. vehicleType = "H16"
  229. case KvehicleMiddle:
  230. vehicleType = "H26"
  231. }
  232. case strings.Contains(vehicleTypeDetail, "自卸汽车") || strings.Contains(vehicleTypeDetail, "自卸货车") || strings.Contains(vehicleTypeDetail, "自卸运输车"):
  233. ret := calcHVehicleType(long, TotalWeight)
  234. switch ret {
  235. case KvehicleBig:
  236. vehicleType = "H17"
  237. case KvehicleMiddle:
  238. vehicleType = "H27"
  239. case KvehicleSmall:
  240. vehicleType = "H37"
  241. case KvehicleMicro:
  242. vehicleType = "H45"
  243. }
  244. case strings.Contains(vehicleTypeDetail, "特殊结构货车") || strings.Contains(vehicleTypeDetail, "特殊结构运输车"):
  245. ret := calcHVehicleType(long, TotalWeight)
  246. switch ret {
  247. case KvehicleBig:
  248. vehicleType = "H18"
  249. case KvehicleMiddle:
  250. vehicleType = "H28"
  251. case KvehicleSmall:
  252. vehicleType = "H38"
  253. case KvehicleMicro:
  254. vehicleType = "H46"
  255. }
  256. case strings.Contains(vehicleTypeDetail, "仓栅式货车") || strings.Contains(vehicleTypeDetail, "仓栅式运输车"):
  257. ret := calcHVehicleType(long, TotalWeight)
  258. switch ret {
  259. case KvehicleBig:
  260. vehicleType = "H19"
  261. case KvehicleMiddle:
  262. vehicleType = "H29"
  263. case KvehicleSmall:
  264. vehicleType = "H39"
  265. case KvehicleMicro:
  266. vehicleType = "H47"
  267. }
  268. case strings.Contains(vehicleTypeDetail, "载货汽车") || strings.Contains(vehicleTypeDetail, "普通货车"):
  269. ret := calcHVehicleType(long, TotalWeight)
  270. switch ret {
  271. case KvehicleBig:
  272. vehicleType = "H11"
  273. case KvehicleMiddle:
  274. vehicleType = "H21"
  275. case KvehicleSmall:
  276. vehicleType = "H31"
  277. case KvehicleMicro:
  278. vehicleType = "H41"
  279. }
  280. case strings.Contains(vehicleTypeDetail, "垃圾车") || strings.Contains(vehicleTypeDetail, "冷藏车") || strings.Contains(vehicleTypeDetail, "除雪车"):
  281. ret := calcHVehicleType(long, TotalWeight)
  282. switch ret {
  283. case KvehicleBig:
  284. vehicleType = "Z51"
  285. case KvehicleMiddle:
  286. vehicleType = "Z21"
  287. case KvehicleSmall:
  288. vehicleType = "Z71"
  289. case KvehicleMicro:
  290. vehicleType = "Z41"
  291. }
  292. /*case strings.Contains(vehicleTypeDetail, "半挂车"):
  293. ret := calcBGVehicleType(TotalWeight)
  294. switch ret {
  295. case KvehicleBig:
  296. vehicleType = "Z51"
  297. case KvehicleMiddle:
  298. vehicleType = "Z21"
  299. case KvehicleSmall:
  300. vehicleType = "Z71"
  301. }
  302. case strings.Contains(vehicleTypeDetail, "全挂车"):
  303. ret := calcBGVehicleType(TotalWeight)
  304. switch ret {
  305. case KvehicleBig:
  306. vehicleType = "Z51"
  307. case KvehicleMiddle:
  308. vehicleType = "Z21"
  309. case KvehicleSmall:
  310. vehicleType = "Z71"
  311. }
  312. */
  313. default:
  314. if strings.Contains(vehicleTypeDetail, "货车") {
  315. ret := calcHVehicleType(long, TotalWeight)
  316. switch ret {
  317. case KvehicleBig:
  318. vehicleType = "H11"
  319. case KvehicleMiddle:
  320. vehicleType = "H21"
  321. case KvehicleSmall:
  322. vehicleType = "H31"
  323. case KvehicleMicro:
  324. vehicleType = "H41"
  325. }
  326. }
  327. }
  328. return
  329. }