A03.go 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. "gorm.io/gorm"
  8. "git.getensh.com/common/gopkgsv2/database"
  9. )
  10. type a03Request struct {
  11. ModelNo string `json:"model_no"`
  12. }
  13. type a03Response struct {
  14. ModelNo string `json:"model_no"`
  15. VehicleBatch string `json:"vehicle_batch"`
  16. BrandName string `json:"brand_name"`
  17. VehicleTypeDetail string `json:"vehicle_type_detail"`
  18. ApprovedLoad string `json:"approved_load"`
  19. GrossMass string `json:"gross_mass"`
  20. UnladenMass string `json:"unladen_mass"`
  21. FuelTypeDetail string `json:"fuel_type_detail"`
  22. AxleNumber string `json:"axle_number"`
  23. EmissionStandard string `json:"emission_standard"`
  24. Wheelbase string `json:"wheelbase"`
  25. AxleWeight string `json:"axle_weight"`
  26. NumberOfLeafSprings string `json:"number_of_leaf_springs"`
  27. TyreNumber string `json:"tyre_number"`
  28. TyreSize string `json:"tyre_size"`
  29. ApproachingDepartureAngle string `json:"approaching_departure_angle"`
  30. FrontBackSuspention string `json:"front_back_suspention"`
  31. FrontWheelDistance string `json:"front_wheel_distance"`
  32. BackWheelDistance string `json:"back_wheel_distance"`
  33. VinRules string `json:"vin_rules"`
  34. Long string `json:"long"`
  35. Wide string `json:"wide"`
  36. High string `json:"high"`
  37. CargoLong string `json:"cargo_long"`
  38. CargoWide string `json:"cargo_wide"`
  39. CargoHigh string `json:"cargo_high"`
  40. TopSpeed string `json:"top_speed"`
  41. ApprovedNumber string `json:"approved_number"`
  42. NumberOfPassengers string `json:"number_of_passengers"`
  43. SteeringMode string `json:"steering_mode"`
  44. TractionMass string `json:"traction_mass"`
  45. LoadMassCoefficient string `json:"load_mass_coefficient"`
  46. SemitrailerSaddleMaxAllowGrossMass string `json:"semitrailer_saddle_max_allow_gross_mass"`
  47. CompanyName string `json:"company_name"`
  48. CompanyAddress string `json:"company_address"`
  49. }
  50. // 公告号数据
  51. func A03(ctx context.Context, params string) (reply *apis.QueryResponse, err error) {
  52. reply = &apis.QueryResponse{}
  53. var req a03Request
  54. err = jsoniter.UnmarshalFromString(params, &req)
  55. if err != nil && req.ModelNo == "" {
  56. return nil, errors.ParamsError
  57. }
  58. db := database.DB()
  59. var res a03Response
  60. err = db.Raw("select model_no, vehicle_batch, brand_name, vehicle_type_detail, approved_load, gross_mass, unladen_mass, fuel_type_detail, "+
  61. "axle_number, emission_standard, wheelbase, axle_weight, number_of_leaf_springs, tyre_number, tyre_size, approaching_departure_angle, "+
  62. "front_back_suspention, front_wheel_distance, back_wheel_distance, vin_rules, `long`, wide, high, cargo_long, cargo_wide, cargo_high, top_speed, "+
  63. "approved_number, number_of_passengers, steering_mode, traction_mass, load_mass_coefficient, semitrailer_saddle_max_allow_gross_mass, "+
  64. "company_name, company_address from t_adm_dws16 where model_no = ? ", req.ModelNo).Find(&res).Error
  65. if err != nil {
  66. if err == gorm.ErrRecordNotFound {
  67. return reply, errors.DataNotExistError
  68. }
  69. return reply, errors.SystemError
  70. }
  71. reply.Data, _ = jsoniter.MarshalToString(res)
  72. return reply, nil
  73. }