Browse Source

update vehicle

jaryhe 1 year ago
parent
commit
bbf8546088

+ 15 - 0
apis/common.go

@@ -1,5 +1,7 @@
 package apis
 package apis
 
 
+import "context"
+
 type MerchantApiInfo struct {
 type MerchantApiInfo struct {
 	IsForceUpdate      bool   `json:"is_force_update"`
 	IsForceUpdate      bool   `json:"is_force_update"`
 	MerchantId         int64  `json:"merchant_id"`
 	MerchantId         int64  `json:"merchant_id"`
@@ -55,3 +57,16 @@ type CommonReply struct {
 	ErrCode int                 `json:"err_code"`
 	ErrCode int                 `json:"err_code"`
 	ErrMsg  string              `json:"err_msg"`
 	ErrMsg  string              `json:"err_msg"`
 }
 }
+
+type ThirdpartRequest struct {
+	Ctx             context.Context
+	Params          map[string]string
+	ProviderApiCode string
+	ProviderMap     map[string]MerchantProviderLimitInfo
+	RangeNo         int
+	Req             *CommonReq
+	Reply           *CommonReply
+	// center中填充
+	LReq         *ThirdpartLogWrite
+	ProviderInfo MerchantProviderLimitInfo
+}

+ 11 - 31
impl/thirdparty_impl/adm/a01.go

@@ -1,42 +1,22 @@
 package adm
 package adm
 
 
 import (
 import (
-	"context"
 	"gd_vehicle/apis"
 	"gd_vehicle/apis"
 	"gd_vehicle/consts"
 	"gd_vehicle/consts"
-	"gd_vehicle/errors"
-	dutils "gd_vehicle/utils"
-	"strconv"
 
 
 	"github.com/tidwall/gjson"
 	"github.com/tidwall/gjson"
 )
 )
 
 
-func A01(ctx context.Context, plateNo, plateType string, lReqs *[]apis.ThirdpartLogWrite, providerMap map[string]apis.MerchantProviderLimitInfo, rangeNo int) (vin string, err error) {
-	// ADM-A01
-	if CheckProviderApiIsAvaliable(dutils.ADMA01, providerMap, rangeNo) == nil {
-		str, err := (&Adm{
-			Ctx: ctx,
-			Params: map[string]string{
-				"plate_no":   plateNo,
-				"plate_type": plateType,
-			},
-			Code:     consts.A01,
-			LReqs:    lReqs,
-			Provider: providerMap[dutils.ADMA01+strconv.Itoa(rangeNo)],
-		}).Request()
-
-		if err != nil {
-			return vin, err
-		}
-
-		dataObj := gjson.Parse(str).Get("list").Array()
-		for _, v := range dataObj {
-			vin = v.Get("vin").String()
-			break
-		}
-	} else {
-		return vin, errors.ProviderUnavailable
+func A01(req *apis.ThirdpartRequest) (reply interface{}, err error) {
+	req.ProviderInfo.ThirdpartApiRouter = consts.A01
+	str, err := AdmRequest(req)
+	if err != nil {
+		return reply, err
 	}
 	}
-
-	return
+	dataObj := gjson.Parse(str).Get("list").Array()
+	for _, v := range dataObj {
+		reply = v.Get("vin").String()
+		break
+	}
+	return reply, nil
 }
 }

+ 22 - 5
impl/thirdparty_impl/adm/a02.go

@@ -1,16 +1,12 @@
 package adm
 package adm
 
 
 import (
 import (
-	"context"
 	"gd_vehicle/apis"
 	"gd_vehicle/apis"
-	"gd_vehicle/common.in/utils"
 	"gd_vehicle/consts"
 	"gd_vehicle/consts"
 	"gd_vehicle/errors"
 	"gd_vehicle/errors"
-	dutils "gd_vehicle/utils"
-	"strconv"
 )
 )
 
 
-func A02(ctx context.Context, vin, plateType string, reply map[string]string, lReqs *[]apis.ThirdpartLogWrite, providerMap map[string]apis.MerchantProviderLimitInfo, rangeNo int) error {
+/*func A02(ctx context.Context, vin, plateType string, reply map[string]string, lReqs *[]apis.ThirdpartLogWrite, providerMap map[string]apis.MerchantProviderLimitInfo, rangeNo int) error {
 	if CheckProviderApiIsAvaliable(dutils.ADMA02, providerMap, rangeNo) == nil {
 	if CheckProviderApiIsAvaliable(dutils.ADMA02, providerMap, rangeNo) == nil {
 		str, err := (&Adm{
 		str, err := (&Adm{
 			Ctx: ctx,
 			Ctx: ctx,
@@ -33,4 +29,25 @@ func A02(ctx context.Context, vin, plateType string, reply map[string]string, lR
 	}
 	}
 
 
 	return nil
 	return nil
+}*/
+
+func A02(req *apis.ThirdpartRequest) (reply interface{}, err error) {
+	req.ProviderInfo.ThirdpartApiRouter = consts.A02
+	str, err := AdmRequest(req)
+	if err != nil {
+		return nil, err
+	}
+
+	if err != nil {
+		return nil, err
+	}
+
+	if str == "" {
+		return nil, errors.VendorError
+	}
+	//respData := make(map[string]string)
+	//utils.Convertion(respData, str)
+
+	return str, nil
+
 }
 }

+ 14 - 27
impl/thirdparty_impl/adm/a04.go

@@ -1,38 +1,25 @@
 package adm
 package adm
 
 
 import (
 import (
-	"context"
 	"gd_vehicle/apis"
 	"gd_vehicle/apis"
-	"gd_vehicle/common.in/utils"
 	"gd_vehicle/consts"
 	"gd_vehicle/consts"
 	"gd_vehicle/errors"
 	"gd_vehicle/errors"
-	dutils "gd_vehicle/utils"
-	"strconv"
 )
 )
 
 
-// reply 必须是指针
-func A04(ctx context.Context, plateNo, plateType, vin string, reply map[string]string, lReqs *[]apis.ThirdpartLogWrite, providerMap map[string]apis.MerchantProviderLimitInfo, rangeNo int) error {
-	// ADM-A04
-	if CheckProviderApiIsAvaliable(dutils.ADMA04, providerMap, rangeNo) == nil {
-		str, err := (&Adm{
-			Ctx: ctx,
-			Params: map[string]string{
-				"plate_no":   plateNo,
-				"plate_type": plateType,
-			},
-			Code:     consts.A04,
-			LReqs:    lReqs,
-			Provider: providerMap[dutils.ADMA04+strconv.Itoa(rangeNo)],
-		}).Request()
-
-		if err != nil {
-			return err
-		}
-
-		utils.Convertion(reply, str)
-	} else {
-		return errors.ProviderUnavailable
+func A04(req *apis.ThirdpartRequest) (reply interface{}, err error) {
+	req.ProviderInfo.ThirdpartApiRouter = consts.A04
+	str, err := AdmRequest(req)
+	if err != nil {
+		return nil, err
+	}
+	if err != nil {
+		return nil, err
 	}
 	}
 
 
-	return nil
+	if str == "" {
+		return nil, errors.VendorError
+	}
+	//respData := make(map[string]string)
+	//utils.Convertion(respData, str)
+	return str, nil
 }
 }

+ 19 - 4
impl/thirdparty_impl/adm/a05.go

@@ -1,15 +1,12 @@
 package adm
 package adm
 
 
 import (
 import (
-	"context"
 	"gd_vehicle/apis"
 	"gd_vehicle/apis"
-	"gd_vehicle/common.in/utils"
 	"gd_vehicle/consts"
 	"gd_vehicle/consts"
 	"gd_vehicle/errors"
 	"gd_vehicle/errors"
-	dutils "gd_vehicle/utils"
-	"strconv"
 )
 )
 
 
+/*
 func A05(ctx context.Context, vin string, reply map[string]string, lReqs *[]apis.ThirdpartLogWrite, providerMap map[string]apis.MerchantProviderLimitInfo, rangeNo int) error {
 func A05(ctx context.Context, vin string, reply map[string]string, lReqs *[]apis.ThirdpartLogWrite, providerMap map[string]apis.MerchantProviderLimitInfo, rangeNo int) error {
 	if CheckProviderApiIsAvaliable(dutils.ADMA05, providerMap, rangeNo) == nil {
 	if CheckProviderApiIsAvaliable(dutils.ADMA05, providerMap, rangeNo) == nil {
 		str, err := (&Adm{
 		str, err := (&Adm{
@@ -32,4 +29,22 @@ func A05(ctx context.Context, vin string, reply map[string]string, lReqs *[]apis
 	}
 	}
 
 
 	return nil
 	return nil
+}*/
+
+func A05(req *apis.ThirdpartRequest) (reply interface{}, err error) {
+	req.ProviderInfo.ThirdpartApiRouter = consts.A05
+	str, err := AdmRequest(req)
+	if err != nil {
+		return nil, err
+	}
+	if err != nil {
+		return nil, err
+	}
+
+	if str == "" {
+		return nil, errors.VendorError
+	}
+	//respData := make(map[string]string)
+	//utils.Convertion(respData, str)
+	return str, nil
 }
 }

+ 19 - 5
impl/thirdparty_impl/adm/is01.go

@@ -1,16 +1,12 @@
 package adm
 package adm
 
 
 import (
 import (
-	"context"
 	"gd_vehicle/apis"
 	"gd_vehicle/apis"
-	"gd_vehicle/common.in/utils"
 	"gd_vehicle/consts"
 	"gd_vehicle/consts"
 	"gd_vehicle/errors"
 	"gd_vehicle/errors"
-	"strconv"
-
-	dutils "gd_vehicle/utils"
 )
 )
 
 
+/*
 func IS01(ctx context.Context, vin string, reply map[string]string, lReqs *[]apis.ThirdpartLogWrite, providerMap map[string]apis.MerchantProviderLimitInfo, rangeNo int) error {
 func IS01(ctx context.Context, vin string, reply map[string]string, lReqs *[]apis.ThirdpartLogWrite, providerMap map[string]apis.MerchantProviderLimitInfo, rangeNo int) error {
 	if CheckProviderApiIsAvaliable(dutils.ADMIS01, providerMap, rangeNo) == nil {
 	if CheckProviderApiIsAvaliable(dutils.ADMIS01, providerMap, rangeNo) == nil {
 		str, err := (&Adm{
 		str, err := (&Adm{
@@ -33,4 +29,22 @@ func IS01(ctx context.Context, vin string, reply map[string]string, lReqs *[]api
 	}
 	}
 
 
 	return nil
 	return nil
+}*/
+
+func IS01(req *apis.ThirdpartRequest) (reply interface{}, err error) {
+	req.ProviderInfo.ThirdpartApiRouter = consts.IS01
+	str, err := AdmRequest(req)
+	if err != nil {
+		return nil, err
+	}
+	if err != nil {
+		return nil, err
+	}
+
+	if str == "" {
+		return nil, errors.VendorError
+	}
+	//respData := make(map[string]string)
+	//utils.Convertion(respData, str)
+	return str, nil
 }
 }

+ 9 - 37
impl/thirdparty_impl/adm/request.go

@@ -8,37 +8,13 @@ import (
 	"gd_vehicle/errors"
 	"gd_vehicle/errors"
 	"gd_vehicle/rpc_apis"
 	"gd_vehicle/rpc_apis"
 	dutils "gd_vehicle/utils"
 	dutils "gd_vehicle/utils"
-	"strconv"
-	"time"
 
 
 	"gd_vehicle/common.in/jsonrpc2"
 	"gd_vehicle/common.in/jsonrpc2"
 	"gd_vehicle/common.in/utils"
 	"gd_vehicle/common.in/utils"
 	"go.uber.org/zap"
 	"go.uber.org/zap"
 )
 )
 
 
-func CheckProviderApiIsAvaliable(code string, providerMap map[string]apis.MerchantProviderLimitInfo, rangeNo int) error {
-	v, ok := providerMap[code+strconv.Itoa(rangeNo)]
-	if ok {
-		ret, _ := dutils.CheckProviderAvailable(v)
-		if ret == false {
-			return errors.ProviderUnavailable
-		}
-	} else {
-		return errors.ProviderApiNotFound
-
-	}
-	return nil
-}
-
-type Adm struct {
-	Ctx      context.Context
-	Params   map[string]string
-	Code     string
-	LReqs    *[]apis.ThirdpartLogWrite
-	Provider apis.MerchantProviderLimitInfo
-}
-
-func (a *Adm) Request() (reply string, err error) {
+func AdmRequest(a *apis.ThirdpartRequest) (reply string, err error) {
 	// 捕获各个task中的异常并返回给调用者
 	// 捕获各个task中的异常并返回给调用者
 	defer func() {
 	defer func() {
 		if r := recover(); r != nil {
 		if r := recover(); r != nil {
@@ -53,13 +29,9 @@ func (a *Adm) Request() (reply string, err error) {
 	}()
 	}()
 
 
 	req := apis.QueryRequest{}
 	req := apis.QueryRequest{}
-	req.Code = a.Code
+	req.Code = a.ProviderInfo.ThirdpartApiRouter
 	params, _ := json.Marshal(a.Params)
 	params, _ := json.Marshal(a.Params)
 	req.Params = string(params)
 	req.Params = string(params)
-	lReq := &apis.ThirdpartLogWrite{ProviderApiId: a.Provider.ProviderApiId, ProviderCode: a.Provider.ProviderApiCode}
-	startTime := uint64(time.Now().UnixNano())
-	defer dutils.AppendLog(a.LReqs, lReq, startTime)
-	lReq.RequestParams = req.Params
 	ret, err := rpc_apis.AdmData.Query(context.Background(), &req)
 	ret, err := rpc_apis.AdmData.Query(context.Background(), &req)
 	if err != nil {
 	if err != nil {
 		var e jsonrpc2.Error
 		var e jsonrpc2.Error
@@ -69,26 +41,26 @@ func (a *Adm) Request() (reply string, err error) {
 				zap.String("call", "Query"),
 				zap.String("call", "Query"),
 				zap.String("args", utils.MarshalJsonString(req)),
 				zap.String("args", utils.MarshalJsonString(req)),
 				zap.String("error", err.Error()))
 				zap.String("error", err.Error()))
-			lReq.ResponseParams = err.Error()
-			dutils.SetAccessLogReqCodeMsgState(lReq, 1101, "gd_1101", "三方错误,请求失败", false)
+			a.LReq.ResponseParams = err.Error()
+			dutils.SetAccessLogReqCodeMsgState(a.LReq, 1101, "gd_1101", "三方错误,请求失败", false)
 		} else {
 		} else {
 
 
-			lReq.ResponseParams = err.Error()
+			a.LReq.ResponseParams = err.Error()
 			if e.Code == 11004 {
 			if e.Code == 11004 {
-				dutils.SetAccessLogReqCodeMsgState(lReq, 1100, "gd_1100", "无数据", false)
+				dutils.SetAccessLogReqCodeMsgState(a.LReq, 1100, "gd_1100", "无数据", false)
 			} else {
 			} else {
 				l.Error("func",
 				l.Error("func",
 					zap.String("call", "Query"),
 					zap.String("call", "Query"),
 					zap.String("args", utils.MarshalJsonString(req)),
 					zap.String("args", utils.MarshalJsonString(req)),
 					zap.String("error", err.Error()))
 					zap.String("error", err.Error()))
-				dutils.SetAccessLogReqCodeMsgState(lReq, e.Code, "gd_1101", "三方错误,请求失败", false)
+				dutils.SetAccessLogReqCodeMsgState(a.LReq, e.Code, "gd_1101", "三方错误,请求失败", false)
 			}
 			}
 
 
 		}
 		}
 		return "", errors.VendorError
 		return "", errors.VendorError
 	}
 	}
 	reply = ret.Data
 	reply = ret.Data
-	lReq.ResponseParams = ret.Data
-	dutils.SetAccessLogReqCodeMsgState(lReq, 0, "0", "成功", true)
+	a.LReq.ResponseParams = ret.Data
+	dutils.SetAccessLogReqCodeMsgState(a.LReq, 0, "0", "成功", true)
 	return
 	return
 }
 }

+ 19 - 6
impl/thirdparty_impl/adm/u01.go

@@ -1,17 +1,12 @@
 package adm
 package adm
 
 
 import (
 import (
-	"context"
 	"gd_vehicle/apis"
 	"gd_vehicle/apis"
 	"gd_vehicle/consts"
 	"gd_vehicle/consts"
 	"gd_vehicle/errors"
 	"gd_vehicle/errors"
-	"strconv"
-
-	dutils "gd_vehicle/utils"
-
-	jsoniter "github.com/json-iterator/go"
 )
 )
 
 
+/*
 func U01(ctx context.Context, str string, LReqs *[]apis.ThirdpartLogWrite, providerMap map[string]apis.MerchantProviderLimitInfo, rangeNo int) (string, error) {
 func U01(ctx context.Context, str string, LReqs *[]apis.ThirdpartLogWrite, providerMap map[string]apis.MerchantProviderLimitInfo, rangeNo int) (string, error) {
 	if CheckProviderApiIsAvaliable(dutils.ADMU01, providerMap, rangeNo) == nil {
 	if CheckProviderApiIsAvaliable(dutils.ADMU01, providerMap, rangeNo) == nil {
 		params := make(map[string]string)
 		params := make(map[string]string)
@@ -32,4 +27,22 @@ func U01(ctx context.Context, str string, LReqs *[]apis.ThirdpartLogWrite, provi
 	} else {
 	} else {
 		return "", errors.ProviderUnavailable
 		return "", errors.ProviderUnavailable
 	}
 	}
+}*/
+
+func U01(req *apis.ThirdpartRequest) (reply interface{}, err error) {
+	req.ProviderInfo.ThirdpartApiRouter = consts.U01
+	str, err := AdmRequest(req)
+	if err != nil {
+		return nil, err
+	}
+	if err != nil {
+		return nil, err
+	}
+
+	if str == "" {
+		return nil, errors.VendorError
+	}
+	//respData := make(map[string]string)
+	//utils.Convertion(respData, str)
+	return str, nil
 }
 }

+ 21 - 3
impl/thirdparty_impl/adm/v01.go

@@ -1,16 +1,14 @@
 package adm
 package adm
 
 
 import (
 import (
-	"context"
 	"gd_vehicle/apis"
 	"gd_vehicle/apis"
 	"gd_vehicle/consts"
 	"gd_vehicle/consts"
 	"gd_vehicle/errors"
 	"gd_vehicle/errors"
-	dutils "gd_vehicle/utils"
-	"strconv"
 
 
 	"github.com/tidwall/gjson"
 	"github.com/tidwall/gjson"
 )
 )
 
 
+/*
 func V01(ctx context.Context, plateNo, plateType, owner string, lReqs *[]apis.ThirdpartLogWrite, providerMap map[string]apis.MerchantProviderLimitInfo, rangeNo int) (isMatch string, err error) {
 func V01(ctx context.Context, plateNo, plateType, owner string, lReqs *[]apis.ThirdpartLogWrite, providerMap map[string]apis.MerchantProviderLimitInfo, rangeNo int) (isMatch string, err error) {
 	if CheckProviderApiIsAvaliable(dutils.ADMV01, providerMap, rangeNo) == nil {
 	if CheckProviderApiIsAvaliable(dutils.ADMV01, providerMap, rangeNo) == nil {
 		str, err := (&Adm{
 		str, err := (&Adm{
@@ -34,4 +32,24 @@ func V01(ctx context.Context, plateNo, plateType, owner string, lReqs *[]apis.Th
 	}
 	}
 
 
 	return isMatch, err
 	return isMatch, err
+}*/
+
+func V01(req *apis.ThirdpartRequest) (reply interface{}, err error) {
+	req.ProviderInfo.ThirdpartApiRouter = consts.V01
+	str, err := AdmRequest(req)
+	if err != nil {
+		return nil, err
+	}
+	if err != nil {
+		return nil, err
+	}
+
+	if str == "" {
+		return nil, errors.VendorError
+	}
+
+	isMatch := gjson.Get(str, "is_match").String()
+	//respData := make(map[string]string)
+	//utils.Convertion(respData, str)
+	return isMatch, nil
 }
 }

+ 119 - 0
impl/thirdparty_impl/center.go

@@ -0,0 +1,119 @@
+// Copyright 2019 autocareai.com. All rights reserved.
+// Use of this source code is governed by autocareai.com.
+
+package thirdparty_impl
+
+import (
+	"encoding/json"
+	"gd_vehicle/impl/thirdparty_impl/adm"
+
+	//"fmt"
+	"gd_vehicle/apis"
+	"gd_vehicle/errors"
+	dutils "gd_vehicle/utils"
+	"strconv"
+	"time"
+
+	"github.com/afex/hystrix-go/hystrix"
+	//"gd_vehicle/common.in/jsonrpc2"
+	//"go.uber.org/zap"
+)
+
+type ThirdpartyFunc struct {
+	LocalFuc       func(req *apis.ThirdpartRequest) (reply interface{}, err error)
+	Function       func(req *apis.ThirdpartRequest) (reply interface{}, err error)
+	ExistLocalFunc bool
+	ReuseFlag      bool
+}
+
+var ThirdpartyFuncMap = map[string]ThirdpartyFunc{
+	dutils.ADMA01:  {nil, adm.A01, false, true},
+	dutils.ADMA02:  {nil, adm.A02, false, true},
+	dutils.ADMA04:  {nil, adm.A04, false, true},
+	dutils.ADMA05:  {nil, adm.A05, false, true},
+	dutils.ADMIS01: {nil, adm.IS01, false, true},
+	dutils.ADMU01:  {nil, adm.U01, false, true},
+	dutils.ADMV01:  {nil, adm.V01, false, true},
+}
+
+func CheckProviderApiIsAvaliable(code string, providerMap map[string]apis.MerchantProviderLimitInfo, rangeNo int) (apis.MerchantProviderLimitInfo, error) {
+	v, ok := providerMap[code+strconv.Itoa(rangeNo)]
+	if ok {
+		ret, _ := dutils.CheckProviderAvailable(v)
+		if ret == false {
+			return v, errors.ProviderUnavailable
+		}
+	} else {
+		return v, errors.ProviderApiNotFound
+
+	}
+	return v, nil
+}
+
+func CallThirdparty(req *apis.ThirdpartRequest) (reply interface{}, err error) {
+	// 捕获各个task中的异常并返回给调用者
+	/*defer func() {
+		if r := recover(); r != nil {
+			err = fmt.Errorf("%+v", r)
+			e := &jsonrpc2.Error{}
+			if er := json.Unmarshal([]byte(err.Error()), e); er != nil {
+				l.Error("err",
+					zap.String("system_err", err.Error()),
+					zap.Stack("stacktrace"))
+			}
+		}
+	}()*/
+
+	provider, err := CheckProviderApiIsAvaliable(req.ProviderApiCode, req.ProviderMap, req.RangeNo)
+	if err != nil {
+		return "", err
+	}
+	req.ProviderInfo = provider
+
+	if v, ok := ThirdpartyFuncMap[req.ProviderApiCode]; ok {
+		// 存在本地复用函数
+		if v.ExistLocalFunc {
+			reply, err = v.LocalFuc(req)
+			if err == nil {
+				return reply, err
+			}
+		}
+
+		params, _ := json.Marshal(req.Params)
+		req.LReq = &apis.ThirdpartLogWrite{ProviderApiId: provider.ProviderApiId}
+		// 标志设为true表示调用该数据源为复用
+		if v.ReuseFlag {
+			req.LReq.ProviderCode = provider.ProviderApiCode
+		}
+
+		req.LReq.RequestParams = string(params)
+		startTime := uint64(time.Now().UnixNano())
+		defer dutils.AppendLog(&req.Reply.LReq, req.LReq, startTime)
+		// 判断是否开启熔断
+		hystrixConf, ok := dutils.CheckProviderApiHystrix(req.ProviderApiCode)
+		if ok {
+			hystrixErr := hystrix.Do(req.ProviderApiCode, func() error {
+				reply, err = v.Function(req)
+				if err == errors.VendorError {
+					return err
+				}
+				return nil
+			}, nil)
+
+			if hystrixErr == hystrix.ErrCircuitOpen {
+				dutils.SetAccessLogReqCodeMsgState(req.LReq, 1101, "gd_1101", "接口熔断", false)
+			}
+
+			if hystrixErr != nil && err == nil {
+				err = errors.VendorError
+			}
+
+			go dutils.CheckHystrixStatus(hystrixConf, hystrixErr, req.LReq.ResponseParams)
+		} else {
+			reply, err = v.Function(req)
+		}
+		return reply, err
+	}
+
+	return
+}

+ 24 - 7
impl/vehicle/a001.go

@@ -8,8 +8,11 @@ import (
 	"gd_vehicle/apis"
 	"gd_vehicle/apis"
 	"gd_vehicle/consts"
 	"gd_vehicle/consts"
 	"gd_vehicle/errors"
 	"gd_vehicle/errors"
-	"gd_vehicle/impl/thirdparty_impl/adm"
+	"gd_vehicle/impl/thirdparty_impl"
 	"gd_vehicle/utils"
 	"gd_vehicle/utils"
+	dutils "gd_vehicle/utils"
+
+	gutils "gd_vehicle/common.in/utils"
 )
 )
 
 
 // 车牌查车辆信息
 // 车牌查车辆信息
@@ -26,13 +29,27 @@ func A001(ctx context.Context, req *apis.CommonReq, reply *apis.CommonReply) err
 	}
 	}
 
 
 	providerMap, _ := utils.GenProviderInfoMapNew(MerchantProviderLimitInfoList)
 	providerMap, _ := utils.GenProviderInfoMapNew(MerchantProviderLimitInfoList)
-	respData := make(map[string]string)
 	// TODO 定义返回字段
 	// TODO 定义返回字段
-	err = adm.A04(ctx, plateNo, plateType, "", respData, &reply.LReq, providerMap, consts.RANGEONE)
-	if err == nil {
-		reply.Data = respData
-		return nil
-	} else {
+
+	tReq := &apis.ThirdpartRequest{
+		Ctx: ctx,
+		Params: map[string]string{
+			"plate_no":   plateNo,
+			"plate_type": plateType,
+		},
+		ProviderApiCode: dutils.ADMA04,
+		ProviderMap:     providerMap,
+		RangeNo:         consts.RANGEONE,
+		Req:             req,
+		Reply:           reply,
+	}
+	ret, err := thirdparty_impl.CallThirdparty(tReq)
+	if err != nil {
 		return errors.NoRecord
 		return errors.NoRecord
 	}
 	}
+
+	respData := make(map[string]string)
+	gutils.Convertion(respData, ret.(string))
+	reply.Data = respData
+	return nil
 }
 }

+ 22 - 6
impl/vehicle/a002.go

@@ -8,8 +8,11 @@ import (
 	"gd_vehicle/apis"
 	"gd_vehicle/apis"
 	"gd_vehicle/consts"
 	"gd_vehicle/consts"
 	"gd_vehicle/errors"
 	"gd_vehicle/errors"
-	"gd_vehicle/impl/thirdparty_impl/adm"
+	"gd_vehicle/impl/thirdparty_impl"
 	"gd_vehicle/utils"
 	"gd_vehicle/utils"
+	dutils "gd_vehicle/utils"
+
+	gutils "gd_vehicle/common.in/utils"
 )
 )
 
 
 // vin查车辆信息
 // vin查车辆信息
@@ -22,13 +25,26 @@ func A002(ctx context.Context, req *apis.CommonReq, reply *apis.CommonReply) err
 	}
 	}
 
 
 	providerMap, _ := utils.GenProviderInfoMapNew(MerchantProviderLimitInfoList)
 	providerMap, _ := utils.GenProviderInfoMapNew(MerchantProviderLimitInfoList)
-	respData := make(map[string]string)
+
 	// TODO 定义返回字段
 	// TODO 定义返回字段
+	tReq := &apis.ThirdpartRequest{
+		Ctx: ctx,
+		Params: map[string]string{
+			"vin": vin,
+		},
+		ProviderApiCode: dutils.ADMA04,
+		ProviderMap:     providerMap,
+		RangeNo:         consts.RANGEONE,
+		Req:             req,
+		Reply:           reply,
+	}
 
 
-	err = adm.A04(ctx, "", "", vin, respData, &reply.LReq, providerMap, consts.RANGEONE)
-	if err == nil {
-		return nil
-	} else {
+	ret, err := thirdparty_impl.CallThirdparty(tReq)
+	if err != nil {
 		return errors.NoRecord
 		return errors.NoRecord
 	}
 	}
+	respData := make(map[string]string)
+	gutils.Convertion(respData, ret.(string))
+	reply.Data = respData
+	return nil
 }
 }

+ 26 - 8
impl/vehicle/center.go

@@ -11,19 +11,37 @@ import (
 	"gd_vehicle/apis"
 	"gd_vehicle/apis"
 )
 )
 
 
-func Query(ctx context.Context, req *apis.CommonReq, reply *apis.CommonReply) error {
-	interfaces := map[string]func(ctx context.Context, req *apis.CommonReq, reply *apis.CommonReply) error{
-		"1001":     A001,
-		"1002":     A002,
-		"2001":     V001,
-		"2002":     V002,
-		"TEST_API": TestApi,
+func IsReuse(reuse *bool, LReq *[]apis.ThirdpartLogWrite) {
+	if len(*LReq) > 0 {
+		for _, v := range *LReq {
+			if v.ProviderCode == "" {
+				*reuse = false
+				return
+			}
+		}
+		*reuse = true
+	} else {
+		*reuse = true
 	}
 	}
+}
+
+var interfaces = map[string]func(ctx context.Context, req *apis.CommonReq, reply *apis.CommonReply) error{
+	"1001":     A001,
+	"1002":     A002,
+	"2001":     V001,
+	"2002":     V002,
+	"TEST_API": TestApi,
+}
+
+func Query(ctx context.Context, req *apis.CommonReq, reply *apis.CommonReply) error {
+	defer func() {
+		IsReuse(&reply.IsReuse, &reply.LReq)
+	}()
 
 
 	if v, ok := interfaces[strings.ToUpper(req.Code)]; ok {
 	if v, ok := interfaces[strings.ToUpper(req.Code)]; ok {
 		err := v(ctx, req, reply)
 		err := v(ctx, req, reply)
 		if err == nil {
 		if err == nil {
-			// TODO 调用u01格式化
+			// TODO 调用F01格式化
 
 
 			return nil
 			return nil
 		}
 		}

+ 22 - 7
impl/vehicle/v001.go

@@ -8,8 +8,9 @@ import (
 	"gd_vehicle/apis"
 	"gd_vehicle/apis"
 	"gd_vehicle/consts"
 	"gd_vehicle/consts"
 	"gd_vehicle/errors"
 	"gd_vehicle/errors"
-	"gd_vehicle/impl/thirdparty_impl/adm"
+	"gd_vehicle/impl/thirdparty_impl"
 	"gd_vehicle/utils"
 	"gd_vehicle/utils"
+	dutils "gd_vehicle/utils"
 )
 )
 
 
 // 二要素验证
 // 二要素验证
@@ -24,12 +25,26 @@ func V001(ctx context.Context, req *apis.CommonReq, reply *apis.CommonReply) err
 	}
 	}
 
 
 	providerMap, _ := utils.GenProviderInfoMapNew(MerchantProviderLimitInfoList)
 	providerMap, _ := utils.GenProviderInfoMapNew(MerchantProviderLimitInfoList)
-	respData := make(map[string]string)
-	isMatch, err := adm.V01(ctx, plateNo, plateType, owner, &reply.LReq, providerMap, consts.RANGEONE)
-	if err == nil {
-		respData["is_match"] = isMatch
-		return nil
-	} else {
+
+	tReq := &apis.ThirdpartRequest{
+		Ctx: ctx,
+		Params: map[string]string{
+			"plate_no":   plateNo,
+			"plate_type": plateType,
+			"owner":      owner,
+		},
+		ProviderApiCode: dutils.ADMV01,
+		ProviderMap:     providerMap,
+		RangeNo:         consts.RANGEONE,
+		Req:             req,
+		Reply:           reply,
+	}
+	ret, err := thirdparty_impl.CallThirdparty(tReq)
+	if err != nil {
 		return errors.NoRecord
 		return errors.NoRecord
 	}
 	}
+	respData := make(map[string]string)
+	respData["is_match"] = ret.(string)
+	reply.Data = respData
+	return nil
 }
 }

+ 28 - 10
impl/vehicle/v002.go

@@ -8,8 +8,11 @@ import (
 	"gd_vehicle/apis"
 	"gd_vehicle/apis"
 	"gd_vehicle/consts"
 	"gd_vehicle/consts"
 	"gd_vehicle/errors"
 	"gd_vehicle/errors"
-	"gd_vehicle/impl/thirdparty_impl/adm"
+	"gd_vehicle/impl/thirdparty_impl"
 	"gd_vehicle/utils"
 	"gd_vehicle/utils"
+	dutils "gd_vehicle/utils"
+
+	gutils "gd_vehicle/common.in/utils"
 )
 )
 
 
 // 二要素验证,返回车档
 // 二要素验证,返回车档
@@ -24,19 +27,34 @@ func V002(ctx context.Context, req *apis.CommonReq, reply *apis.CommonReply) err
 	}
 	}
 
 
 	providerMap, _ := utils.GenProviderInfoMapNew(MerchantProviderLimitInfoList)
 	providerMap, _ := utils.GenProviderInfoMapNew(MerchantProviderLimitInfoList)
-	respData := make(map[string]string)
-	isMatch, err := adm.V01(ctx, plateNo, plateType, owner, &reply.LReq, providerMap, consts.RANGEONE)
-	if err == nil {
-		respData["is_match"] = isMatch
-	} else {
+	tReq := &apis.ThirdpartRequest{
+		Ctx: ctx,
+		Params: map[string]string{
+			"plate_no":   plateNo,
+			"plate_type": plateType,
+			"owner":      owner,
+		},
+		ProviderApiCode: dutils.ADMV01,
+		ProviderMap:     providerMap,
+		RangeNo:         consts.RANGEONE,
+		Req:             req,
+		Reply:           reply,
+	}
+	ret, err := thirdparty_impl.CallThirdparty(tReq)
+	if err != nil {
 		return errors.NoRecord
 		return errors.NoRecord
 	}
 	}
+	respData := make(map[string]string)
+	respData["is_match"] = ret.(string)
+
+	tReq.ProviderApiCode = dutils.ADMA04
 
 
-	err = adm.A04(ctx, plateNo, plateType, "", respData, &reply.LReq, providerMap, consts.RANGEONE)
-	if err == nil {
-		return nil
-	} else {
+	ret, err = thirdparty_impl.CallThirdparty(tReq)
+	if err != nil {
 		return errors.NoRecord
 		return errors.NoRecord
 	}
 	}
 
 
+	gutils.Convertion(respData, ret.(string))
+	reply.Data = respData
+	return nil
 }
 }