jaryhe 7 months ago
parent
commit
62aef2c40b
6 changed files with 96 additions and 61 deletions
  1. 4 1
      consts/common.go
  2. 13 14
      impl/analysis/ods4.go
  3. 62 32
      impl/analysis/ods8.go
  4. 14 11
      impl/handle/common.go
  5. 2 2
      model/ods4.go
  6. 1 1
      model/ods8.go

+ 4 - 1
consts/common.go

@@ -38,8 +38,11 @@ const (
 	ZJCVEHICLEOWNER              = "142-001"*/
 	DYIDCERTVERIFY               = "102-001"
 	CDBDTWOELEMENTVERIFY = "101-001"
-	ZRTWOELEMENTVERIFY = "103-001"
+	ZRVEHICLEINFO         = "103-001"
 	ZRTWOELEMENTVERIFYNATIONAL = "103-002"
+	ZRVEHICLEVIN        = "103-003"
+	ZRVEHICLEFIVE         = "103-004"
+	ZRVININFO        = "103-005"
 	DYXL                       = "104-002"
 	DYXW                       = "104-001"
 	DYXLALL                       = "104-003"

+ 13 - 14
impl/analysis/ods4.go

@@ -23,35 +23,34 @@ func ParasOds4(content string) (ret []map[string]string, err error) {
 	requestParam := requestParamsArray[0]
 
 	responseParams := data.Get("response_params").String()
-	plateNo := requestParam.Get("plateNo").String()
-	plateType := requestParam.Get("plateType").String()
-	owner := requestParam.Get("name").String()
+	plateNo := requestParam.Get("vinOrPlateNumber").String()
 
-	if plateNo == "" || owner == ""{
+	if plateNo == ""{
 		return nil, fmt.Errorf("数据异常")
 	}
 
 	dataMap := make(map[string]string)
 	dataMap["plate_no"] = plateNo
-	dataMap["plate_type"] = plateType
 
 	code := gjson.Get(responseParams, "code").String()
 	if code != "0"{
 		return nil , fmt.Errorf("数据异常,code不为0")
 	}
 
-	ownerVerifyResult := gjson.Get(responseParams, "data.msg").String()
-	if ownerVerifyResult != "OK"{
-		return nil , fmt.Errorf("数据异常,不是OK")
-	}
-	dataMap["owner"] = owner
+	rdata := gjson.Get(responseParams, "data").String()
+	dataMap["engine_type"] = gjson.Get(rdata, "fdjxh").String()
+	dataMap["engine_no"] = gjson.Get(rdata, "fdjh").String()
+	dataMap["model_no"] = gjson.Get(rdata, "clxh").String()
+	dataMap["vin"] = gjson.Get(rdata, "vin").String()
+	dataMap["initial_registration_date"] = gjson.Get(rdata, "registerDate").String()
+	dataMap["brand_name"] = gjson.Get(rdata, "brand").String()
 
 	ret = append(ret, dataMap)
 	return ret, nil
 
 }
 
-//    ZR 广东所有人验证
+//  ZR 车牌查车五项或者vin
 func HandleOnlineOds4(msg *apis.OdsMessage) (dataMapList []map[string]string, err error) {
 	dataMapList, err = ParasOds4(msg.Content)
 	if err != nil {
@@ -66,15 +65,15 @@ func HandleOnlineOds4(msg *apis.OdsMessage) (dataMapList []map[string]string, er
 	// 入本地库
 	ods4 := &model.Ods4{}
 	ods4.PlateNo = dataMapList[0]["plate_no"]
-	ods4.PlateType = dataMapList[0]["plate_type"]
-	ods4.Owner = dataMapList[0]["owner"]
+	//ods4.PlateType = dataMapList[0]["plate_type"]
+	//ods4.Owner = dataMapList[0]["owner"]
 	ods4.Content = msg.Content
 	err = ods4.Insert(clinit.DB())
 	if err != nil {
 		if !strings.Contains(err.Error(), "Duplicate") {
 			return nil, err
 		} else {
-			where := map[string]interface{}{"plate_no": ods4.PlateNo,"plate_type":ods4.PlateType,"owner":ods4.Owner}
+			where := map[string]interface{}{"plate_no": ods4.PlateNo}
 			oldOds4 := &model.Ods4{}
 			err = oldOds4.Query(clinit.DB(), where)
 			if err == nil {

+ 62 - 32
impl/analysis/ods8.go

@@ -1,4 +1,4 @@
-// Copyright 2019 autocareai.com. All rights reserved.
+// Copyright 208 autocareai.com. All rights reserved.
 // Use of this source code is governed by autocareai.com.
 
 package analysis
@@ -7,45 +7,81 @@ import (
 	"gadm-ods/apis"
 	"gadm-ods/common.in/clinit"
 	"gadm-ods/model"
-	dutils "gadm-ods/utils"
 	"fmt"
 	"github.com/tidwall/gjson"
 	"strings"
 )
 
-// SPY 首保日期查询(128-009)
 func ParasOds8(content string) (ret []map[string]string, err error) {
 	data := gjson.Parse(content)
+
 	requestParams := data.Get("request_params").String()
-	responseParams := data.Get("response_params").String()
-	cp := gjson.Get(requestParams, "queryByCp").String()
-	if cp == "" {
-		return nil, fmt.Errorf("数据异常,车牌姓名不匹配")
-	}
-	code := gjson.Get(responseParams, "respCode").String()
-	if code != "0" {
+	requestParamsArray := gjson.Parse(requestParams).Array()
+	if len(requestParamsArray) < 1 {
 		return nil, fmt.Errorf("数据异常,没有数据")
 	}
+	requestParam := requestParamsArray[0]
+
+	responseParams := data.Get("response_params").String()
+	plateNo := requestParam.Get("plateNumber").String()
+
+	if plateNo == ""{
+		return nil, fmt.Errorf("数据异常")
+	}
 
 	dataMap := make(map[string]string)
-	dataMap["cp"] = cp
-	if dutils.IsPlate(cp) {
-		dataMap["plate_no"] = cp
-	} else {
-		dataMap["vin"] = cp
+	dataMap["plate_no"] = plateNo
+
+	code := gjson.Get(responseParams, "code").String()
+	if code != "0"{
+		return nil , fmt.Errorf("数据异常,code不为0")
 	}
 
-	respData := gjson.Get(responseParams, "data").String()
-	dataMap["city"] = gjson.Get(respData, "city").String()
-	dataMap["district"] = gjson.Get(respData, "district").String()
-	dataMap["province"] = gjson.Get(respData, "province").String()
-	dataMap["last_compulsory_insurance_date"] = gjson.Get(respData, "insuranceMonth").String()
-	dataMap["insurance_first_date"] = gjson.Get(respData, "registerDate").String()
-	dataMap["use_property_detail"] = gjson.Get(respData, "usage").String()
+	rdata := gjson.Get(responseParams, "data").String()
+	dataMap["vehicle_type_detail"] = gjson.Get(rdata, "cllb").String()  //"中型车"
+	dataMap["vehicle_type"] = ""
+	dataMap["engine_type"] = gjson.Get(rdata, "fdjxh").String()
+	dataMap["rated_power"] = gjson.Get(rdata, "gl").String()
+	dataMap["back_wheel_distance"] = gjson.Get(rdata, "hlj").String()
+	dataMap["front_wheel_distance"] = gjson.Get(rdata, "qlj").String()
+	dataMap["unladen_mass"] = gjson.Get(rdata, "zbzl").String()
+	dataMap["use_property_detail"] = gjson.Get(rdata, "usage").String()
+	dataMap["use_property"] = ""
+
+	dataMap["gross_mass"] = gjson.Get(rdata, "zzl").String()
+	dataMap["traction_mass"] = gjson.Get(rdata, "edqyzzl").String()
+	dataMap["long"] = gjson.Get(rdata, "wkc").String()
+	dataMap["wheel_base"] = gjson.Get(rdata, "zj").String()
+
+	dataMap["high"] = gjson.Get(rdata, "wkg").String()
+	dataMap["engine_no"] = gjson.Get(rdata, "fdjh").String()
+
+	dataMap["approved_load"] = gjson.Get(rdata, "edzzl").String()
+	//dataMap["state"] = gjson.Get(rdata, "clzl").String()
+	dataMap["wide"] = gjson.Get(rdata, "wkk").String()
+	dataMap["model_no"] = gjson.Get(rdata, "clxh").String()
+	dataMap["fuel_type_detail"] = gjson.Get(rdata, "rlzl").String()
+	dataMap["fuel_type"] = ""
+	dataMap["axle_number"] = gjson.Get(rdata, "zs").String()
+	dataMap["vin"] = gjson.Get(rdata, "vin").String()
+
+
+	dataMap["emission_standard"] = gjson.Get(rdata, "pfbz").String()
+	dataMap["displacement_l"] = gjson.Get(rdata, "pl").String()
+	dataMap["displacement"] = ""
+	dataMap["brand_name"] = gjson.Get(rdata, "brand").String()
+	dataMap["initial_registration_date"] = gjson.Get(rdata, "registerDate").String()
+	dataMap["approved_number"] = gjson.Get(rdata, "edzk").String()
+	dataMap["vehicle_body_color_detail"] = gjson.Get(rdata, "csys").String()
+	dataMap["vehicle_body_color"] = ""
+
+
 	ret = append(ret, dataMap)
 	return ret, nil
+
 }
 
+//  ZR 车牌查车辆信息
 func HandleOnlineOds8(msg *apis.OdsMessage) (dataMapList []map[string]string, err error) {
 	dataMapList, err = ParasOds8(msg.Content)
 	if err != nil {
@@ -59,14 +95,16 @@ func HandleOnlineOds8(msg *apis.OdsMessage) (dataMapList []map[string]string, er
 
 	// 入本地库
 	ods8 := &model.Ods8{}
-	ods8.Cp = dataMapList[0]["cp"]
+	ods8.PlateNo = dataMapList[0]["plate_no"]
+	//ods8.PlateType = dataMapList[0]["plate_type"]
+	//ods8.Owner = dataMapList[0]["owner"]
 	ods8.Content = msg.Content
 	err = ods8.Insert(clinit.DB())
 	if err != nil {
 		if !strings.Contains(err.Error(), "Duplicate") {
 			return nil, err
 		} else {
-			where := map[string]interface{}{"cp": ods8.Cp}
+			where := map[string]interface{}{"plate_no": ods8.PlateNo}
 			oldOds8 := &model.Ods8{}
 			err = oldOds8.Query(clinit.DB(), where)
 			if err == nil {
@@ -78,13 +116,5 @@ func HandleOnlineOds8(msg *apis.OdsMessage) (dataMapList []map[string]string, er
 			ods8.UpdateWhere(clinit.DB(), where)
 		}
 	}
-
-	for _, dataMap := range dataMapList {
-		delete(dataMap, "cp")
-		//dwsMsg := dutils.NewDwsMessage(msg)
-		//dwsMsg.Content = utils.MarshalJsonString(dataMap)
-		//ret = append(ret, dwsMsg)
-	}
-
 	return dataMapList, nil
 }

+ 14 - 11
impl/handle/common.go

@@ -30,13 +30,14 @@ var OdsOnlineTaskMap = map[string]ProviderLogTask{
 	consts.SOURCEODS11: {analysis.HandleOnlineOds11, analysis.ParasOds11},
 	consts.SOURCEODS12: {analysis.HandleOnlineOds12, analysis.ParasOds12},
 	consts.SOURCEODS13: {analysis.HandleOnlineOds13, analysis.ParasOds13},*/
-	consts.SOURCEODS1: {analysis.HandleOnlineOds1, analysis.ParasOds1},
-	consts.SOURCEODS2:  {analysis.HandleOnlineOds2, analysis.ParasOds2},
+	//consts.SOURCEODS1: {analysis.HandleOnlineOds1, analysis.ParasOds1},
+	//consts.SOURCEODS2:  {analysis.HandleOnlineOds2, analysis.ParasOds2},
 	consts.SOURCEODS3:  {analysis.HandleOnlineOds3, analysis.ParasOds3},
 	consts.SOURCEODS4:  {analysis.HandleOnlineOds4, analysis.ParasOds4},
-	consts.SOURCEODS5:  {analysis.HandleOnlineOds5, analysis.ParasOds5},
-	consts.SOURCEODS6:  {analysis.HandleOnlineOds6, analysis.ParasOds6},
-	consts.SOURCEODS7:  {analysis.HandleOnlineOds7, analysis.ParasOds7},
+	consts.SOURCEODS8:  {analysis.HandleOnlineOds8, analysis.ParasOds8},
+	//consts.SOURCEODS5:  {analysis.HandleOnlineOds5, analysis.ParasOds5},
+	//consts.SOURCEODS6:  {analysis.HandleOnlineOds6, analysis.ParasOds6},
+	//consts.SOURCEODS7:  {analysis.HandleOnlineOds7, analysis.ParasOds7},
 	/*consts.SOURCEODS16: {analysis.HandleOnlineOds16, analysis.ParasOds16},
 	consts.SOURCEODS17: {analysis.HandleOnlineOds17, analysis.ParasOds12},
 	consts.SOURCEODS18: {analysis.HandleOnlineOds18, analysis.ParasOds18},
@@ -62,13 +63,15 @@ var ProviderApiCodeToSoucreCodeMap = map[string]string{
 	consts.ZCRKTWOELEMENTVERIFY:     consts.SOURCEODS12,
 	consts.ZCRKTWOELEMENTVERIFY2:    consts.SOURCEODS17,
 	consts.ZJCVEHICLEOWNER:          consts.SOURCEODS13,*/
-	consts.DYIDCERTVERIFY:           consts.SOURCEODS1,
-	consts.CDBDTWOELEMENTVERIFY: consts.SOURCEODS2,
+	//consts.DYIDCERTVERIFY:           consts.SOURCEODS1,
+	//consts.CDBDTWOELEMENTVERIFY: consts.SOURCEODS2,
 	consts.ZRTWOELEMENTVERIFYNATIONAL:           consts.SOURCEODS3,
-	consts.ZRTWOELEMENTVERIFY: consts.SOURCEODS4,
-	consts.DYXW: consts.SOURCEODS5,
-	consts.DYXL: consts.SOURCEODS6,
-	consts.DYXLALL: consts.SOURCEODS7,
+	consts.ZRVEHICLEVIN: consts.SOURCEODS4,
+	consts.ZRVEHICLEFIVE: consts.SOURCEODS4,
+	consts.ZRVEHICLEINFO: consts.SOURCEODS8,
+	//consts.DYXW: consts.SOURCEODS5,
+	//consts.DYXL: consts.SOURCEODS6,
+	//consts.DYXLALL: consts.SOURCEODS7,
 	/*consts.ZCRKENGINENO:             consts.SOURCEODS18,
 	consts.ZCRKBYVIN: consts.SOURCEODS19,*/
 }

+ 2 - 2
model/ods4.go

@@ -13,8 +13,8 @@ import (
 type Ods4 struct {
 	ID        int64  `gorm:"primary_key"`
 	PlateNo       string `json:"plate_no"`
-	PlateType string `json:"plate_type"`
-	Owner string `json:"owner"`
+	//PlateType string `json:"plate_type"`
+	//Owner string `json:"owner"`
 	Content   string `json:"content"`
 	CreatedAt int64  `json:"created_at"`
 	UpdatedAt int64  `json:"updated_at"`

+ 1 - 1
model/ods8.go

@@ -13,7 +13,7 @@ import (
 //SPY 首保日期查询(128-009)
 type Ods8 struct {
 	ID        int64  `gorm:"primary_key"`
-	Cp        string `json:"cp"`
+	PlateNo        string `json:"plate_no"`
 	Content   string `json:"content"`
 	CreatedAt int64  `json:"created_at"`
 	UpdatedAt int64  `json:"updated_at"`