|
@@ -16,6 +16,38 @@ import (
|
|
|
"git.getensh.com/common/gopkgsv2/database"
|
|
|
)
|
|
|
|
|
|
+func calcMoto(vehicleTypeDetail, tyreNumber, displacement, ratedPower string) (plateType string, vehicleType string) {
|
|
|
+ // 摩托车不处理
|
|
|
+ if vehicleTypeDetail != "" && strings.Contains(vehicleTypeDetail, "摩托") {
|
|
|
+ if vehicleTypeDetail == "两轮轻便摩托车" {
|
|
|
+ vehicleType = "M22"
|
|
|
+ plateType = "08"
|
|
|
+ } else if vehicleTypeDetail == "两轮摩托车" {
|
|
|
+ vehicleType = "M21"
|
|
|
+ plateType = "07"
|
|
|
+ } else {
|
|
|
+ ratedPowerFloat, _ := strconv.ParseFloat(ratedPower, 64)
|
|
|
+ displacementFloat, _ := strconv.ParseFloat(displacement, 64)
|
|
|
+ if tyreNumber == "2" {
|
|
|
+ if ratedPowerFloat <= 4 && displacementFloat <= 50 {
|
|
|
+ vehicleType = "M22"
|
|
|
+ plateType = "08"
|
|
|
+ } else {
|
|
|
+ vehicleType = "M21"
|
|
|
+ plateType = "07"
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if ratedPowerFloat <= 4 && displacementFloat <= 50 {
|
|
|
+ plateType = "08"
|
|
|
+ } else {
|
|
|
+ plateType = "07"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return plateType, vehicleType
|
|
|
+}
|
|
|
+
|
|
|
func getString(key string, old map[string]interface{}) string {
|
|
|
if v, ok := old[key]; ok {
|
|
|
switch v.(type) {
|
|
@@ -66,10 +98,24 @@ func supplementPlateTypeByCalc(old map[string]interface{}) {
|
|
|
switch v.(type) {
|
|
|
case string:
|
|
|
if v.(string) == "" {
|
|
|
- longStr := getString("long", old)
|
|
|
- approvedNumberStr := getString("approved_number", old)
|
|
|
- grossMassStr := getString("gross_mass", old)
|
|
|
- old["plate_type"] = calcPlateType(longStr, approvedNumberStr, grossMassStr)
|
|
|
+ vehicleTypeDetail := getString("vehicle_type_detail", old)
|
|
|
+ tyreNumber := getString("tyre_number", old)
|
|
|
+ displacement := getString("displacement", old)
|
|
|
+ ratedPower := getString("rated_power", old)
|
|
|
+
|
|
|
+ plateType, vehicleType := calcMoto(vehicleTypeDetail, tyreNumber, displacement, ratedPower)
|
|
|
+ if plateType != "" {
|
|
|
+ old["plate_type"] = plateType
|
|
|
+ if _, ok1 := old["vehicle_type"]; ok1 {
|
|
|
+ old["vehicle_type"] = vehicleType
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ longStr := getString("long", old)
|
|
|
+ approvedNumberStr := getString("approved_number", old)
|
|
|
+ grossMassStr := getString("gross_mass", old)
|
|
|
+ old["plate_type"] = calcPlateType(longStr, approvedNumberStr, grossMassStr)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|