|
@@ -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
|
|
|
}
|