You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
112 lines
3.1 KiB
112 lines
3.1 KiB
4 years ago
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Linq;
|
||
|
using System.Text;
|
||
|
using System.Threading.Tasks;
|
||
|
|
||
|
namespace QMAPP.FJC.DAL.BZD
|
||
|
{
|
||
|
class BarcodeRule
|
||
|
{
|
||
|
//barcode标识头3位
|
||
|
private string _barcodeFirst = "052";
|
||
|
//barcode公司编号3位
|
||
|
private string _barcodeCompnentCode = "111";
|
||
|
//车型1位
|
||
|
private string _VehicleType = "A";
|
||
|
//配置、颜色1位
|
||
|
private string _ConfigColor = "3";
|
||
|
//年1位
|
||
|
private string _Year = "J";
|
||
|
//月1位
|
||
|
private string _Mon = "4";
|
||
|
|
||
|
//barcode流水号3位
|
||
|
private string _barcodeSequence = "001";
|
||
|
|
||
|
public string barcodeFirst
|
||
|
{
|
||
|
get { return _barcodeFirst;}
|
||
|
set { _barcodeFirst = value; }
|
||
|
}
|
||
|
//barcode公司编号3位
|
||
|
public string barcodeCompnentCode
|
||
|
{
|
||
|
get { return _barcodeCompnentCode; }
|
||
|
set { _barcodeCompnentCode = value; }
|
||
|
}
|
||
|
//车型1位
|
||
|
public string VehicleType
|
||
|
{
|
||
|
get { return _VehicleType; }
|
||
|
set { _VehicleType = value; }
|
||
|
}
|
||
|
//配置、颜色1位
|
||
|
public string ConfigColor
|
||
|
{
|
||
|
get { return _ConfigColor; }
|
||
|
set { _ConfigColor = value; }
|
||
|
}
|
||
|
//年1位
|
||
|
public string Year
|
||
|
{
|
||
|
get { return _Year; }
|
||
|
set { _Year = value; }
|
||
|
}
|
||
|
//月1位
|
||
|
public string Mon
|
||
|
{
|
||
|
get { return _Mon; }
|
||
|
set { _Mon = value; }
|
||
|
}
|
||
|
|
||
|
public string barcodeSequence
|
||
|
{
|
||
|
get { return _barcodeSequence.PadLeft(3, '0'); }
|
||
|
set { _barcodeSequence = value; }
|
||
|
}
|
||
|
|
||
|
//将barcode所有字符转为10进制相加,求和
|
||
|
public int Xsum(string str,int toX)
|
||
|
{
|
||
|
int sum = 0;
|
||
|
for (int i = 0; i < str.Length; i++)
|
||
|
{
|
||
|
sum = sum + DecimalToCharX.CharXTodecimal(str[i].ToString(), toX);
|
||
|
}
|
||
|
return sum;
|
||
|
}
|
||
|
|
||
|
//barcode校验位
|
||
|
public string getCheckBit(string barcodeTemp)
|
||
|
{
|
||
|
int sum = 0;
|
||
|
int remainder = 0;
|
||
|
sum = Xsum(barcodeTemp, 43);
|
||
|
//将求和值除以43,得到余数作为校验位
|
||
|
remainder = sum % 43;
|
||
|
//将校验位转为43进制
|
||
|
return DecimalToCharX.decimalToCharX(remainder, 43);
|
||
|
}
|
||
|
public string barcode
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
string barcodeTemp = "";
|
||
|
barcodeTemp = string.Format("{0}{1}{2}{3}{4}{5}{6}{7}",
|
||
|
barcodeFirst,
|
||
|
" ",
|
||
|
barcodeCompnentCode,
|
||
|
VehicleType,
|
||
|
ConfigColor,
|
||
|
Year,
|
||
|
Mon,
|
||
|
barcodeSequence);//_barcodeFirst + " " + _barcodeCompnentCode + _VehicleType + ConfigColor + _Year + _Mon + barcodeSequence;
|
||
|
return barcodeTemp + getCheckBit(barcodeTemp);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|