12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- package query
- import (
- "context"
- "gd_adm_data/apis"
- "gd_adm_data/errors"
- jsoniter "github.com/json-iterator/go"
- "git.getensh.com/common/gopkgsv2/database"
- )
- type a06Request struct {
- Vin string `json:"vin"`
- PlateNo string `json:"plate_no"`
- PlateType string `json:"plate_type"`
- }
- type a06Response struct {
- PlateNo string `json:"plate_no"`
- PlateNoPrex string `json:"plate_no_prex"`
- PlateType string `json:"plate_type"`
- Vin string `json:"vin"`
- SaleTime string `json:"sale_time"`
- Province string `json:"province"`
- City string `json:"city"`
- District string `json:"district"`
- UsePropertyDetail string `json:"use_property_detail"`
- BrandName string `json:"brand_name"`
- EngineNo string `json:"engine_no"`
- EngineType string `json:"engine_type"`
- Displacement string `json:"displacement"`
- DisplacementL string `json:"displacement_l"`
- ReleaseDate string `json:"release_date"`
- VehicleBodyColorDetail string `json:"vehicle_body_color_detail"`
- VehicleBodyColor string `json:"vehicle_body_color"`
- LastCompulsoryInsuranceDate string `json:"last_compulsory_insurance_date"`
- }
- // 车流向
- func A06(ctx context.Context, params string) (reply *apis.QueryResponse, err error) {
- reply = &apis.QueryResponse{}
- var req a06Request
- err = jsoniter.UnmarshalFromString(params, &req)
- if err != nil {
- return nil, errors.ParamsError
- }
- if req.Vin == "" {
- return nil, errors.ParamsError
- }
- a06Rsp := a06Response{}
- sql := `SELECT
- *
- FROM
- v_gadm_vehicle_destination
- WHERE
- vin = ?`
- err = database.DB().Raw(sql, req.Vin).Find(&a06Rsp).Error
- if err != nil {
- return nil, errors.DataNotExistError
- }
- sql1 := `SELECT insurance_date as last_compulsory_insurance_date FROM t_adm_dws8 WHERE vin = ? ORDER BY insurance_date desc LIMIT 1`
- err = database.DB().Raw(sql1, req.Vin).Find(&a06Rsp).Error
- a06Str, _ := jsoniter.MarshalToString(a06Rsp)
- a06Map := make(map[string]interface{})
- jsoniter.Unmarshal([]byte(a06Str), &a06Map)
- //formatData(a05Map)
- reply.Data, _ = jsoniter.MarshalToString(a06Map)
- return reply, nil
- }
|