package query import ( "context" "gd_adm_data/apis" "gd_adm_data/errors" "github.com/json-iterator/go" "git.getensh.com/common/gopkgsv2/database" ) type a04Request struct { PlateNo string `json:"plate_no"` PlateType string `json:"plate_type"` Vin string `json:"vin"` } type a04Response struct { PlateNo string `json:"plate_no"` PlateType string `json:"plate_type"` Owner string `json:"owner"` Vin string `json:"vin"` EngineType string `json:"engine_type"` EngineNo string `json:"engine_no"` ModelNo string `json:"model_no"` BrandName string `json:"brand_name"` InitialRegistrationDate string `json:"initial_registration_date"` InsuranceFirstDate string `json:"insurance_first_date"` VehicleType string `json:"vehicle_type"` UseProperty string `json:"use_property"` UsePropertyDetail string `json:"use_property_detail"` VehicleBodyColor string `json:"vehicle_body_color"` VehicleBodyColorDetail string `json:"vehicle_body_color_detail"` ApprovedLoad string `json:"approved_load"` ApprovedNumber string `json:"approved_number"` AxleWeight string `json:"axle_weight"` AxleNumber string `json:"axle_number"` Displacement string `json:"displacement"` DisplacementL string `json:"displacement_l"` FrontWheelDistance string `json:"front_wheel_distance"` BackWheelDistance string `json:"back_wheel_distance"` FuelType string `json:"fuel_type"` FuelTypeDetail string `json:"fuel_type_detail"` GrossMass string `json:"gross_mass"` RatedPower string `json:"rated_power"` ReleaseDate string `json:"release_date"` UnladenMass string `json:"unladen_mass"` EmissionStandard string `json:"emission_standard"` Long string `json:"long"` Wide string `json:"wide"` High string `json:"high"` OilWear string `json:"oil_wear"` TractionMass string `json:"traction_mass"` TyreSize string `json:"tyre_size"` WheelBase string `json:"wheel_base"` CompulsoryScrapTo string `json:"compulsory_scrap_to" description:"强制报废日期"` InspectionResultEffectiveTo string `json:"inspection_result_effective_to" description:"检验有效期止"` TyreNumber string `json:"tyre_number"` VehicleTypeDetail string `json:"vehicle_type_detail"` } // 车牌查车信息 func A04(ctx context.Context, params string) (reply *apis.QueryResponse, err error) { reply = &apis.QueryResponse{} var req a04Request err = jsoniter.UnmarshalFromString(params, &req) if err != nil { return nil, errors.ParamsError } if (req.PlateNo == "" || req.PlateType == "") && req.Vin == "" { return nil, errors.ParamsError } a04Rsp := a04Response{} if req.PlateNo != "" && req.PlateType != "" { sql := `SELECT * FROM v_gadm_vehicle WHERE plate_no = ? and plate_type = ? LIMIT 1` err = database.DB().Raw(sql, req.PlateNo, req.PlateType).Find(&a04Rsp).Error } else { sql := `SELECT * FROM v_gadm_vin WHERE vin = ? LIMIT 1` err = database.DB().Raw(sql, req.Vin).Find(&a04Rsp).Error } //fmt.Println("err:", err) if err != nil { return nil, errors.DataNotExistError } if req.PlateType == "01" || req.PlateType == "02" { // 校验本地数据车牌对应关系是否正确 a04PlateType := calcPlateType(a04Rsp.Long, a04Rsp.ApprovedNumber, a04Rsp.GrossMass) if a04PlateType != "" && a04PlateType != req.PlateType { return nil, errors.DataNotExistError } } a04Str, _ := jsoniter.MarshalToString(a04Rsp) a04Map := make(map[string]interface{}) jsoniter.Unmarshal([]byte(a04Str), &a04Map) reply.Data, _ = jsoniter.MarshalToString(a04Map) return reply, nil }