U01.go 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736
  1. package query
  2. import (
  3. "context"
  4. "encoding/json"
  5. "fmt"
  6. "gd_adm_data/apis"
  7. "gd_adm_data/errors"
  8. "gd_adm_data/model"
  9. "gd_adm_data/utils"
  10. "strconv"
  11. "strings"
  12. jsoniter "github.com/json-iterator/go"
  13. "git.getensh.com/common/gopkgsv2/database"
  14. )
  15. func calcMoto(vehicleTypeDetail, tyreNumber, displacement, ratedPower string) (plateType string, vehicleType string) {
  16. // 摩托车不处理
  17. if vehicleTypeDetail != "" && strings.Contains(vehicleTypeDetail, "摩托") {
  18. if vehicleTypeDetail == "两轮轻便摩托车" {
  19. vehicleType = "M22"
  20. plateType = "08"
  21. } else if vehicleTypeDetail == "两轮摩托车" {
  22. vehicleType = "M21"
  23. plateType = "07"
  24. } else {
  25. ratedPowerFloat, _ := strconv.ParseFloat(ratedPower, 64)
  26. displacementFloat, _ := strconv.ParseFloat(displacement, 64)
  27. if tyreNumber == "2" {
  28. if ratedPowerFloat <= 4 && displacementFloat <= 50 {
  29. vehicleType = "M22"
  30. plateType = "08"
  31. } else {
  32. vehicleType = "M21"
  33. plateType = "07"
  34. }
  35. } else {
  36. if ratedPowerFloat <= 4 && displacementFloat <= 50 {
  37. plateType = "08"
  38. } else {
  39. plateType = "07"
  40. }
  41. }
  42. }
  43. }
  44. return plateType, vehicleType
  45. }
  46. func getString(key string, old map[string]interface{}) string {
  47. if v, ok := old[key]; ok {
  48. switch v.(type) {
  49. case string:
  50. return strings.Split(v.(string), ",")[0]
  51. case int:
  52. return strconv.Itoa(v.(int))
  53. case int16:
  54. return strconv.Itoa(int(v.(int16)))
  55. case int32:
  56. return strconv.Itoa(int(v.(int32)))
  57. case int64:
  58. return strconv.Itoa(int(v.(int64)))
  59. case float64:
  60. return fmt.Sprintf("%1.0f", v.(float64))
  61. case float32:
  62. return fmt.Sprintf("%1.0f", v.(float32))
  63. }
  64. } else {
  65. return ""
  66. }
  67. return ""
  68. }
  69. func calcPlateType(longStr, approvedNumberStr, grossMassStr string) string {
  70. long, _ := strconv.Atoi(longStr)
  71. approvedNumber, _ := strconv.Atoi(approvedNumberStr)
  72. grossMass, _ := strconv.Atoi(grossMassStr)
  73. if long >= 6000 || approvedNumber >= 20 || grossMass >= 4500 {
  74. return "01"
  75. }
  76. if (long != 0) && (approvedNumber != 0 || grossMass != 0) {
  77. if long < 6000 && approvedNumber > 9 {
  78. return "01"
  79. } else {
  80. return "02"
  81. }
  82. }
  83. return ""
  84. }
  85. func supplementPlateTypeByCalc(old map[string]interface{}) {
  86. if v, ok := old["plate_type"]; ok {
  87. switch v.(type) {
  88. case string:
  89. if v.(string) == "" {
  90. vehicleTypeDetail := getString("vehicle_type_detail", old)
  91. tyreNumber := getString("tyre_number", old)
  92. displacement := getString("displacement", old)
  93. ratedPower := getString("rated_power", old)
  94. plateType, vehicleType := calcMoto(vehicleTypeDetail, tyreNumber, displacement, ratedPower)
  95. if plateType != "" {
  96. old["plate_type"] = plateType
  97. if _, ok1 := old["vehicle_type"]; ok1 {
  98. old["vehicle_type"] = vehicleType
  99. }
  100. } else {
  101. longStr := getString("long", old)
  102. approvedNumberStr := getString("approved_number", old)
  103. grossMassStr := getString("gross_mass", old)
  104. old["plate_type"] = calcPlateType(longStr, approvedNumberStr, grossMassStr)
  105. }
  106. }
  107. }
  108. }
  109. }
  110. func ToInt(newMap map[string]string, k string) (ret int) {
  111. if v, ok := newMap[k]; ok {
  112. if v != "" {
  113. v = strings.Split(v, ",")[0]
  114. }
  115. ret, _ = strconv.Atoi(v)
  116. }
  117. return ret
  118. }
  119. func ToFloat64(newMap map[string]string, k string) (ret float64) {
  120. if v, ok := newMap[k]; ok {
  121. if v != "" {
  122. v = strings.Split(v, ",")[0]
  123. }
  124. ret, _ = strconv.ParseFloat(v, 64)
  125. }
  126. return ret
  127. }
  128. func ToFloat32(newMap map[string]string, k string) (ret float32) {
  129. if v, ok := newMap[k]; ok {
  130. ret1, _ := strconv.ParseFloat(v, 32)
  131. ret = float32(ret1)
  132. }
  133. return ret
  134. }
  135. func toString(in interface{}) string {
  136. switch in.(type) {
  137. case string:
  138. return in.(string)
  139. case int:
  140. if in.(int) == 0 {
  141. return ""
  142. }
  143. return strconv.Itoa(in.(int))
  144. case int16:
  145. if in.(int16) == 0 {
  146. return ""
  147. }
  148. return strconv.Itoa(int(in.(int16)))
  149. case int32:
  150. if in.(int32) == 0 {
  151. return ""
  152. }
  153. return strconv.Itoa(int(in.(int32)))
  154. case int64:
  155. if in.(int64) == 0 {
  156. return ""
  157. }
  158. return strconv.Itoa(int(in.(int64)))
  159. case float64:
  160. if in.(float64) == 0 {
  161. return ""
  162. }
  163. return strconv.FormatFloat(in.(float64), 'f', -1, 64)
  164. case float32:
  165. if in.(float32) == 0 {
  166. return ""
  167. }
  168. return strconv.FormatFloat(float64(in.(float32)), 'f', -1, 32)
  169. }
  170. return ""
  171. }
  172. /*
  173. func formatType(old interface{},newMap map[string]string,k string) interface{}{
  174. switch old.(type) {
  175. case string:
  176. if old.(string) == "" || old.(string) == "0"{
  177. return old
  178. }
  179. case int:
  180. if old.(int) == 0 {
  181. return ToInt(newMap, k)
  182. }
  183. case int16:
  184. if old.(int16) == 0 {
  185. return int16(ToInt(newMap, k))
  186. }
  187. case int32:
  188. if old.(int32) == 0 {
  189. return int32(ToInt(newMap, k))
  190. }
  191. case int64:
  192. if old.(int64) == 0 {
  193. return int64(ToInt(newMap, k))
  194. }
  195. case float64:
  196. if old.(float64) == 0 {
  197. return int64(ToFloat64(newMap, k))
  198. }
  199. case float32:
  200. if old.(float32) == 0 {
  201. return int64(ToFloat32(newMap, k))
  202. }
  203. }
  204. return
  205. }*/
  206. func supplementEngineType(modelNo string, reqMap map[string]interface{}) {
  207. if modelNo == "" {
  208. return
  209. }
  210. where := make(map[string]interface{})
  211. where["model_no"] = modelNo
  212. needSupplment := false
  213. isExist := false
  214. if v, ok := reqMap["engine_type"]; ok {
  215. engineType := v.(string)
  216. if engineType != "" {
  217. isExist = true
  218. where["engine_type"] = engineType
  219. } else {
  220. needSupplment = true
  221. }
  222. }
  223. if v, ok := reqMap["displacement"]; ok {
  224. displacement := toString(v)
  225. if displacement != "" {
  226. if !isExist {
  227. where["displacement"] = displacement
  228. }
  229. } else {
  230. needSupplment = true
  231. }
  232. }
  233. if v, ok := reqMap["rated_power"]; ok {
  234. rated_power := toString(v)
  235. if rated_power != "" {
  236. if !isExist {
  237. where["rated_power"] = rated_power
  238. }
  239. } else {
  240. needSupplment = true
  241. }
  242. }
  243. if !needSupplment {
  244. return
  245. }
  246. db := database.DB()
  247. engineInfo := &model.EngineInfo{}
  248. if err := engineInfo.Query(db, where); err != nil {
  249. fmt.Println("err", err)
  250. return
  251. }
  252. newData, _ := json.Marshal(engineInfo)
  253. newMap := make(map[string]string)
  254. json.Unmarshal(newData, &newMap)
  255. for k, v1 := range reqMap {
  256. if k != "displacement" && k != "rated_power" && k != "engine_type" {
  257. continue
  258. }
  259. switch v1.(type) {
  260. case string:
  261. if v1.(string) == "" || v1.(string) == "0" {
  262. reqMap[k] = newMap[k]
  263. }
  264. case int:
  265. if v1.(int) == 0 {
  266. reqMap[k] = ToInt(newMap, k)
  267. }
  268. case int16:
  269. if v1.(int16) == 0 {
  270. reqMap[k] = int16(ToInt(newMap, k))
  271. }
  272. case int32:
  273. if v1.(int32) == 0 {
  274. reqMap[k] = int32(ToInt(newMap, k))
  275. }
  276. case int64:
  277. if v1.(int64) == 0 {
  278. reqMap[k] = int64(ToInt(newMap, k))
  279. }
  280. case float64:
  281. if v1.(float64) == 0 {
  282. reqMap[k] = float64(ToFloat64(newMap, k))
  283. }
  284. case float32:
  285. if v1.(float32) == 0 {
  286. reqMap[k] = float32(ToFloat32(newMap, k))
  287. }
  288. }
  289. }
  290. /*if v, ok := reqMap["engine_type"]; ok {
  291. engineType := v.(string)
  292. if engineType == ""{
  293. db := database.DB()
  294. ads24 := &model.Ads24{}
  295. if err := ads24.Query(db, map[string]interface{}{"model_no": modelNo}); err != nil {
  296. return
  297. }
  298. reqMap["engine_type"] = ads24.EngineType
  299. if ads24.EngineType != ""{
  300. ads25 := &model.Ads25{}
  301. if err := ads25.Query(db, map[string]interface{}{"engine_type": ads24.EngineType}); err != nil {
  302. return
  303. }
  304. newData, _ := json.Marshal(ads25)
  305. newMap := make(map[string]string)
  306. json.Unmarshal(newData, &newMap)
  307. for k, v1 := range reqMap {
  308. if k != "displacement" && k != "rated_power"{
  309. continue
  310. }
  311. switch v1.(type) {
  312. case string:
  313. if v1.(string) == "" || v1.(string) == "0"{
  314. reqMap[k] = newMap[k]
  315. }
  316. case int:
  317. if v1.(int) == 0 {
  318. reqMap[k] = ToInt(newMap, k)
  319. }
  320. case int16:
  321. if v1.(int16) == 0 {
  322. reqMap[k] = int16(ToInt(newMap, k))
  323. }
  324. case int32:
  325. if v1.(int32) == 0 {
  326. reqMap[k] = int32(ToInt(newMap, k))
  327. }
  328. case int64:
  329. if v1.(int64) == 0 {
  330. reqMap[k] = int64(ToInt(newMap, k))
  331. }
  332. case float64:
  333. if v1.(float64) == 0 {
  334. reqMap[k] = int64(ToFloat64(newMap, k))
  335. }
  336. case float32:
  337. if v1.(float32) == 0 {
  338. reqMap[k] = int64(ToFloat32(newMap, k))
  339. }
  340. }
  341. }
  342. }
  343. }
  344. }*/
  345. }
  346. func supplementData(reqMap map[string]interface{}) {
  347. modelNo := ""
  348. vin := ""
  349. if v, ok := reqMap["model_no"]; ok {
  350. modelNo = v.(string)
  351. }
  352. if v, ok := reqMap["vin"]; ok {
  353. vin = v.(string)
  354. }
  355. // 补充数据
  356. modelNo = supplementByAds19(vin, modelNo, reqMap)
  357. supplementEngineType(modelNo, reqMap)
  358. // 补充号牌种类
  359. supplementPlateType(modelNo, reqMap)
  360. supplementPlateTypeByCalc(reqMap)
  361. }
  362. func supplementByAds19(vin string, modelNo string, old map[string]interface{}) (newModelNo string) {
  363. if modelNo == "" && vin == "" {
  364. return
  365. }
  366. db := database.DB()
  367. if modelNo == "" {
  368. vinRule := ""
  369. if len(vin) > 8 {
  370. vinRule = vin[0:8]
  371. }
  372. if vinRule == "" {
  373. return
  374. }
  375. ads21 := &model.Dws11{}
  376. if err := ads21.Query(db, map[string]interface{}{"vin_rule": vinRule}); err != nil {
  377. return
  378. }
  379. old["model_no"] = ads21.ModelNo
  380. modelNo = ads21.ModelNo
  381. }
  382. ads19 := &model.Dws16{}
  383. if err := ads19.Query(db, map[string]interface{}{"model_no": modelNo}); err != nil {
  384. return modelNo
  385. }
  386. newData, _ := json.Marshal(ads19)
  387. newMap := make(map[string]string)
  388. json.Unmarshal(newData, &newMap)
  389. for k, v1 := range old {
  390. switch v1.(type) {
  391. case string:
  392. if v1.(string) == "" {
  393. if newMap[k] != "" {
  394. newMap[k] = strings.Split(newMap[k], ",")[0]
  395. }
  396. old[k] = newMap[k]
  397. }
  398. case int:
  399. if v1.(int) == 0 {
  400. old[k] = ToInt(newMap, k)
  401. }
  402. case int16:
  403. if v1.(int16) == 0 {
  404. old[k] = int16(ToInt(newMap, k))
  405. }
  406. case int32:
  407. if v1.(int32) == 0 {
  408. old[k] = int32(ToInt(newMap, k))
  409. }
  410. case int64:
  411. if v1.(int64) == 0 {
  412. old[k] = int64(ToInt(newMap, k))
  413. }
  414. case float64:
  415. if v1.(float64) == 0 {
  416. old[k] = int64(ToFloat64(newMap, k))
  417. }
  418. case float32:
  419. if v1.(float32) == 0 {
  420. old[k] = int64(ToFloat32(newMap, k))
  421. }
  422. }
  423. }
  424. return modelNo
  425. }
  426. func formatDataCode(m map[string]interface{}, s, t string, f func(string) (string, string)) {
  427. if v, ok := m[s]; ok {
  428. if _, ok = v.(string); ok && v.(string) == "" {
  429. if v, ok = m[t]; ok {
  430. if _, ok = v.(string); ok && v.(string) != "" {
  431. m[s], _ = f(v.(string))
  432. return
  433. }
  434. }
  435. }
  436. }
  437. if v, ok := m[t]; ok {
  438. if _, ok = v.(string); ok && v.(string) == "" {
  439. if v, ok = m[s]; ok {
  440. if _, ok = v.(string); ok && v.(string) != "" {
  441. m[t], _ = f(v.(string))
  442. return
  443. }
  444. }
  445. }
  446. }
  447. }
  448. func formatDate(m map[string]interface{}, s string) {
  449. if v, ok := m[s]; ok {
  450. if _, ok = v.(string); ok && v.(string) != "" {
  451. m[s] = utils.FormatDate(v.(string))
  452. }
  453. }
  454. }
  455. func formatDisplacement(reqMap map[string]interface{}) {
  456. if v, ok := reqMap["displacement"]; ok {
  457. var (
  458. temp int
  459. )
  460. switch v.(type) {
  461. case string:
  462. temp, _ = strconv.Atoi(v.(string))
  463. case float64:
  464. temp = int(v.(float64))
  465. case int64:
  466. temp = int(v.(int64))
  467. }
  468. if temp > 100000 {
  469. temp /= 1000
  470. switch v.(type) {
  471. case string:
  472. reqMap["displacement"] = strconv.Itoa(temp)
  473. case float64:
  474. reqMap["displacement"] = float64(temp)
  475. case int64:
  476. reqMap["displacement"] = int64(temp)
  477. }
  478. }
  479. if temp > 0 {
  480. if l, ok := reqMap["displacement_l"]; ok {
  481. if _, ok = l.(string); ok && l.(string) == "" {
  482. reqMap["displacement_l"] = strconv.FormatFloat(float64(temp)/float64(1000), 'f', 1, 64)
  483. }
  484. }
  485. }
  486. }
  487. if v, ok := reqMap["displacement_l"]; ok {
  488. if _, ok = v.(string); ok && v.(string) != "" {
  489. tmp := strings.Replace(v.(string), "L", "", -1)
  490. tmp = strings.Replace(tmp, "T", "", -1)
  491. displacementL, _ := strconv.ParseFloat(tmp, 64)
  492. if displacementL > 100 {
  493. reqMap["displacement_l"] = strconv.FormatFloat(float64(displacementL)/float64(1000), 'f', 1, 64)
  494. }
  495. if l, ok := reqMap["displacement"]; ok {
  496. var (
  497. temp int
  498. )
  499. switch l.(type) {
  500. case string:
  501. temp, _ = strconv.Atoi(l.(string))
  502. case float64:
  503. temp = int(l.(float64))
  504. case int64:
  505. temp = int(l.(int64))
  506. }
  507. if temp == 0 {
  508. if displacementL > 100 {
  509. temp = int(displacementL)
  510. } else {
  511. temp = int(displacementL * float64(1000))
  512. }
  513. switch l.(type) {
  514. case string:
  515. reqMap["displacement"] = strconv.Itoa(temp)
  516. case float64:
  517. reqMap["displacement"] = float64(temp)
  518. case int64:
  519. reqMap["displacement"] = int64(temp)
  520. }
  521. }
  522. }
  523. }
  524. }
  525. }
  526. func formatBrand(reqMap map[string]interface{}) {
  527. if v, ok := reqMap["brand_name"]; ok {
  528. if _, ok = v.(string); ok && v.(string) != "" {
  529. if ads22, err := model.NewAds22Model().Get(database.DB().Where("source = ? and type = 6", v)); err == nil {
  530. if ads22.Standard != "" {
  531. reqMap["brand_id"] = ads22.Standard
  532. if ads2, err := model.NewDws20Model().Get(database.DB().Where("brand_id = ?", ads22.Standard)); err == nil {
  533. reqMap["brand_name"] = ads2.BrandName
  534. }
  535. } else {
  536. if ads2, err := model.NewDws20Model().Get(database.DB().Where("brand_name = ?", v)); err == nil {
  537. reqMap["brand_name"] = ads2.BrandName
  538. if ads2.BrandId != "" {
  539. reqMap["brand_id"] = ads2.BrandId
  540. }
  541. }
  542. }
  543. } else {
  544. if ads2, err := model.NewDws20Model().Get(database.DB().Where("brand_name = ?", v)); err == nil {
  545. reqMap["brand_name"] = ads2.BrandName
  546. if ads2.BrandId != "" {
  547. reqMap["brand_id"] = ads2.BrandId
  548. }
  549. }
  550. }
  551. }
  552. }
  553. }
  554. func formatEmissionStandard(reqMap map[string]interface{}) {
  555. if v, ok := reqMap["emission_standard"]; ok {
  556. if _, ok = v.(string); ok && v.(string) != "" {
  557. reqMap["emission_standard"] = utils.EmissionStandard(v.(string))
  558. }
  559. }
  560. }
  561. func supplementPlateType(modelNo string, reqMap map[string]interface{}) {
  562. if v, ok := reqMap["plate_type"]; ok {
  563. if _, ok = v.(string); ok && v.(string) == "" {
  564. if v1, ok := reqMap["plate_no"]; ok {
  565. if _, ok = v1.(string); ok {
  566. plateNo := v1.(string)
  567. if plateNo != "" {
  568. plateType, _ := utils.VehicleDefaultPlateType(&plateNo)
  569. if plateType != "" {
  570. reqMap["plate_type"] = plateType
  571. return
  572. }
  573. }
  574. }
  575. }
  576. if modelNo == "" {
  577. return
  578. }
  579. if ads18, err := model.NewDws12Model().Get(database.DB().Where("model_no = ?", modelNo)); err == nil {
  580. reqMap["plate_type"] = ads18.PlateType
  581. }
  582. }
  583. }
  584. }
  585. // 判断首保日期和初登日期
  586. func supplementRegisterDate(reqMap map[string]interface{}) {
  587. if insuranceDate, ok := reqMap["insurance_first_date"]; ok {
  588. // 存在首保日期
  589. if initialRegistrationDate, ok := reqMap["initial_registration_date"]; ok && initialRegistrationDate == "" {
  590. reqMap["initial_registration_date"] = insuranceDate
  591. }
  592. }
  593. }
  594. func formatYearMonth(m map[string]interface{}, s string) {
  595. if v, ok := m[s]; ok {
  596. if _, ok = v.(string); ok && v.(string) != "" {
  597. if len(v.(string)) > utils.MonthLen {
  598. m[s] = v.(string)[0:utils.MonthLen]
  599. }
  600. }
  601. }
  602. }
  603. func formatData(reqMap map[string]interface{}) {
  604. // 补充初等
  605. supplementRegisterDate(reqMap)
  606. // 格式化日期
  607. formatDate(reqMap, "initial_registration_date")
  608. formatDate(reqMap, "inspection_result_effective_to")
  609. formatDate(reqMap, "release_date")
  610. formatDate(reqMap, "insurance_first_date")
  611. formatDate(reqMap, "compulsory_scrap_to")
  612. formatYearMonth(reqMap, "last_compulsory_insurance_date")
  613. calcLatestInsuredate(reqMap)
  614. // 格式化数据编码
  615. formatDataCode(reqMap, "use_property", "use_property_detail", utils.ParseProperty)
  616. formatDataCode(reqMap, "fuel_type", "fuel_type_detail", utils.ParseFuel)
  617. formatDataCode(reqMap, "vehicle_type", "vehicle_type_detail", utils.VehicleType)
  618. formatDataCode(reqMap, "vehicle_body_color", "vehicle_body_color_detail", utils.ParseColor)
  619. formatDataCode(reqMap, "body_color", "body_color_detail", utils.ParseColor)
  620. // 格式化排放标准
  621. formatEmissionStandard(reqMap)
  622. // 格式化排量
  623. formatDisplacement(reqMap)
  624. // 格式化品牌
  625. formatBrand(reqMap)
  626. FormatField(reqMap, "engine_type")
  627. FormatField(reqMap, "axle_weight")
  628. FormatField(reqMap, "tyre_number")
  629. FormatField(reqMap, "axle_number")
  630. FormatField(reqMap, "tyre_size")
  631. FormatField(reqMap, "oil_wear")
  632. FormatField(reqMap, "rated_power")
  633. FormatField(reqMap, "traction_mass")
  634. FormatField(reqMap, "front_wheel_distance")
  635. FormatField(reqMap, "back_wheel_distance")
  636. FormatField(reqMap, "gross_mass")
  637. FormatField(reqMap, "unladen_mass")
  638. FormatField(reqMap, "approved_load")
  639. FormatField(reqMap, "wheel_base")
  640. FormatField(reqMap, "long")
  641. FormatField(reqMap, "wide")
  642. FormatField(reqMap, "high")
  643. FormatField(reqMap, "approved_number")
  644. FormatField(reqMap, "displacement")
  645. FormatField(reqMap, "displacement_l")
  646. FormatField(reqMap, "engine_no")
  647. // 计算强制报废日期
  648. utils.CalcCompulsoryScrapTo(reqMap)
  649. // 计算年检到期时间
  650. utils.CalcAnnualExamExpireTime(reqMap)
  651. }
  652. func U01(ctx context.Context, params string) (reply *apis.QueryResponse, err error) {
  653. reply = &apis.QueryResponse{}
  654. reply.Data = params
  655. reqMap := make(map[string]interface{})
  656. err = json.Unmarshal([]byte(params), &reqMap)
  657. if err != nil {
  658. return reply, errors.ParamsError
  659. }
  660. // 补充车辆数据
  661. supplementData(reqMap)
  662. // 格式化数据
  663. formatData(reqMap)
  664. reply.Data, _ = jsoniter.MarshalToString(reqMap)
  665. return reply, nil
  666. }