f
This commit is contained in:
@@ -141,6 +141,7 @@ type QCXGX2X6Req struct {
|
||||
type QCXG7K2NReq struct {
|
||||
PlateNo string `json:"plate_no" validate:"required"`
|
||||
Name string `json:"name" validate:"required,min=1,validName"`
|
||||
PlateType string `json:"plate_type" validate:"omitempty,oneof=01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 20 21 22 23 24 38 51 52"`
|
||||
}
|
||||
type QCXG1S2LReq struct {
|
||||
VinCode string `json:"vin_code" validate:"required"`
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package qcxg
|
||||
|
||||
import "strings"
|
||||
|
||||
const defaultPlateType = "02"
|
||||
|
||||
// plateTypeToPlateColor 将车牌类型编码转换为 ETC 人车关系核验所需的车牌颜色。
|
||||
func plateTypeToPlateColor(plateType string) string {
|
||||
code := normalizePlateType(plateType)
|
||||
if color, ok := plateTypePlateColorMap[code]; ok {
|
||||
return color
|
||||
}
|
||||
return "0"
|
||||
}
|
||||
|
||||
// normalizePlateType 归一化车牌类型,空值默认小型汽车(02)。
|
||||
func normalizePlateType(plateType string) string {
|
||||
code := strings.TrimSpace(plateType)
|
||||
if code == "" {
|
||||
return defaultPlateType
|
||||
}
|
||||
return code
|
||||
}
|
||||
|
||||
// plateTypePlateColorMap 车牌类型 -> ETC 车牌颜色
|
||||
// 0蓝 1黄 2黑 3白 4渐变绿 5黄绿双拼 6蓝白渐变 7临时 11绿 12红
|
||||
var plateTypePlateColorMap = map[string]string{
|
||||
"01": "1",
|
||||
"02": "0",
|
||||
"03": "2",
|
||||
"04": "2",
|
||||
"05": "2",
|
||||
"06": "2",
|
||||
"07": "1",
|
||||
"08": "0",
|
||||
"09": "2",
|
||||
"10": "2",
|
||||
"11": "2",
|
||||
"12": "2",
|
||||
"13": "1",
|
||||
"14": "1",
|
||||
"15": "1",
|
||||
"16": "1",
|
||||
"17": "1",
|
||||
"20": "7",
|
||||
"21": "7",
|
||||
"22": "7",
|
||||
"23": "3",
|
||||
"24": "3",
|
||||
"38": "0",
|
||||
"51": "5",
|
||||
"52": "11",
|
||||
}
|
||||
@@ -21,12 +21,18 @@ func ProcessQCXG7K2NRequest(ctx context.Context, params []byte, deps *processors
|
||||
return nil, errors.Join(processors.ErrInvalidParam, err)
|
||||
}
|
||||
|
||||
reqParams, err := json.Marshal(paramsDto)
|
||||
plateType := normalizePlateType(paramsDto.PlateType)
|
||||
|
||||
etcParams, err := json.Marshal(map[string]string{
|
||||
"plate_no": paramsDto.PlateNo,
|
||||
"name": paramsDto.Name,
|
||||
"plate_color": plateTypeToPlateColor(paramsDto.PlateType),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, errors.Join(processors.ErrSystem, err)
|
||||
}
|
||||
|
||||
respBytes, err := processors.CallTianyuanByProduct(ctx, deps, "QCXG3M7Z", reqParams)
|
||||
respBytes, err := processors.CallTianyuanByProduct(ctx, deps, "QCXG3M7Z", etcParams)
|
||||
if err == nil {
|
||||
return respBytes, nil
|
||||
}
|
||||
@@ -34,7 +40,16 @@ func ProcessQCXG7K2NRequest(ctx context.Context, params []byte, deps *processors
|
||||
return nil, err
|
||||
}
|
||||
|
||||
respBytes, err = ProcessQCXGX2X6Request(ctx, reqParams, deps)
|
||||
x2x6Params, err := json.Marshal(dto.QCXGX2X6Req{
|
||||
PlateNo: paramsDto.PlateNo,
|
||||
Name: paramsDto.Name,
|
||||
VehicleType: plateType,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, errors.Join(processors.ErrSystem, err)
|
||||
}
|
||||
|
||||
respBytes, err = ProcessQCXGX2X6Request(ctx, x2x6Params, deps)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user