ods17.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Copyright 2019 autocareai.com. All rights reserved.
  2. // Use of this source code is governed by autocareai.com.
  3. package analysis
  4. import (
  5. "gadm-ods/apis"
  6. "gadm-ods/common.in/clinit"
  7. "gadm-ods/model"
  8. "strings"
  9. )
  10. // ZCRK 姓名车牌号核查(全国)(141-002)
  11. func HandleOnlineOds17(msg *apis.OdsMessage) (dataMapList []map[string]string, err error) {
  12. dataMapList, err = ParasOds12(msg.Content)
  13. if err != nil {
  14. // 解析不出来数据直接返回
  15. return nil, nil
  16. }
  17. if len(dataMapList) == 0 {
  18. return nil, nil
  19. }
  20. // 入本地库
  21. ods17 := &model.Ods17{}
  22. ods17.PlateNo = dataMapList[0]["plate_no"]
  23. ods17.PlateType = dataMapList[0]["plate_type"]
  24. ods17.Owner = dataMapList[0]["owner"]
  25. ods17.Content = msg.Content
  26. err = ods17.Insert(clinit.DB())
  27. if err != nil {
  28. if !strings.Contains(err.Error(), "Duplicate") {
  29. return nil, err
  30. } else {
  31. where := map[string]interface{}{"plate_no": ods17.PlateNo, "plate_type": ods17.PlateType, "owner": ods17.Owner}
  32. oldOds17 := &model.Ods17{}
  33. err = oldOds17.Query(clinit.DB(), where)
  34. if err == nil {
  35. oldDataMapList, _ := ParasOds12(oldOds17.Content)
  36. if checkDataMapListEqual(oldDataMapList, dataMapList) {
  37. return nil, nil
  38. }
  39. }
  40. ods17.UpdateWhere(clinit.DB(), where)
  41. }
  42. }
  43. return dataMapList, nil
  44. }