This commit is contained in:
2026-07-05 01:26:44 +08:00
parent bd0727277e
commit e4751067e3
3 changed files with 74 additions and 5 deletions

View File

@@ -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",
}

View File

@@ -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
}