A06.go 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. package query
  2. import (
  3. "context"
  4. "gd_adm_data/apis"
  5. "gd_adm_data/errors"
  6. jsoniter "github.com/json-iterator/go"
  7. "git.getensh.com/common/gopkgsv2/database"
  8. )
  9. type a06Request struct {
  10. Vin string `json:"vin"`
  11. PlateNo string `json:"plate_no"`
  12. PlateType string `json:"plate_type"`
  13. }
  14. type a06Response struct {
  15. PlateNo string `json:"plate_no"`
  16. PlateNoPrex string `json:"plate_no_prex"`
  17. PlateType string `json:"plate_type"`
  18. Vin string `json:"vin"`
  19. SaleTime string `json:"sale_time"`
  20. Province string `json:"province"`
  21. City string `json:"city"`
  22. District string `json:"district"`
  23. UsePropertyDetail string `json:"use_property_detail"`
  24. BrandName string `json:"brand_name"`
  25. EngineNo string `json:"engine_no"`
  26. EngineType string `json:"engine_type"`
  27. Displacement string `json:"displacement"`
  28. DisplacementL string `json:"displacement_l"`
  29. ReleaseDate string `json:"release_date"`
  30. VehicleBodyColorDetail string `json:"vehicle_body_color_detail"`
  31. VehicleBodyColor string `json:"vehicle_body_color"`
  32. LastCompulsoryInsuranceDate string `json:"last_compulsory_insurance_date"`
  33. }
  34. // 车流向
  35. func A06(ctx context.Context, params string) (reply *apis.QueryResponse, err error) {
  36. reply = &apis.QueryResponse{}
  37. var req a06Request
  38. err = jsoniter.UnmarshalFromString(params, &req)
  39. if err != nil {
  40. return nil, errors.ParamsError
  41. }
  42. if req.Vin == "" {
  43. return nil, errors.ParamsError
  44. }
  45. a06Rsp := a06Response{}
  46. sql := `SELECT
  47. *
  48. FROM
  49. v_gadm_vehicle_destination
  50. WHERE
  51. vin = ?`
  52. err = database.DB().Raw(sql, req.Vin).Find(&a06Rsp).Error
  53. if err != nil {
  54. return nil, errors.DataNotExistError
  55. }
  56. sql1 := `SELECT insurance_date as last_compulsory_insurance_date FROM t_adm_dws8 WHERE vin = ? ORDER BY insurance_date desc LIMIT 1`
  57. err = database.DB().Raw(sql1, req.Vin).Find(&a06Rsp).Error
  58. a06Str, _ := jsoniter.MarshalToString(a06Rsp)
  59. a06Map := make(map[string]interface{})
  60. jsoniter.Unmarshal([]byte(a06Str), &a06Map)
  61. //formatData(a05Map)
  62. reply.Data, _ = jsoniter.MarshalToString(a06Map)
  63. return reply, nil
  64. }