liusuyi
2026-06-01 a2e7e8ff9cfaa69b001d483710bddbda50d55c91
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package com.ard.gb28181.api.domain;
 
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
 
import java.io.Serializable;
 
/**
 * 国标编码对象
 */
@Data
@Schema(description = "国标编码对象")
public class GbCode implements Serializable {
 
    @Schema(description = "中心编码,由监控中心所在地的行政区划代码确定,符合GB/T2260—2007的要求")
    private String centerCode;
 
    @Schema(description = "行业编码")
    private String industryCode;
 
    @Schema(description = "类型编码")
    private String typeCode;
 
    @Schema(description = "网络标识")
    private String netCode;
 
    @Schema(description = "序号")
    private String sn;
 
    /**
     * 解析国标编号
     */
    public static GbCode decode(String code){
        if (code == null || code.trim().length() != 20) {
            return null;
        }
        code = code.trim();
        GbCode gbCode = new GbCode();
        gbCode.setCenterCode(code.substring(0, 8));
        gbCode.setIndustryCode(code.substring(8, 10));
        gbCode.setTypeCode(code.substring(10, 13));
        gbCode.setNetCode(code.substring(13, 14));
        gbCode.setSn(code.substring(14));
        return gbCode;
    }
 
    public String ecode(){
        return centerCode + industryCode + typeCode + netCode + sn;
    }
}