F01.go 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724
  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. "git.getensh.com/common/gopkgsv2/database"
  11. "strconv"
  12. "strings"
  13. "time"
  14. jsoniter "github.com/json-iterator/go"
  15. )
  16. // 计算最后投保日期
  17. func calcLatestInsuredate(reqMap map[string]interface{}) {
  18. retLen := utils.MonthLen
  19. firstInsuranceDate := ""
  20. lastCompulsoryInsuranceDate := ""
  21. if v, ok := reqMap["first_insurance_date"]; ok {
  22. firstInsuranceDate = v.(string)
  23. }
  24. if v, ok := reqMap["last_compulsory_insurance_date"]; ok {
  25. lastCompulsoryInsuranceDate = v.(string)
  26. }
  27. if firstInsuranceDate == "" && lastCompulsoryInsuranceDate == "" {
  28. return
  29. }
  30. latestInsuranceDateStart := ""
  31. lastCompulsoryInsuranceDate = strings.TrimSpace(lastCompulsoryInsuranceDate)
  32. firstInsuranceDate = strings.TrimSpace(firstInsuranceDate)
  33. if lastCompulsoryInsuranceDate == "" {
  34. return
  35. } else if firstInsuranceDate == "" {
  36. latestInsuranceDateStart = lastCompulsoryInsuranceDate
  37. } else if len(lastCompulsoryInsuranceDate) < utils.MonthLen ||
  38. len(firstInsuranceDate) < utils.MonthLen {
  39. return
  40. } else if lastCompulsoryInsuranceDate[utils.MonthLen-2:utils.MonthLen] == firstInsuranceDate[utils.MonthLen-2:utils.MonthLen] {
  41. if len(firstInsuranceDate) == utils.DataLen {
  42. latestInsuranceDateStart = lastCompulsoryInsuranceDate + firstInsuranceDate[7:]
  43. retLen = utils.DataLen
  44. } else {
  45. latestInsuranceDateStart = lastCompulsoryInsuranceDate
  46. }
  47. } else {
  48. latestInsuranceDateStart = lastCompulsoryInsuranceDate
  49. }
  50. latestInsuranceDateStart = strings.TrimSpace(latestInsuranceDateStart)
  51. if len(latestInsuranceDateStart) > utils.DataLen {
  52. latestInsuranceDateStart = latestInsuranceDateStart[:utils.DataLen]
  53. } else if len(latestInsuranceDateStart) == utils.MonthLen {
  54. latestInsuranceDateStart = latestInsuranceDateStart + "-01"
  55. }
  56. latestInsuranceDateStartTime, _ := time.Parse(utils.DayLayout, latestInsuranceDateStart)
  57. latestInsuranceDateEnd := latestInsuranceDateStartTime.AddDate(1, 0, 0).String()[:retLen]
  58. reqMap["latest_insurance_date_end"] = latestInsuranceDateEnd
  59. reqMap["latest_nsurance_date_start"] = latestInsuranceDateStart
  60. }
  61. func FormatApprovedNumber(in string) string {
  62. in = FormatNormal(in)
  63. in = getApprovedNumberStr(in)
  64. return in
  65. }
  66. func FormatNormal(in string) string {
  67. in = strings.TrimSpace(in)
  68. in = strings.TrimLeft(in, "-")
  69. in = strings.TrimLeft(in, ".")
  70. in = strings.TrimLeft(in, "/")
  71. in = strings.TrimLeft(in, "&")
  72. in = strings.TrimLeft(in, ",")
  73. in = strings.Replace(in, `"`, "", -1)
  74. if strings.Contains(in, "月") {
  75. return ""
  76. }
  77. switch in {
  78. case "―":
  79. return ""
  80. /*case "99999":
  81. return ""
  82. case "999999":
  83. return ""
  84. case "9999999":
  85. return ""
  86. case "99999999":
  87. return ""*/
  88. case "00976867":
  89. return ""
  90. case "02":
  91. return "2"
  92. case "04":
  93. return "4"
  94. case "06":
  95. return "6"
  96. case "07":
  97. return "7"
  98. case "08":
  99. return "8"
  100. case "09":
  101. return "9"
  102. case "未":
  103. return ""
  104. case "无":
  105. return ""
  106. case "未知":
  107. return ""
  108. case "N/A":
  109. return ""
  110. case "*ANQ":
  111. return "ANQ"
  112. case "/AYJ":
  113. return "AYJ"
  114. case "----":
  115. return ""
  116. case "---":
  117. return ""
  118. case "######":
  119. return ""
  120. case "***":
  121. return ""
  122. case "****":
  123. return ""
  124. case "**/":
  125. return ""
  126. case "....":
  127. return ""
  128. case ".00":
  129. return ""
  130. case "0.1*":
  131. return ""
  132. case "00":
  133. return ""
  134. case "000":
  135. return ""
  136. case "0000":
  137. return ""
  138. case "00000":
  139. return ""
  140. case "000000":
  141. return ""
  142. case "0000000":
  143. return ""
  144. case "+":
  145. return ""
  146. case "+G4E":
  147. return "G4E"
  148. case "0.0":
  149. return ""
  150. case "0":
  151. return ""
  152. case "-1":
  153. return ""
  154. case "?":
  155. return ""
  156. case "-":
  157. return ""
  158. case "--":
  159. return ""
  160. case ".":
  161. return ""
  162. case "..":
  163. return ""
  164. case "...":
  165. return ""
  166. case "/":
  167. return ""
  168. case "#":
  169. return ""
  170. case "##":
  171. return ""
  172. case "*":
  173. return ""
  174. case "**":
  175. return ""
  176. case "__":
  177. return ""
  178. case "null":
  179. return ""
  180. case "/8":
  181. return "8"
  182. case "#NAME?":
  183. return ""
  184. case "1.4/44KW 5G":
  185. return ""
  186. //case "1.6":
  187. //return ""
  188. case "1.6AT":
  189. return ""
  190. //case "1.8":
  191. //return ""
  192. case "1.8AT":
  193. return ""
  194. //case "1.8T":
  195. //return ""
  196. case "1.8TAT":
  197. return ""
  198. //case "100":
  199. //return ""
  200. case "100-2.2E":
  201. return ""
  202. case "100-2.6E":
  203. return ""
  204. case "1598CC":
  205. return ""
  206. case "1984CC":
  207. return ""
  208. case "1984CC小轿车":
  209. return ""
  210. case "1997CC":
  211. return ""
  212. }
  213. in = strings.Replace(in, ` `, "", -1)
  214. return in
  215. }
  216. // 发动机型号
  217. func FormatEngineType(in string) string {
  218. if in == "" {
  219. return in
  220. }
  221. in = strings.TrimSpace(in)
  222. in = strings.Replace(in, `,`, "", -1)
  223. in = strings.Replace(in, `+`, "", -1)
  224. in = strings.Replace(in, `*`, "", -1)
  225. //in = strings.Replace(in,`.`,"",-1)
  226. //in = strings.TrimLeft(in,"-")
  227. //in = strings.TrimLeft(in,"-")
  228. //in = strings.TrimLeft(in,"/")
  229. return FormatNormal(in)
  230. }
  231. // 轴荷
  232. func FormatAxleWeight(in string) string {
  233. if in == "" {
  234. return ""
  235. }
  236. in = strings.Replace(in, `"`, "", -1)
  237. in = strings.Replace(in, `-/`, "", -1)
  238. return FormatNormal(in)
  239. }
  240. // 轮胎数
  241. func FormatTyreNum(tyreNum string) string {
  242. if tyreNum == "" {
  243. return ""
  244. }
  245. if strings.Contains(tyreNum, "AM") || strings.Contains(tyreNum, "月") || strings.Contains(tyreNum, "R") {
  246. return ""
  247. }
  248. tyreNum = strings.Replace(tyreNum, "]", "", -1)
  249. return FormatNormal(tyreNum)
  250. }
  251. // 轴数
  252. func FormatAxleNumber(axleNumber string) string {
  253. if axleNumber == "" {
  254. return axleNumber
  255. }
  256. switch axleNumber {
  257. case "2月4日":
  258. return "2线4轴"
  259. case "2轴":
  260. return "2"
  261. case "3轴":
  262. return "3"
  263. case "4轴":
  264. return "4"
  265. case "5轴":
  266. return "5"
  267. case "三线六轴":
  268. return "3线6轴"
  269. case "三轴":
  270. return "3"
  271. case "两线四轴":
  272. return "2线4轴"
  273. case "二线四轴":
  274. return "2线4轴"
  275. case "-":
  276. return ""
  277. case "-1":
  278. return ""
  279. }
  280. axleNumber = strings.Replace(axleNumber, `"`, "", -1)
  281. axleNumber = strings.Replace(axleNumber, `,`, "", -1)
  282. return axleNumber
  283. }
  284. // 轮胎规格
  285. func FormatTyreSize(tyreSize string) string {
  286. if tyreSize == "" {
  287. return ""
  288. }
  289. tyreSize = strings.Replace(tyreSize, `"`, "", -1)
  290. tyreSize = strings.Replace(tyreSize, `第1轴:`, "第1轴", -1)
  291. tyreSize = strings.Replace(tyreSize, `第2轴:`, "第2轴", -1)
  292. tyreSize = strings.Replace(tyreSize, `;第2轴`, "第2轴", -1)
  293. tyreSize = strings.Replace(tyreSize, `第一轴`, "第1轴", -1)
  294. tyreSize = strings.Replace(tyreSize, `第二轴`, "第2轴", -1)
  295. tyreSize = strings.Replace(tyreSize, `前`, "第1轴", -1)
  296. tyreSize = strings.Replace(tyreSize, `后`, "第2轴", -1)
  297. tyreSize = strings.Replace(tyreSize, ` `, "", -1)
  298. return tyreSize
  299. }
  300. func FormatOilWear(oilWear string) string {
  301. if oilWear == "" {
  302. return ""
  303. }
  304. // 截断
  305. oilWear = strings.Split(oilWear, "L")[0]
  306. oilWear = strings.Split(oilWear, "(")[0]
  307. oilWear = strings.Split(oilWear, "&")[0]
  308. oilWear = strings.Split(oilWear, "R")[0]
  309. oilWear = strings.Split(oilWear, "(")[0]
  310. // 去掉空格
  311. oilWear = strings.Replace(oilWear, "小于等于", "", -1)
  312. oilWear = strings.Replace(oilWear, " ", "", -1)
  313. if oilWear == "" {
  314. return ""
  315. }
  316. num, err := strconv.ParseFloat(oilWear, 10)
  317. if err != nil {
  318. return ""
  319. }
  320. if num == 0 {
  321. return ""
  322. }
  323. if num > 200 {
  324. return ""
  325. }
  326. return fmt.Sprintf("%.2f", num)
  327. }
  328. func FormatRatedPower(in string) string {
  329. num, err := strconv.ParseFloat(in, 10)
  330. if err != nil {
  331. return RatedPower(in)
  332. //return in
  333. }
  334. if num == 0 {
  335. return ""
  336. }
  337. return fmt.Sprintf("%.1f", num)
  338. }
  339. func FormatLongWideHigh(in string) string {
  340. if in == "" {
  341. return in
  342. }
  343. inList := strings.Split(in, ",")
  344. for _, v := range inList {
  345. if v == "0" {
  346. continue
  347. } else {
  348. return v
  349. }
  350. }
  351. return in
  352. }
  353. func FormatField(reqMap map[string]interface{}, key string) {
  354. if v, ok := reqMap[key]; ok {
  355. if _, ok = v.(string); ok && v.(string) != "" {
  356. switch key {
  357. case "engine_type":
  358. reqMap[key] = FormatEngineType(v.(string))
  359. case "axle_weight":
  360. reqMap[key] = FormatAxleWeight(v.(string))
  361. case "tyre_number":
  362. reqMap[key] = FormatTyreNum(v.(string))
  363. case "axle_number":
  364. reqMap[key] = FormatAxleNumber(v.(string))
  365. case "tyre_size":
  366. reqMap[key] = FormatTyreSize(v.(string))
  367. case "oil_wear":
  368. reqMap[key] = FormatOilWear(v.(string))
  369. case "rated_power":
  370. reqMap[key] = FormatRatedPower(v.(string))
  371. case "traction_mass":
  372. tmp := FormatNormal(v.(string))
  373. reqMap[key] = FormatLongWideHigh(tmp)
  374. case "front_wheel_distance":
  375. tmp := FormatNormal(v.(string))
  376. reqMap[key] = FormatLongWideHigh(tmp)
  377. case "back_wheel_distance":
  378. tmp := FormatNormal(v.(string))
  379. reqMap[key] = FormatLongWideHigh(tmp)
  380. case "gross_mass":
  381. tmp := FormatNormal(v.(string))
  382. reqMap[key] = FormatLongWideHigh(tmp)
  383. case "unladen_mass":
  384. tmp := FormatNormal(v.(string))
  385. reqMap[key] = FormatLongWideHigh(tmp)
  386. case "approved_load":
  387. tmp := FormatNormal(v.(string))
  388. reqMap[key] = FormatLongWideHigh(tmp)
  389. case "wheel_base":
  390. wheelBase := FormatNormal(v.(string))
  391. reqMap[key] = FormatLongWideHigh(wheelBase)
  392. case "long":
  393. reqMap[key] = FormatLongWideHigh(v.(string))
  394. case "wide":
  395. reqMap[key] = FormatLongWideHigh(v.(string))
  396. case "high":
  397. reqMap[key] = FormatLongWideHigh(v.(string))
  398. case "approved_number":
  399. reqMap[key] = FormatApprovedNumber(v.(string))
  400. case "displacement":
  401. reqMap[key] = FormatNormal(v.(string))
  402. case "displacement_l":
  403. reqMap[key] = FormatNormal(v.(string))
  404. case "engine_no":
  405. reqMap[key] = FormatNormal(v.(string))
  406. }
  407. }
  408. }
  409. }
  410. func DisplacementTol(displacementml string) string {
  411. tmp, err := strconv.Atoi(displacementml)
  412. if err != nil {
  413. return displacementml
  414. }
  415. if tmp == 0 {
  416. return displacementml
  417. }
  418. left := tmp % 100
  419. if left >= 50 {
  420. tmp = tmp / 100
  421. tmp = tmp * 100
  422. tmp = tmp + 100
  423. } else {
  424. tmp = tmp / 100
  425. tmp = tmp * 100
  426. }
  427. r := float64(tmp) / float64(1000)
  428. return fmt.Sprintf("%.1f", r)
  429. }
  430. func formatVehicleType(reqMap map[string]interface{}) {
  431. if v, ok := reqMap["vehicle_type"]; ok {
  432. if _, ok = v.(string); ok && v.(string) == "" {
  433. vehicleTypeDetail := getString("vehicle_type_detail", reqMap)
  434. longStr := getString("long", reqMap)
  435. approvedNumberStr := getString("approved_number", reqMap)
  436. grossMassStr := getString("gross_mass", reqMap)
  437. displacementStr := getString("displacement", reqMap)
  438. long, _ := strconv.Atoi(longStr)
  439. approvedNumber, _ := strconv.Atoi(approvedNumberStr)
  440. grossMass, _ := strconv.Atoi(grossMassStr)
  441. displacement, _ := strconv.Atoi(displacementStr)
  442. reqMap["vehicle_type"] = utils.CalcVehicleType(vehicleTypeDetail, long, approvedNumber, displacement, grossMass)
  443. //reqMap["vehicle_type"] = "xxxx"
  444. //reqMap["emission_standard"] = utils.EmissionStandard(v.(string))
  445. }
  446. }
  447. }
  448. func formatYearMonth(m map[string]interface{}, s string) {
  449. if v, ok := m[s]; ok {
  450. if _, ok = v.(string); ok && v.(string) != "" {
  451. if len(v.(string)) > utils.MonthLen {
  452. m[s] = v.(string)[0:utils.MonthLen]
  453. }
  454. }
  455. }
  456. }
  457. func formatDate(m map[string]interface{}, s string) {
  458. if v, ok := m[s]; ok {
  459. if _, ok = v.(string); ok && v.(string) != "" {
  460. m[s] = utils.FormatDate(v.(string))
  461. }
  462. }
  463. }
  464. func formatDataCode(m map[string]interface{}, s, t string, f func(string) (string, string)) {
  465. if v, ok := m[s]; ok {
  466. if _, ok = v.(string); ok && v.(string) == "" {
  467. if v, ok = m[t]; ok {
  468. if _, ok = v.(string); ok && v.(string) != "" {
  469. m[s], _ = f(v.(string))
  470. return
  471. }
  472. }
  473. }
  474. }
  475. if v, ok := m[t]; ok {
  476. if _, ok = v.(string); ok && v.(string) == "" {
  477. if v, ok = m[s]; ok {
  478. if _, ok = v.(string); ok && v.(string) != "" {
  479. m[t], _ = f(v.(string))
  480. return
  481. }
  482. }
  483. }
  484. }
  485. }
  486. func formatEmissionStandard(reqMap map[string]interface{}) {
  487. if v, ok := reqMap["emission_standard"]; ok {
  488. if _, ok = v.(string); ok && v.(string) != "" {
  489. reqMap["emission_standard"] = utils.EmissionStandard(v.(string))
  490. }
  491. }
  492. }
  493. func formatDisplacement(reqMap map[string]interface{}) {
  494. if v, ok := reqMap["displacement"]; ok {
  495. var (
  496. temp int
  497. )
  498. switch v.(type) {
  499. case string:
  500. temp, _ = strconv.Atoi(v.(string))
  501. case float64:
  502. temp = int(v.(float64))
  503. case int64:
  504. temp = int(v.(int64))
  505. }
  506. if temp > 100000 {
  507. temp /= 1000
  508. switch v.(type) {
  509. case string:
  510. reqMap["displacement"] = strconv.Itoa(temp)
  511. case float64:
  512. reqMap["displacement"] = float64(temp)
  513. case int64:
  514. reqMap["displacement"] = int64(temp)
  515. }
  516. }
  517. if temp > 0 {
  518. if l, ok := reqMap["displacement_l"]; ok {
  519. if _, ok = l.(string); ok && l.(string) == "" {
  520. reqMap["displacement_l"] = strconv.FormatFloat(float64(temp)/float64(1000), 'f', 1, 64)
  521. }
  522. }
  523. }
  524. }
  525. if v, ok := reqMap["displacement_l"]; ok {
  526. if _, ok = v.(string); ok && v.(string) != "" {
  527. tmp := strings.Replace(v.(string), "L", "", -1)
  528. tmp = strings.Replace(tmp, "T", "", -1)
  529. displacementL, _ := strconv.ParseFloat(tmp, 64)
  530. if displacementL > 100 {
  531. reqMap["displacement_l"] = strconv.FormatFloat(float64(displacementL)/float64(1000), 'f', 1, 64)
  532. }
  533. if l, ok := reqMap["displacement"]; ok {
  534. var (
  535. temp int
  536. )
  537. switch l.(type) {
  538. case string:
  539. temp, _ = strconv.Atoi(l.(string))
  540. case float64:
  541. temp = int(l.(float64))
  542. case int64:
  543. temp = int(l.(int64))
  544. }
  545. if temp == 0 {
  546. if displacementL > 100 {
  547. temp = int(displacementL)
  548. } else {
  549. temp = int(displacementL * float64(1000))
  550. }
  551. switch l.(type) {
  552. case string:
  553. reqMap["displacement"] = strconv.Itoa(temp)
  554. case float64:
  555. reqMap["displacement"] = float64(temp)
  556. case int64:
  557. reqMap["displacement"] = int64(temp)
  558. }
  559. }
  560. }
  561. }
  562. }
  563. }
  564. func formatBrand(reqMap map[string]interface{}) {
  565. if v, ok := reqMap["brand_name"]; ok {
  566. if _, ok = v.(string); ok && v.(string) != "" {
  567. if ads22, err := model.NewAds22Model().Get(database.DB().Where("source = ? and type = 6", v)); err == nil {
  568. if ads22.Standard != "" {
  569. //reqMap["brand_id"] = ads22.Standard
  570. ads2, err := model.NewDws20Model().Get(database.DB().Where("brand_id = ?", ads22.Standard))
  571. if err == nil {
  572. reqMap["brand_name"] = ads2.BrandName
  573. reqMap["brand_id"] = ads22.Standard
  574. } else {
  575. reqMap["brand_name"] = ads22.Standard
  576. }
  577. } else {
  578. if ads2, err := model.NewDws20Model().Get(database.DB().Where("brand_name = ?", v)); err == nil {
  579. reqMap["brand_name"] = ads2.BrandName
  580. if ads2.BrandId != "" {
  581. reqMap["brand_id"] = ads2.BrandId
  582. }
  583. }
  584. }
  585. } else {
  586. if ads2, err := model.NewDws20Model().Get(database.DB().Where("brand_name = ?", v)); err == nil {
  587. reqMap["brand_name"] = ads2.BrandName
  588. if ads2.BrandId != "" {
  589. reqMap["brand_id"] = ads2.BrandId
  590. }
  591. }
  592. }
  593. }
  594. }
  595. }
  596. func formatData(reqMap map[string]interface{}) {
  597. // 补充初等
  598. //supplementRegisterDate(reqMap)
  599. // 格式化日期
  600. formatDate(reqMap, "initial_registration_date")
  601. formatDate(reqMap, "inspection_result_effective_to")
  602. formatDate(reqMap, "release_date")
  603. formatDate(reqMap, "insurance_first_date")
  604. formatDate(reqMap, "compulsory_scrap_to")
  605. formatYearMonth(reqMap, "last_compulsory_insurance_date")
  606. calcLatestInsuredate(reqMap)
  607. // 格式化数据编码
  608. formatDataCode(reqMap, "use_property", "use_property_detail", utils.ParseProperty)
  609. fmt.Println("user property :", reqMap["use_property"], reqMap["use_property"])
  610. formatDataCode(reqMap, "fuel_type", "fuel_type_detail", utils.ParseFuel)
  611. formatDataCode(reqMap, "vehicle_type", "vehicle_type_detail", utils.VehicleType)
  612. formatDataCode(reqMap, "vehicle_body_color", "vehicle_body_color_detail", utils.ParseColor)
  613. formatDataCode(reqMap, "body_color", "body_color_detail", utils.ParseColor)
  614. formatVehicleType(reqMap)
  615. // 格式化排放标准
  616. formatEmissionStandard(reqMap)
  617. // 格式化排量
  618. formatDisplacement(reqMap)
  619. // 格式化品牌
  620. formatBrand(reqMap)
  621. FormatField(reqMap, "engine_type")
  622. FormatField(reqMap, "axle_weight")
  623. FormatField(reqMap, "tyre_number")
  624. FormatField(reqMap, "axle_number")
  625. FormatField(reqMap, "tyre_size")
  626. FormatField(reqMap, "oil_wear")
  627. FormatField(reqMap, "rated_power")
  628. FormatField(reqMap, "traction_mass")
  629. FormatField(reqMap, "front_wheel_distance")
  630. FormatField(reqMap, "back_wheel_distance")
  631. FormatField(reqMap, "gross_mass")
  632. FormatField(reqMap, "unladen_mass")
  633. FormatField(reqMap, "approved_load")
  634. FormatField(reqMap, "wheel_base")
  635. FormatField(reqMap, "long")
  636. FormatField(reqMap, "wide")
  637. FormatField(reqMap, "high")
  638. FormatField(reqMap, "approved_number")
  639. FormatField(reqMap, "displacement")
  640. FormatField(reqMap, "displacement_l")
  641. FormatField(reqMap, "engine_no")
  642. // 计算强制报废日期
  643. utils.CalcCompulsoryScrapTo(reqMap)
  644. // 计算年检到期时间
  645. utils.CalcAnnualExamExpireTime(reqMap)
  646. }
  647. // 格式化数据
  648. func F01(ctx context.Context, params string) (reply *apis.QueryResponse, err error) {
  649. reply = &apis.QueryResponse{}
  650. reply.Data = params
  651. reqMap := make(map[string]interface{})
  652. err = json.Unmarshal([]byte(params), &reqMap)
  653. if err != nil {
  654. return reply, errors.ParamsError
  655. }
  656. // 格式化数据
  657. formatData(reqMap)
  658. reply.Data, _ = jsoniter.MarshalToString(reqMap)
  659. return reply, nil
  660. }