package cn.stylefeng.guns.plcserver.opc.unit;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import java.util.Calendar;
|
|
public class SFCCodeTool {
|
|
public static String marketAreaCode = ""; //市场区域编码
|
public static String softwareVersionCode = ""; //软件版本编码
|
public static String productCompanyCode = ""; //产品公司编码
|
public static String RunningWaterNumber = "0000"; //流水号
|
public static String SerialNumbers = "0000"; //序列号
|
/* public static String Years = String.valueOf(calendar.get(Calendar.YEAR)); //年份
|
public static String Months = StringUtils.leftPad(String.valueOf(calendar.get(Calendar.MONTH) + 1),2, "0"); //月份
|
public static String Dates = StringUtils.leftPad(String.valueOf(calendar.get(Calendar.DATE)),2, "0"); //日期*/
|
|
|
//头部拼接
|
public static String C1_36V_HEAD_STRING = "T19000E001";//T1标识产品型号MTB、90表示产品扭矩、00表示 36V 6V3W、E表示国家(这里是欧洲,其他的待定)、001表示软件基础版
|
public static String C1_48V_HEAD_STRING = "T19000E001";//T1标识产品型号MTB、90表示产品扭矩、00表示 36V 6V3W、E表示国家(这里是欧洲,其他的待定)、001表示软件基础版
|
public static String T1_36V_HEAD_STRING = "T19000E001";//T1标识产品型号MTB、90表示产品扭矩、00表示 36V 6V3W、E表示国家(这里是欧洲,其他的待定)、001表示软件基础版
|
public static String T1_48V_HEAD_STRING = "T19000E001";//T1标识产品型号MTB、90表示产品扭矩、00表示 36V 6V3W、E表示国家(这里是欧洲,其他的待定)、001表示软件基础版
|
|
public static String CENTER_STRING = "A1";//中间拼接
|
|
public static String TAIL_STRING = "";//尾部拼接
|
|
public static void main(String[] args){
|
createCodingRulesSFC("1","1","1");
|
}
|
/**
|
* 单体编号追溯
|
* @param softwareVersionCode 软件版本编码(型号+扭矩+差异款+国家地区+软件版本)
|
* @param productCompanyCode 生产基地编码(生产基地代码+产线代码)
|
* @param serialNumbers 序列号
|
* @return
|
*/
|
|
public static String createCodingRulesSFC(String softwareVersionCode,String productCompanyCode,String serialNumbers){
|
Calendar calendar = Calendar.getInstance();
|
String Years = String.valueOf(calendar.get(Calendar.YEAR)); //年份
|
String Months = StringUtils.leftPad(String.valueOf(calendar.get(Calendar.MONTH) + 1),2, "0"); //月份
|
String Dates = StringUtils.leftPad(String.valueOf(calendar.get(Calendar.DATE)),2, "0"); //日期
|
StringBuffer result = new StringBuffer();
|
|
String headString = "";
|
/* if("".equals(productCode)){
|
headString = C1_36V_HEAD_STRING;
|
}else if ("".equals(productCode)){
|
headString = C1_48V_HEAD_STRING;
|
}else if ("".equals(productCode)){
|
headString = C1_48V_HEAD_STRING;
|
}else if ("".equals(productCode)){
|
headString = C1_48V_HEAD_STRING;
|
}else {
|
return "";
|
}*/
|
|
|
result.append(softwareVersionCode);//产品型号
|
result.append(Years.substring(Years.length()-2));//年
|
result.append(replaceMonths(Months));
|
result.append(Dates);//日
|
result.append(productCompanyCode);//班次
|
result.append(serialNumbers);//序列号
|
result.append("B");//产线
|
|
return result.toString();
|
}
|
|
public static String replaceMonths(String months){
|
String result = "";
|
switch(months) {
|
case "01":
|
result = "A";
|
break;
|
case "02":
|
result = "B";
|
break;
|
case "03":
|
result = "C";
|
break;
|
case "04":
|
result = "D";
|
break;
|
case "05":
|
result = "E";
|
break;
|
case "06":
|
result = "F";
|
break;
|
case "07":
|
result = "G";
|
break;
|
case "08":
|
result = "H";
|
break;
|
case "09":
|
result = "I";
|
break;
|
case "10":
|
result = "J";
|
break;
|
case "11":
|
result = "K";
|
break;
|
case "12":
|
result = "L";
|
break;
|
default:
|
result = "";
|
}
|
|
return result;
|
}
|
}
|