info.go 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. package style
  2. import (
  3. "context"
  4. "encoding/json"
  5. "fmt"
  6. "adm-vehicle-style/errors"
  7. "adm-vehicle-style/model"
  8. v1 "adm-vehicle-style/pb/v1"
  9. "git.getensh.com/common/gopkgsv2/database"
  10. "git.getensh.com/common/gopkgsv2/logger"
  11. "go.uber.org/zap"
  12. "google.golang.org/grpc/status"
  13. )
  14. func Info(ctx context.Context, req *v1.StyleInfoRequest) (reply *v1.StyleInfoReply, err error) {
  15. reply = &v1.StyleInfoReply{}
  16. // 捕获各个task中的异常并返回给调用者
  17. defer func() {
  18. if r := recover(); r != nil {
  19. err = fmt.Errorf("%+v", r)
  20. e := &status.Status{}
  21. if er := json.Unmarshal([]byte(err.Error()), e); er != nil {
  22. logger.Error("err",
  23. zap.String("system_err", err.Error()),
  24. zap.Stack("stacktrace"))
  25. }
  26. }
  27. }()
  28. res, err := model.NewSyStyleModel().Get(database.DB().Where("id = ?", req.Id))
  29. if err != nil {
  30. return reply, errors.SystemError
  31. }
  32. reply.Aircondition = &v1.StyleInfoReply_Aircondition{
  33. AirconditionControlType: res.AirconditionControlType,
  34. CarAirPurifier: res.CarAirPurifier,
  35. FragranceSystem: res.FragranceSystem,
  36. NegativeIonGenerator: res.NegativeIonGenerator,
  37. Pm25Device: res.Pm25Device,
  38. RearIndependentAirConditioner: res.RearIndependentAirConditioner,
  39. RearSeatAirOutlet: res.RearSeatAirOutlet,
  40. Refrigerator: res.Refrigerator,
  41. TemperatureZoneControl: res.TemperatureZoneControl,
  42. }
  43. reply.Basic = &v1.StyleInfoReply_Basic{
  44. BrandId: res.BrandId,
  45. Alternator: res.Alternator,
  46. BrakingDistanceMeasure: res.BrakingDistanceMeasure,
  47. BrandName: res.BrandName,
  48. EmissionStandard: res.EmissionStandard,
  49. Engine: res.Engine,
  50. FastChargeAmount: res.FastChargeAmount,
  51. FastChargingTime: res.FastChargingTime,
  52. FuelTypeDetail: res.FuelTypeDetail,
  53. GearboxDesc: res.GearboxDesc,
  54. HundredAccelerate: res.HundredAccelerate,
  55. HundredAccelerateMeasure: res.HundredAccelerateMeasure,
  56. Level: res.Level,
  57. Lwh: res.Lwh,
  58. Maker: res.Maker,
  59. MaximumPower: res.MaximumPower,
  60. MaximumSimulationMilage: res.MaximumSimulationMilage,
  61. MaximumSimulationMilageMeasure: res.MaximumSimulationMilageMeasure,
  62. MaximumSpeed: res.MaximumSpeed,
  63. MaximumTorque: res.MaximumTorque,
  64. ModelYear: res.ModelYear,
  65. OilWearComrehensive: res.OilWearComrehensive,
  66. OilWearMeasure: res.OilWearMeasure,
  67. Price: res.Price,
  68. PriceYuan: res.PriceYuan,
  69. SeriesId: res.SeriesId,
  70. SeriesName: res.SeriesName,
  71. SlowChargingTime: res.SlowChargingTime,
  72. StyleId: res.StyleId,
  73. StyleName: res.StyleName,
  74. SubLevel: res.SubLevel,
  75. VehicleStructure: res.VehicleStructure,
  76. VehicleWarranty: res.VehicleWarranty,
  77. }
  78. reply.Body = &v1.StyleInfoReply_Body{
  79. BackWheelDistance: res.BackWheelDistance,
  80. DoorNumber: res.DoorNumber,
  81. FrontWheelDistance: res.FrontWheelDistance,
  82. High: res.High,
  83. Long: res.Long,
  84. MinimumGroundClearance: res.MinimumGroundClearance,
  85. OilboxVolume: res.OilboxVolume,
  86. SeatNumber: res.SeatNumber,
  87. TrunkVolume: res.TrunkVolume,
  88. UnladenMass: res.UnladenMass,
  89. Wheelbase: res.Wheelbase,
  90. Wide: res.Wide,
  91. }
  92. reply.Chassis = &v1.StyleInfoReply_Chassis{
  93. AssistType: res.AssistType,
  94. BackSuspentionType: res.BackSuspentionType,
  95. BodyStructure: res.BodyStructure,
  96. DriveType: res.DriveType,
  97. FrontSuspentionType: res.FrontSuspentionType,
  98. }
  99. reply.Control = &v1.StyleInfoReply_Control{
  100. AirSuspension: res.AirSuspension,
  101. AscentAssist: res.AscentAssist,
  102. AutoHold: res.AutoHold,
  103. AutomaticDrivingAssistance: res.AutomaticDrivingAssistance,
  104. AutomaticParking: res.AutomaticParking,
  105. BackParkingRador: res.BackParkingRador,
  106. CentralDiffLock: res.CentralDiffLock,
  107. CruiseSystem: res.CruiseSystem,
  108. DrivingModeSelection: res.DrivingModeSelection,
  109. EInductionSuspension: res.EInductionSuspension,
  110. Edl: res.Edl,
  111. EngineStartStopTechnology: res.EngineStartStopTechnology,
  112. FrontParkingRador: res.FrontParkingRador,
  113. Hdc: res.Hdc,
  114. OverallActiveSteeringSystem: res.OverallActiveSteeringSystem,
  115. ReverseVehicleSideWarningSystem: res.ReverseVehicleSideWarningSystem,
  116. VariableSteeringRatio: res.VariableSteeringRatio,
  117. VariableSuspension: res.VariableSuspension,
  118. WadeSensingSystem: res.WadeSensingSystem,
  119. }
  120. reply.Electric = &v1.StyleInfoReply_Electric{
  121. BackElectricMaximumPower: res.BackElectricMaximumPower,
  122. BackElectricTorque: res.BackElectricTorque,
  123. BatteryEnergy: res.BatteryEnergy,
  124. BatteryPackWarranty: res.BatteryPackWarranty,
  125. BatteryType: res.BatteryType,
  126. FrontElectricMaximumPower: res.FrontElectricMaximumPower,
  127. FrontElectricTorque: res.FrontElectricTorque,
  128. HundredElectricityConsumption: res.HundredElectricityConsumption,
  129. MaximumSimulationMilage: res.MaximumSimulationMilage,
  130. MotorLayout: res.MotorLayout,
  131. MotorNumber: res.MotorNumber,
  132. MotorType: res.MotorType,
  133. SystemIntegratedPower: res.SystemIntegratedPower,
  134. SystemIntegratedTorque: res.SystemIntegratedTorque,
  135. TotalMotorPower: res.TotalMotorPower,
  136. TotalMotorTorque: res.TotalMotorTorque,
  137. }
  138. reply.Engine = &v1.StyleInfoReply_Engine{
  139. AirIntakForm: res.AirIntakForm,
  140. CylinderArrangement: res.CylinderArrangement,
  141. CylinderDiameter: res.CylinderDiameter,
  142. CylinderHeadMaterial: res.CylinderHeadMaterial,
  143. CylinderMaterial: res.CylinderMaterial,
  144. CylinderNumber: res.CylinderNumber,
  145. CylinderValveNumber: res.CylinderValveNumber,
  146. Displacement: res.Displacement,
  147. DisplacementL: res.DisplacementL,
  148. EngineTechnology: res.EngineTechnology,
  149. EngineType: res.EngineType,
  150. FuelLable: res.FuelLable,
  151. FuelTypeDetail: res.FuelTypeDetail,
  152. MaximumHorsepower: res.MaximumHorsepower,
  153. MaximumPowerRpm: res.MaximumPowerRpm,
  154. OilSupplyMode: res.OilSupplyMode,
  155. PistonStroke: res.PistonStroke,
  156. ReductionRatio: res.ReductionRatio,
  157. Rpm: res.Rpm,
  158. ValveMechanism: res.ValveMechanism,
  159. }
  160. reply.External = &v1.StyleInfoReply_External{
  161. ActiveIntakeGrille: res.ActiveIntakeGrille,
  162. BatteryPreHeating: res.BatteryPreHeating,
  163. CentralControlLock: res.CentralControlLock,
  164. ElectricTrunk: res.ElectricTrunk,
  165. ElectronicAntiTheft: res.ElectronicAntiTheft,
  166. Eosd: res.Eosd,
  167. FramelessDesignDoor: res.FramelessDesignDoor,
  168. HideElectricDoorHandle: res.HideElectricDoorHandle,
  169. InductiveTrunk: res.InductiveTrunk,
  170. KeyType: res.KeyType,
  171. KeylessEntrySystem: res.KeylessEntrySystem,
  172. KeylessStartSystem: res.KeylessStartSystem,
  173. OutsidePedal: res.OutsidePedal,
  174. RearCompartmentPositionMemory: res.RearCompartmentPositionMemory,
  175. RemoteStart: res.RemoteStart,
  176. RimMaterial: res.RimMaterial,
  177. RoofLuggageRack: res.RoofLuggageRack,
  178. SideSlidingDoor: res.SideSlidingDoor,
  179. SkylightType: res.SkylightType,
  180. SportsAppearanceKit: res.SportsAppearanceKit,
  181. Tail: res.Tail,
  182. TheTailgateGlassOpensIndependently: res.TheTailgateGlassOpensIndependently,
  183. }
  184. reply.Gearbox = &v1.StyleInfoReply_Gearbox{
  185. GearNumber: res.GearNumber,
  186. GearboxDesc: res.GearboxDesc,
  187. GearboxType: res.GearboxType,
  188. }
  189. reply.Internal = &v1.StyleInfoReply_Internal{
  190. ActiveNoiseReduction: res.ActiveNoiseReduction,
  191. CarDrivingRecorder: res.CarDrivingRecorder,
  192. DrivingComputerDisplay: res.DrivingComputerDisplay,
  193. ElectricallyAdjustablePedal: res.ElectricallyAdjustablePedal,
  194. FullLcdDashboard: res.FullLcdDashboard,
  195. FullLcdDashboardSize: res.FullLcdDashboardSize,
  196. HudRisingNumberDisplay: res.HudRisingNumberDisplay,
  197. MobilePhoneWirelessCharging: res.MobilePhoneWirelessCharging,
  198. MultiFunctionalSteeringWheel: res.MultiFunctionalSteeringWheel,
  199. SteeringWheelAdjustment: res.SteeringWheelAdjustment,
  200. SteeringWheelHeating: res.SteeringWheelHeating,
  201. SteeringWheelMaterial: res.SteeringWheelMaterial,
  202. SteeringWheelRemember: res.SteeringWheelRemember,
  203. SteeringWheelShift: res.SteeringWheelShift,
  204. }
  205. reply.Light = &v1.StyleInfoReply_Light{
  206. AdaptiveFarNear: res.AdaptiveFarNear,
  207. Atmosphere: res.Atmosphere,
  208. AutoHead: res.AutoHead,
  209. Clean: res.Clean,
  210. Daytime: res.Daytime,
  211. Far: res.Far,
  212. Fog: res.Fog,
  213. HeadlampDelayOff: res.HeadlampDelayOff,
  214. HeadlampRainFogMode: res.HeadlampRainFogMode,
  215. HeightAdjustable: res.HeightAdjustable,
  216. LightingFeatures: res.LightingFeatures,
  217. Near: res.Near,
  218. SideTurn: res.SideTurn,
  219. SteeringAssistLamp: res.SteeringAssistLamp,
  220. TouchReadingLamp: res.TouchReadingLamp,
  221. }
  222. reply.Media = &v1.StyleInfoReply_Media{
  223. BackLcd: res.BackLcd,
  224. CarInternet: res.CarInternet,
  225. CarPhone: res.CarPhone,
  226. CarTv: res.CarTv,
  227. CdDvd: res.CdDvd,
  228. CenterConsoleLargeScreenSize: res.CenterConsoleLargeScreenSize,
  229. CentralColourScreen: res.CentralColourScreen,
  230. CentralLcdSplitScreen: res.CentralLcdSplitScreen,
  231. ChargingInterface: res.ChargingInterface,
  232. FaceRecognition: res.FaceRecognition,
  233. GestureControl: res.GestureControl,
  234. Gps: res.Gps,
  235. InterfaceOf12V: res.InterfaceOf12v,
  236. MobileInternet: res.MobileInternet,
  237. NavigationTrafficInformationDisplay: res.NavigationTrafficInformationDisplay,
  238. NumberOfInterfaces: res.NumberOfInterfaces,
  239. Ota: res.Ota,
  240. PowerOf220V: res.PowerOf220v,
  241. RearControlMultimedia: res.RearControlMultimedia,
  242. RoadRescueCall: res.RoadRescueCall,
  243. SpeakerBrand: res.SpeakerBrand,
  244. SpeakerNumber: res.SpeakerNumber,
  245. VoiceControl: res.VoiceControl,
  246. }
  247. reply.Optional = &v1.StyleInfoReply_Optional{
  248. BodyColour: res.BodyColour,
  249. InteriorColor: res.InteriorColor,
  250. }
  251. reply.Rearview = &v1.StyleInfoReply_Rearview{
  252. AntiPinchHand: res.AntiPinchHand,
  253. BackElectricWindow: res.BackElectricWindow,
  254. BackSidePrivacy: res.BackSidePrivacy,
  255. BackSideSunshade: res.BackSideSunshade,
  256. BackSunshade: res.BackSunshade,
  257. BackWiper: res.BackWiper,
  258. Cosmetic: res.Cosmetic,
  259. ExteriorRearviewMirrorFunction: res.ExteriorRearviewMirrorFunction,
  260. FrontElectricWindow: res.FrontElectricWindow,
  261. FrontWiper: res.FrontWiper,
  262. HeatableSprayNozzle: res.HeatableSprayNozzle,
  263. InteriorRearviewMirrorFunction: res.InteriorRearviewMirrorFunction,
  264. MultilayerSoundInsulationGlass: res.MultilayerSoundInsulationGlass,
  265. WindowOneKey: res.WindowOneKey,
  266. }
  267. reply.Safety = &v1.StyleInfoReply_Safety{
  268. Abs: res.Abs,
  269. ActiveBrake: res.ActiveBrake,
  270. AsrTcsTrc: res.AsrTcsTrc,
  271. AuxiliarySeatAirbag: res.AuxiliarySeatAirbag,
  272. BackBeltAirbag: res.BackBeltAirbag,
  273. BackHeadAirbag: res.BackHeadAirbag,
  274. BackSideAirbag: res.BackSideAirbag,
  275. EbaBasBa: res.EbaBasBa,
  276. EbdCbc: res.EbdCbc,
  277. Esp: res.Esp,
  278. FatigueDrivingWarning: res.FatigueDrivingWarning,
  279. FontHeadAirbag: res.FontHeadAirbag,
  280. FrontMiddleAirbag: res.FrontMiddleAirbag,
  281. FrontSideAirbag: res.FrontSideAirbag,
  282. IsoFix: res.IsoFix,
  283. KneeAirbag: res.KneeAirbag,
  284. LaneDepartureWarningSystem: res.LaneDepartureWarningSystem,
  285. LaneKeeping: res.LaneKeeping,
  286. MainSeatAirbag: res.MainSeatAirbag,
  287. NightVision: res.NightVision,
  288. ParallelAuxiliary: res.ParallelAuxiliary,
  289. PassengerSeatCushionAirbag: res.PassengerSeatCushionAirbag,
  290. PassivePedestrianProtection: res.PassivePedestrianProtection,
  291. RearCentralAirbag: res.RearCentralAirbag,
  292. RearSeatAntiSlideAirbag: res.RearSeatAntiSlideAirbag,
  293. RoadTrafficSignRecognition: res.RoadTrafficSignRecognition,
  294. RunFlatTire: res.RunFlatTire,
  295. SeatBeltWarning: res.SeatBeltWarning,
  296. TirePresureMonitor: res.TirePresureMonitor,
  297. }
  298. reply.Seat = &v1.StyleInfoReply_Seat{
  299. AuxiliaryAdjustableButton: res.AuxiliaryAdjustableButton,
  300. AuxiliaryElectricAdust: res.AuxiliaryElectricAdust,
  301. AuxiliarySeatAdjustmentMode: res.AuxiliarySeatAdjustmentMode,
  302. BackCupHolder: res.BackCupHolder,
  303. BackDownType: res.BackDownType,
  304. BackFoldTable: res.BackFoldTable,
  305. BackHandrail: res.BackHandrail,
  306. ElectricSeatRemeber: res.ElectricSeatRemeber,
  307. FrontHandrail: res.FrontHandrail,
  308. FrontSeatFunction: res.FrontSeatFunction,
  309. HeatingCoolingCupHolder: res.HeatingCoolingCupHolder,
  310. MainElectricAdust: res.MainElectricAdust,
  311. MainSeatAdjustmentMode: res.MainSeatAdjustmentMode,
  312. RearSeatElectricAdjustment: res.RearSeatElectricAdjustment,
  313. RearSeatFunction: res.RearSeatFunction,
  314. RearSeatPowerDown: res.RearSeatPowerDown,
  315. SeatLayoutForm: res.SeatLayoutForm,
  316. SeatMaterial: res.SeatMaterial,
  317. SecondIndependent: res.SecondIndependent,
  318. SecondRowSeatAdjustment: res.SecondRowSeatAdjustment,
  319. SportSeat: res.SportSeat,
  320. }
  321. reply.Wheelbrake = &v1.StyleInfoReply_Wheelbrake{
  322. BackBrakeType: res.BackBrakeType,
  323. BackWheelSpecification: res.BackWheelSpecification,
  324. FrontBrakeType: res.FrontBrakeType,
  325. FrontWheelSpecification: res.FrontWheelSpecification,
  326. ParkingBrakeType: res.ParkingBrakeType,
  327. SpareWheelSpecification: res.SpareWheelSpecification,
  328. }
  329. return reply, nil
  330. }