12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- // Copyright 2019 autocareai.com. All rights reserved.
- // Use of this source code is governed by autocareai.com.
- package analysis
- import (
- "gadm-ods/apis"
- "gadm-ods/common.in/clinit"
- "gadm-ods/model"
- "strings"
- )
- // ZCRK 姓名车牌号核查(全国)(141-002)
- func HandleOnlineOds17(msg *apis.OdsMessage) (dataMapList []map[string]string, err error) {
- dataMapList, err = ParasOds12(msg.Content)
- if err != nil {
- // 解析不出来数据直接返回
- return nil, nil
- }
- if len(dataMapList) == 0 {
- return nil, nil
- }
- // 入本地库
- ods17 := &model.Ods17{}
- ods17.PlateNo = dataMapList[0]["plate_no"]
- ods17.PlateType = dataMapList[0]["plate_type"]
- ods17.Owner = dataMapList[0]["owner"]
- ods17.Content = msg.Content
- err = ods17.Insert(clinit.DB())
- if err != nil {
- if !strings.Contains(err.Error(), "Duplicate") {
- return nil, err
- } else {
- where := map[string]interface{}{"plate_no": ods17.PlateNo, "plate_type": ods17.PlateType, "owner": ods17.Owner}
- oldOds17 := &model.Ods17{}
- err = oldOds17.Query(clinit.DB(), where)
- if err == nil {
- oldDataMapList, _ := ParasOds12(oldOds17.Content)
- if checkDataMapListEqual(oldDataMapList, dataMapList) {
- return nil, nil
- }
- }
- ods17.UpdateWhere(clinit.DB(), where)
- }
- }
- return dataMapList, nil
- }
|