jaryhe 7 hónapja
szülő
commit
728c9e7415

+ 18 - 18
apis/vehicle_new.go

@@ -31,33 +31,33 @@ type VehicleNew struct {
 	EngineType                  string `json:"engine_type" description:"发动机型号"`
 	FuelType                    string `json:"fuel_type" description:"燃料种类"`
 	FuelTypeDetail              string `json:"fuel_type_detail"` //
-	Displacement                int    `json:"displacement" description:"排量"`
-	RatedPower                  int    `json:"rated_power" description:"功率"`
-	AxleNumber                  int    `json:"axle_number" description:"轴数"`
-	WheelBase                   int    `json:"wheel_base" description:"轴距"`
-	FrontWheelDistance          int    `json:"front_wheel_distance" description:"前轮距"`
-	BackWheelDistance           int    `json:"back_wheel_distance" description:"后轮距"`
-	GrossMass                   int    `json:"gross_mass" description:"总质量"`
-	UnladenMass                 int    `json:"unladen_mass" description:"装备质量"`
-	ApprovedLoad                int    `json:"approved_load" description:"核定载重量"`
-	ApprovedNumber              int    `json:"approved_number" description:"核定载客"`
+	Displacement                string    `json:"displacement" description:"排量"`
+	RatedPower                  string    `json:"rated_power" description:"功率"`
+	AxleNumber                  string    `json:"axle_number" description:"轴数"`
+	WheelBase                   string    `json:"wheel_base" description:"轴距"`
+	FrontWheelDistance          string    `json:"front_wheel_distance" description:"前轮距"`
+	BackWheelDistance           string    `json:"back_wheel_distance" description:"后轮距"`
+	GrossMass                   string    `json:"gross_mass" description:"总质量"`
+	UnladenMass                 string    `json:"unladen_mass" description:"装备质量"`
+	ApprovedLoad                string    `json:"approved_load" description:"核定载重量"`
+	ApprovedNumber              string    `json:"approved_number" description:"核定载客"`
 	ReleaseDate                 string `json:"release_date" description:"出厂日期"`
 	IsOwner                     string `json:"is_owner" orm:"-"`
 	IsSupplement                bool   `json:"is_supplement"`
-	CreateTime                  string `json:"create_time"`
-	UpdateTime                  string `json:"update_time"`
-	Timestamp                   int64  `json:"timestamp"` //
+	//CreateTime                  string `json:"create_time"`
+	//UpdateTime                  string `json:"update_time"`
+	//Timestamp                   string  `json:"timestamp"` //
 	UtSource                    string `json:"ut_source"` //
 	Dataid                      string `json:"dataid"`
 	LastCompulsoryInsuranceDate string `json:"last_compulsory_insurance_date"`     // 最近一次交强险投保年月
 	OilWear                     string `json:"oil_wear"`                           //油耗
-	Long                        int    `json:"long"`                               //长
-	Wide                        int    `json:"wide"`                               // 宽
-	High                        int    `json:"high"`                               // 高
+	Long                        string    `json:"long"`                               //长
+	Wide                        string    `json:"wide"`                               // 宽
+	High                        string    `json:"high"`                               // 高
 	EmissionStandard            string `json:"emission_standard"`                  // 排放标准
-	TyreNumber                  int    `json:"tyre_number"`                        // 轮胎数
+	TyreNumber                  string    `json:"tyre_number"`                        // 轮胎数
 	TyreSize                    string `json:"tyre_size"`                          // 轮胎规格
 	AxleWeight                  string `json:"axle_weight"`                        // 轴荷
 	VehicleModel                string `json:"vehicle_model"`                      // 车型
-	TractionMass                int    `json:"traction_mass" descrition:"准牵引总质量 "` // spy 独有,A008
+	TractionMass                string    `json:"traction_mass" descrition:"准牵引总质量 "` // spy 独有,A008
 }

+ 1 - 0
impl/thirdparty_impl/center.go

@@ -49,6 +49,7 @@ var ThirdpartyFuncMap = map[string]ThirdpartyFunc{
 	dutils.ZRVEHICLEINFO: {zr.VehicleInfoNationalLocal, zr.VehicleInfoNational, true, false,"plateNumber"},
 	dutils.ZRVEHICLEVIN: {zr.VehicleVinNationalLocal, zr.VehicleVinNational, true, false,"vinOrPlateNumber"},
 	dutils.ZRVEHICLEFIVE: {zr.VehicleFiveNationalLocal, zr.VehicleFiveNational, true, false,"vinOrPlateNumber"},
+	dutils.ZRVININFO: {zr.VinInfoNationalLocal, zr.VinInfoNational, true, false,"vin"},
 
 	//dutils.DYXW: {dybd.TwoElementVerifyLocal, dybd.TwoElementVerify, true, false,"xwzsbh"},
 

+ 2 - 2
impl/thirdparty_impl/zr/two_element_verify_national.go

@@ -83,8 +83,8 @@ func TwoElementVerifyNationalLocal(req *apis.ThirdpartRequest, respMap map[strin
 }
 
 func TwoElementVerifyNational(req *apis.ThirdpartRequest, respMap map[string]interface{})  error {
-	plateNo := req.Params["plateNum"]
-	name := req.Params["name"]
+	plateNo := gutils.GetInterfaceString(req.Params,"plateNum")
+	name := gutils.GetInterfaceString(req.Params,"name")
 	/*plateType := req.Params["plateColor"]
 	color, exist :=  utils.ConvertPlateType(plateType)
 	if !exist{

+ 1 - 1
impl/thirdparty_impl/zr/vehicle_five.go

@@ -53,7 +53,7 @@ func  VehicleFiveNationalLocal(req *apis.ThirdpartRequest, respMap map[string]in
 }
 
 func VehicleFiveNational(req *apis.ThirdpartRequest, respMap map[string]interface{})  error {
-	plateNo := req.Params["vinOrPlateNumber"]
+	plateNo :=  gutils.GetInterfaceString(req.Params,"vinOrPlateNumber")
 	if plateNo == ""  {
 		return errors.ArgsError
 	}

+ 1 - 1
impl/thirdparty_impl/zr/vehicle_info.go

@@ -84,7 +84,7 @@ func  VehicleInfoNationalLocal(req *apis.ThirdpartRequest, respMap map[string]in
 }
 
 func VehicleInfoNational(req *apis.ThirdpartRequest, respMap map[string]interface{})  error {
-	plateNo := req.Params["plateNumber"]
+	plateNo := gutils.GetInterfaceString(req.Params,"plateNumber")
 	if plateNo == ""  {
 		return errors.ArgsError
 	}

+ 1 - 1
impl/thirdparty_impl/zr/vehicle_vin.go

@@ -51,7 +51,7 @@ func  VehicleVinNationalLocal(req *apis.ThirdpartRequest, respMap map[string]int
 }
 
 func VehicleVinNational(req *apis.ThirdpartRequest, respMap map[string]interface{})  error {
-	plateNo := req.Params["vinOrPlateNumber"]
+	plateNo := gutils.GetInterfaceString(req.Params,"vinOrPlateNumber")
 	if plateNo == ""  {
 		return errors.ArgsError
 	}

+ 124 - 0
impl/thirdparty_impl/zr/vin_info.go

@@ -0,0 +1,124 @@
+// Copyright 2019 autocareai.com. All rights reserved.
+// Use of this source code is governed by autocareai.com.
+
+package zr
+
+import (
+	"gd_vehicle/apis"
+	"gd_vehicle/common.in/utils"
+	"gd_vehicle/errors"
+	"gd_vehicle/thirdparty"
+	dutils "gd_vehicle/utils"
+	"go.uber.org/zap"
+	gutils "gd_vehicle/common.in/utils"
+	"github.com/tidwall/gjson"
+)
+
+
+
+func getZrVinInfoKey(req *apis.ThirdpartRequest) string {
+	key := req.ProviderApiCode + ":" +  gutils.GetInterfaceString(req.Params,"vin")
+	return key
+}
+
+func paramZrVinInfoData(rdata string, respMap map[string]interface{}) {
+	arr := gjson.Parse(rdata).Array()
+	list := []apis.VehicleNew{}
+	for _,v := range arr{
+		tmp := apis.VehicleNew{}
+		tmp.RatedPower = v.Get("power").String()
+		tmp.Long = v.Get("length").String()
+		tmp.EngineType = v.Get("enginemodel").String()
+		tmp.BackWheelDistance = v.Get("reartrack").String()
+		tmp.BrandName = v.Get("brand").String()
+		tmp.GrossMass = v.Get("totalweight").String()
+		tmp.EmissionStandard = v.Get("emissionstandard").String()
+		tmp.Displacement = v.Get("displacement").String()
+		tmp.UnladenMass = v.Get("weight").String()
+		tmp.Wide = v.Get("wide").String()
+		tmp.High = v.Get("height").String()
+		tmp.FuelType = v.Get("fueltype").String()
+		list = append(list,tmp)
+	}
+	respMap["list"] = list
+
+}
+
+func paramZrVinInfoReturn(ret string) (reply string, err error) {
+	code := gjson.Get(ret, "code").String()
+	if code == "0" {
+		return gjson.Get(ret, "data").String() ,nil
+	} else if code == "10030"{
+		return "", errors.NoRecord
+	}else if code == "10003"{
+		return "",errors.UserTokenExpire
+	}
+	return "", errors.VendorError
+}
+
+func  VinInfoNationalLocal(req *apis.ThirdpartRequest, respMap map[string]interface{})  error {
+	rawData, err := dutils.GetRawDataByRedis(getZrVinInfoKey(req), int64(req.Req.ReuseTime))
+	if err == nil {
+		paramZrVinInfoData(rawData,respMap)
+	}
+
+	return  err
+}
+
+func VinInfoNational(req *apis.ThirdpartRequest, respMap map[string]interface{})  error {
+	vin := gutils.GetInterfaceString(req.Params,"vin")
+	if vin == ""  {
+		return errors.ArgsError
+	}
+
+	//req.LReq.Search = plateNo
+	token,err := getZrToken(req.ProviderInfo.ThirdpartHost,req.TryAgain,req.ProviderInfo.Timeout)
+	if err != nil{
+		l.Error("thridPart",
+			zap.String("call", "getZrToken"),
+			zap.String("args",utils.MarshalJsonString(req.Params)),
+			zap.String("error", err.Error()))
+		req.LReq.ResponseParams = err.Error()
+		dutils.SetAccessLogReqCodeMsgState(req.LReq, 1101, "gd_1101", err.Error(), false)
+		return errors.VendorError
+	}
+
+	ret, err := thirdparty.ZrHttpClient(req.ProviderInfo.ThirdpartHost+"/"+req.ProviderInfo.ThirdpartApiRouter, token,req.Params,req.ProviderInfo.Timeout)
+	if err != nil {
+		l.Error("func",
+			zap.String("call", "ZrHttpClient"),
+			zap.String("args", utils.MarshalJsonString(req.Params)),
+			zap.String("error", err.Error()))
+		req.LReq.ResponseParams = err.Error()
+		dutils.SetAccessLogReqCodeMsgState(req.LReq, 1101, "gd_1101", "三方错误,请求失败", false)
+		return  errors.VendorError
+	} else {
+		req.LReq.ResponseParams = string(ret)
+		replyData ,err := paramZrVinInfoReturn(string(ret))
+		message := gjson.GetBytes(ret, "msg").String()
+		code := gjson.GetBytes(ret, "code").String()
+		if err == nil {
+			paramZrVinInfoData(replyData,respMap)
+			dutils.StoreDataToRedis(getZrVinInfoKey(req), replyData)
+			dutils.SetAccessLogReqCodeMsgState(req.LReq, 0, code, message, true)
+		} else if err == errors.NoRecord {
+			dutils.StoreDataToRedis(getZrVinInfoKey(req), replyData)
+			dutils.SetAccessLogReqCodeMsgState(req.LReq, 1100, code, message, false)
+		}else if err == errors.UserTokenExpire{
+			if !req.TryAgain {
+				req.TryAgain = true
+				return VinInfoNational(req,respMap)
+			}
+			dutils.SetAccessLogReqCodeMsgState(req.LReq, 1101, code, message, false)
+		} else {
+			l.Error("func",
+				zap.String("call", "ZrHttpClient"),
+				zap.String("args", utils.MarshalJsonString(req.Params)),
+				zap.String("error", err.Error()))
+			//codeInt,_ := strconv.Atoi(code)
+			dutils.SetAccessLogReqCodeMsgState(req.LReq, 1101, code, message, false)
+		}
+		return  err
+	}
+}
+

+ 14 - 0
impl/vehicle/a003.go

@@ -0,0 +1,14 @@
+// Copyright 2019 getensh.com. All rights reserved.
+// Use of this source code is governed by getensh.com.
+
+package vehicle
+
+import (
+	"context"
+	"gd_vehicle/apis"
+)
+
+// vin查车型号
+func A003(ctx context.Context, req *apis.CommonReq, reply *apis.CommonReply) error {
+	return group(ctx,req,reply)
+}

+ 1 - 0
impl/vehicle/center.go

@@ -41,6 +41,7 @@ type FuncInterface struct {
 var interfaces = map[string]FuncInterface{
 	"1001": {A001,true,true },   // 车牌查车辆信息
 	"1002": {A002,true,true },   // vin查车辆信息
+	"1003": {A003,false,false },   // vin查车型
 	"2001": {V001,false,false }, // 二要素验证
 	"2002": {V002,true,true },   // 二要素验证,返回车档
 	"2003": {V003,false ,true},  // 二要素验证,不一致不返回车档

+ 15 - 9
impl/vehicle/group.go

@@ -6,7 +6,7 @@ package vehicle
 import (
 	"context"
 	"gd_vehicle/apis"
-	//gutils "gd_vehicle/common.in/utils"
+	gutils "gd_vehicle/common.in/utils"
 	"gd_vehicle/errors"
 	"gd_vehicle/impl/thirdparty_impl"
 	"gd_vehicle/utils"
@@ -276,7 +276,8 @@ func vehicleInfoByVinGroup(ctx context.Context, req *apis.CommonReq, reply *apis
 			if err != nil {
 				continue
 			}
-			plateNo := respData["plate_no"]
+
+			plateNo := gutils.GetInterfaceString(respData,"plate_no")
 			if  plateNo == ""{
 				continue
 			}
@@ -284,7 +285,7 @@ func vehicleInfoByVinGroup(ctx context.Context, req *apis.CommonReq, reply *apis
 
 			_, err := thirdparty_impl.CheckProviderApiIsAvaliable(utils.LOCALENGINENO, tReq.ProviderMap, rangeNo)
 			if err == nil {
-				engineNo := respData["engine_no"]
+				engineNo := gutils.GetInterfaceString(respData,"engine_no")
 				if engineNo != ""{
 					return nil
 				}
@@ -301,10 +302,18 @@ func vehicleInfoByVinGroup(ctx context.Context, req *apis.CommonReq, reply *apis
 			if err != nil {
 				continue
 			}
-			plateNo := respData["plate_no"]
+			plateNo := gutils.GetInterfaceString(respData,"plate_no")
 			if plateNo != ""{
 				return nil
 			}
+		case utils.ZRVININFO:
+			tReq.Params = map[string]interface{}{
+				"vin":   vin,
+			}
+			err = thirdparty_impl.CallThirdparty(tReq,respData)
+			if err != nil {
+				continue
+			}
 		default:
 			continue
 		}
@@ -313,13 +322,10 @@ func vehicleInfoByVinGroup(ctx context.Context, req *apis.CommonReq, reply *apis
 }
 
 func getIsMatch(respData map[string]interface{}) string {
-	if v, ok := respData["is_match"]; ok {
-		if _, ok = v.(string); ok && v.(string) != "" {
-			return v.(string)
-		}
-	}
+	return gutils.GetInterfaceString(respData,"is_match")
 	return "0"
 }
+
 func group(ctx context.Context, req *apis.CommonReq, reply *apis.CommonReply) error {
 	reqData := req.Data.(map[string]interface{})
 	/*MerchantProviderLimitInfoList, err := utils.GetProviderInfo(req.MerchantApiInfo.MerchantChildApiId, req.BaseApiId)

+ 1 - 0
utils/provider_api_code.go

@@ -22,5 +22,6 @@ const (
 	ZRTWOELEMENTVERIFYNATIONAL = "103-002"
 	ZRVEHICLEVIN        = "103-003"
 	ZRVEHICLEFIVE         = "103-004"
+	ZRVININFO        = "103-005"
 	DYXW                       = "104-001"
 )