1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- // Copyright 2019 autocareai.com. All rights reserved.
- // Use of this source code is governed by autocareai.com.
- package task
- import (
- "gadm-dws/apis"
- "gadm-dws/common.in/clinit"
- "time"
- )
- func NewDwsMessage(dwsMessage *apis.DwsMessage,outputSourceCode string) *apis.DwsMessage{
- msg := &apis.DwsMessage{}
- msg.OdsMsgType =dwsMessage.OdsMsgType
- if dwsMessage.Timestamp != 0 {
- msg.Timestamp = dwsMessage.Timestamp
- }else{
- msg.Timestamp = time.Now().Unix()
- }
- msg.SourceCode = outputSourceCode
- msg.OfflineTaskId = dwsMessage.OfflineTaskId
- return msg
- }
- func NewAdsMessage(dwsMessage *apis.DwsMessage,outputSourceCode,action string) *apis.AdsMessage {
- msg := &apis.AdsMessage{}
- msg.OdsMsgType =dwsMessage.OdsMsgType
- msg.Timestamp = time.Now().Unix()
- msg.SourceCode = outputSourceCode
- msg.Action = action
- msg.OfflineTaskId = dwsMessage.OfflineTaskId
- return msg
- }
- var ProvinceMap map[string]string
- var AreaMap map[string]string
- var SurnameMap map[string]string
- var CompoundSurnameMap map[string]string
- var LastNameMap map[string]string
- func Load(){
- ProvinceMap = make(map[string]string)
- AreaMap = make(map[string]string)
- SurnameMap = make(map[string]string)
- CompoundSurnameMap = make(map[string]string)
- LastNameMap = make(map[string]string)
- var codeList []string
- err := clinit.DB().Raw("select plate_code from t_adm_province").Find(&codeList).Error
- if err == nil {
- for _,v := range codeList{
- ProvinceMap[v] = ""
- }
- }
- err = clinit.DB().Raw("select area_code from t_adm_area").Find(&codeList).Error
- if err == nil {
- for _,v := range codeList{
- AreaMap[v] = ""
- }
- }
- err = clinit.DB().Raw("select surname from t_adm_surname").Find(&codeList).Error
- if err == nil {
- for _,v := range codeList{
- if len(v) > 3{
- CompoundSurnameMap[v] = ""
- }else{
- SurnameMap[v] = ""
- }
- }
- }
- err = clinit.DB().Raw("select last_name from t_adm_lastname").Find(&codeList).Error
- if err == nil {
- for _,v := range codeList{
- for _,v1 := range v{
- LastNameMap[string(v1)] = ""
- }
- //LastNameMap[v] = ""
- }
- }
- }
|