提交 | 用户 | 时间
|
71e81e
|
1 |
package cn.stylefeng.guns.plcserver.opc.unit; |
懒 |
2 |
|
|
3 |
import org.apache.commons.lang3.StringUtils; |
|
4 |
|
|
5 |
import java.util.Calendar; |
|
6 |
|
|
7 |
public class SFCCodeTool { |
|
8 |
|
|
9 |
public static String marketAreaCode = ""; //市场区域编码 |
|
10 |
public static String softwareVersionCode = ""; //软件版本编码 |
|
11 |
public static String productCompanyCode = ""; //产品公司编码 |
|
12 |
public static String RunningWaterNumber = "0000"; //流水号 |
|
13 |
public static String SerialNumbers = "0000"; //序列号 |
e37994
|
14 |
/* public static String Years = String.valueOf(calendar.get(Calendar.YEAR)); //年份 |
71e81e
|
15 |
public static String Months = StringUtils.leftPad(String.valueOf(calendar.get(Calendar.MONTH) + 1),2, "0"); //月份 |
e37994
|
16 |
public static String Dates = StringUtils.leftPad(String.valueOf(calendar.get(Calendar.DATE)),2, "0"); //日期*/ |
71e81e
|
17 |
|
懒 |
18 |
|
|
19 |
//头部拼接 |
|
20 |
public static String C1_36V_HEAD_STRING = "T19000E001";//T1标识产品型号MTB、90表示产品扭矩、00表示 36V 6V3W、E表示国家(这里是欧洲,其他的待定)、001表示软件基础版 |
|
21 |
public static String C1_48V_HEAD_STRING = "T19000E001";//T1标识产品型号MTB、90表示产品扭矩、00表示 36V 6V3W、E表示国家(这里是欧洲,其他的待定)、001表示软件基础版 |
|
22 |
public static String T1_36V_HEAD_STRING = "T19000E001";//T1标识产品型号MTB、90表示产品扭矩、00表示 36V 6V3W、E表示国家(这里是欧洲,其他的待定)、001表示软件基础版 |
|
23 |
public static String T1_48V_HEAD_STRING = "T19000E001";//T1标识产品型号MTB、90表示产品扭矩、00表示 36V 6V3W、E表示国家(这里是欧洲,其他的待定)、001表示软件基础版 |
|
24 |
|
|
25 |
public static String CENTER_STRING = "A1";//中间拼接 |
|
26 |
|
|
27 |
public static String TAIL_STRING = "";//尾部拼接 |
|
28 |
|
e37994
|
29 |
public static void main(String[] args){ |
L |
30 |
createCodingRulesSFC("1","1","1"); |
|
31 |
} |
71e81e
|
32 |
/** |
懒 |
33 |
* 单体编号追溯 |
|
34 |
* @param softwareVersionCode 软件版本编码(型号+扭矩+差异款+国家地区+软件版本) |
|
35 |
* @param productCompanyCode 生产基地编码(生产基地代码+产线代码) |
|
36 |
* @param serialNumbers 序列号 |
|
37 |
* @return |
|
38 |
*/ |
|
39 |
|
|
40 |
public static String createCodingRulesSFC(String softwareVersionCode,String productCompanyCode,String serialNumbers){ |
e37994
|
41 |
Calendar calendar = Calendar.getInstance(); |
L |
42 |
String Years = String.valueOf(calendar.get(Calendar.YEAR)); //年份 |
|
43 |
String Months = StringUtils.leftPad(String.valueOf(calendar.get(Calendar.MONTH) + 1),2, "0"); //月份 |
|
44 |
String Dates = StringUtils.leftPad(String.valueOf(calendar.get(Calendar.DATE)),2, "0"); //日期 |
71e81e
|
45 |
StringBuffer result = new StringBuffer(); |
懒 |
46 |
|
|
47 |
String headString = ""; |
|
48 |
/* if("".equals(productCode)){ |
|
49 |
headString = C1_36V_HEAD_STRING; |
|
50 |
}else if ("".equals(productCode)){ |
|
51 |
headString = C1_48V_HEAD_STRING; |
|
52 |
}else if ("".equals(productCode)){ |
|
53 |
headString = C1_48V_HEAD_STRING; |
|
54 |
}else if ("".equals(productCode)){ |
|
55 |
headString = C1_48V_HEAD_STRING; |
|
56 |
}else { |
|
57 |
return ""; |
|
58 |
}*/ |
|
59 |
|
|
60 |
|
|
61 |
result.append(softwareVersionCode);//产品型号 |
|
62 |
result.append(Years.substring(Years.length()-2));//年 |
|
63 |
result.append(replaceMonths(Months)); |
|
64 |
result.append(Dates);//日 |
|
65 |
result.append(productCompanyCode);//班次 |
|
66 |
result.append(serialNumbers);//序列号 |
|
67 |
result.append("B");//产线 |
|
68 |
|
|
69 |
return result.toString(); |
|
70 |
} |
|
71 |
|
|
72 |
public static String replaceMonths(String months){ |
|
73 |
String result = ""; |
|
74 |
switch(months) { |
|
75 |
case "01": |
|
76 |
result = "A"; |
|
77 |
break; |
|
78 |
case "02": |
|
79 |
result = "B"; |
|
80 |
break; |
|
81 |
case "03": |
|
82 |
result = "C"; |
|
83 |
break; |
|
84 |
case "04": |
|
85 |
result = "D"; |
|
86 |
break; |
|
87 |
case "05": |
|
88 |
result = "E"; |
|
89 |
break; |
|
90 |
case "06": |
|
91 |
result = "F"; |
|
92 |
break; |
|
93 |
case "07": |
|
94 |
result = "G"; |
|
95 |
break; |
|
96 |
case "08": |
|
97 |
result = "H"; |
|
98 |
break; |
|
99 |
case "09": |
|
100 |
result = "I"; |
|
101 |
break; |
|
102 |
case "10": |
|
103 |
result = "J"; |
|
104 |
break; |
|
105 |
case "11": |
|
106 |
result = "K"; |
|
107 |
break; |
|
108 |
case "12": |
|
109 |
result = "L"; |
|
110 |
break; |
|
111 |
default: |
|
112 |
result = ""; |
|
113 |
} |
|
114 |
|
|
115 |
return result; |
|
116 |
} |
|
117 |
} |