|
|
@ -78,75 +78,86 @@ namespace WY.NewJit |
|
|
|
/// <returns></returns>
|
|
|
|
public static string ToSerialNumStr(DateTime? onlineTime, int? hostSN, string m100_r100, string productLine) |
|
|
|
{ |
|
|
|
if (onlineTime == null) |
|
|
|
{ |
|
|
|
throw new Exception("ToSerialNumStr上线时间不能为空:" + hostSN.ToString()); |
|
|
|
} |
|
|
|
if (hostSN == null) |
|
|
|
{ |
|
|
|
throw new Exception("ToSerialNumStr大众顺序号不能为空!"); |
|
|
|
} |
|
|
|
if (m100_r100.IsNullOrEmpty()) |
|
|
|
{ |
|
|
|
throw new Exception("ToSerialNumStr m100_r100参数不能为空!"); |
|
|
|
} |
|
|
|
if (productLine.IsNullOrEmpty()) |
|
|
|
{ |
|
|
|
throw new Exception("ToSerialNumStr productLine参数不能为空!"); |
|
|
|
throw new Exception("ToSerialNumStr大众顺序号不能为空!!"); |
|
|
|
} |
|
|
|
/* |
|
|
|
1.SerialNumStr在分钟后面插入00 |
|
|
|
2.取报文中的上线时间、大众顺序号,如果缓存分钟键没有,则增加一个 |
|
|
|
3.如果缓存中有该分钟键,取最大“大众顺序号”更新 |
|
|
|
4.如果缓存中有该分钟键,并且比当前上线时间的“大众顺序号”大1000以上,则 01 |
|
|
|
5.分钟键超过2000时,保留1000 |
|
|
|
6.字典按产线分组 |
|
|
|
*/ |
|
|
|
string secondPart = "00"; |
|
|
|
return hostSN.ToString().PadLeft(6, '0'); ; //红旗顺序号不重复,按红旗顺序号排序
|
|
|
|
|
|
|
|
//if (onlineTime == null)
|
|
|
|
//{
|
|
|
|
// throw new Exception("ToSerialNumStr上线时间不能为空:" + hostSN.ToString());
|
|
|
|
//}
|
|
|
|
//if (hostSN == null)
|
|
|
|
//{
|
|
|
|
// throw new Exception("ToSerialNumStr大众顺序号不能为空!");
|
|
|
|
//}
|
|
|
|
//if (m100_r100.IsNullOrEmpty())
|
|
|
|
//{
|
|
|
|
// throw new Exception("ToSerialNumStr m100_r100参数不能为空!");
|
|
|
|
//}
|
|
|
|
//if (productLine.IsNullOrEmpty())
|
|
|
|
//{
|
|
|
|
// throw new Exception("ToSerialNumStr productLine参数不能为空!");
|
|
|
|
//}
|
|
|
|
///*
|
|
|
|
//1.SerialNumStr在分钟后面插入00
|
|
|
|
//2.取报文中的上线时间、大众顺序号,如果缓存分钟键没有,则增加一个
|
|
|
|
//3.如果缓存中有该分钟键,取最大“大众顺序号”更新
|
|
|
|
//4.如果缓存中有该分钟键,并且比当前上线时间的“大众顺序号”大1000以上,则 01
|
|
|
|
//5.分钟键超过2000时,保留1000
|
|
|
|
//6.字典按产线分组
|
|
|
|
//*/
|
|
|
|
//string secondPart = "00";
|
|
|
|
|
|
|
|
string pl = (m100_r100?.Trim() + productLine?.Trim()).ToLower(); |
|
|
|
Dictionary<DateTime, int> childDic = GetDicByPL(pl); //根据产线取子字典
|
|
|
|
//string pl = (m100_r100?.Trim() + productLine?.Trim()).ToLower();
|
|
|
|
//Dictionary<DateTime, int> childDic = GetDicByPL(pl); //根据产线取子字典
|
|
|
|
|
|
|
|
DateTime curOnlineTime = (DateTime)onlineTime; |
|
|
|
int curHostSN = (int)hostSN; |
|
|
|
//DateTime curOnlineTime = (DateTime)onlineTime;
|
|
|
|
//int curHostSN = (int)hostSN;
|
|
|
|
|
|
|
|
if (childDic.ContainsKey(curOnlineTime)) //缓存中有
|
|
|
|
{ |
|
|
|
int cacheHostSN = childDic[curOnlineTime]; |
|
|
|
//if (childDic.ContainsKey(curOnlineTime)) //缓存中有
|
|
|
|
//{
|
|
|
|
// int cacheHostSN = childDic[curOnlineTime];
|
|
|
|
|
|
|
|
if (curHostSN > cacheHostSN) |
|
|
|
{ |
|
|
|
childDic[curOnlineTime] = curHostSN; //取最大“大众顺序号”更新
|
|
|
|
} |
|
|
|
//大1000以上,则 01
|
|
|
|
//202309251350 - 00 - 51999
|
|
|
|
//差1000以上
|
|
|
|
//202309251350 - 01 - 50001
|
|
|
|
//202309251350 - 01 - 50002
|
|
|
|
//202309251351 - 00 - 50003
|
|
|
|
if (cacheHostSN - curHostSN >= 1000) |
|
|
|
{ |
|
|
|
secondPart = "01"; |
|
|
|
} |
|
|
|
} |
|
|
|
else //缓存中没有
|
|
|
|
{ |
|
|
|
childDic.Add(curOnlineTime, curHostSN); //添加缓存
|
|
|
|
} |
|
|
|
return ((DateTime)onlineTime).ToString("yyyyMMddHHmm") + secondPart + hostSN.ToString().PadLeft(5, '0'); |
|
|
|
// if (curHostSN > cacheHostSN)
|
|
|
|
// {
|
|
|
|
// childDic[curOnlineTime] = curHostSN; //取最大“大众顺序号”更新
|
|
|
|
// }
|
|
|
|
// //大1000以上,则 01
|
|
|
|
// //202309251350 - 00 - 51999
|
|
|
|
// //差1000以上
|
|
|
|
// //202309251350 - 01 - 50001
|
|
|
|
// //202309251350 - 01 - 50002
|
|
|
|
// //202309251351 - 00 - 50003
|
|
|
|
// if (cacheHostSN - curHostSN >= 1000)
|
|
|
|
// {
|
|
|
|
// secondPart = "01";
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
//else //缓存中没有
|
|
|
|
//{
|
|
|
|
// childDic.Add(curOnlineTime, curHostSN); //添加缓存
|
|
|
|
//}
|
|
|
|
//return ((DateTime)onlineTime).ToString("yyyyMMddHHmm") + secondPart + hostSN.ToString().PadLeft(5, '0');
|
|
|
|
} |
|
|
|
|
|
|
|
public static string ToSerialNumStr(DateTime? onlineTime, int? hostSN) |
|
|
|
{ |
|
|
|
if (onlineTime == null) |
|
|
|
{ |
|
|
|
throw new Exception("ToSerialNumStr上线时间不能为空:" + hostSN.ToString()); |
|
|
|
} |
|
|
|
if (hostSN == null) |
|
|
|
{ |
|
|
|
throw new Exception("ToSerialNumStr大众顺序号不能为空!"); |
|
|
|
} |
|
|
|
return ((DateTime)onlineTime).ToString("yyyyMMddHHmmss") + hostSN.ToString().PadLeft(5, '0'); |
|
|
|
return hostSN.ToString().PadLeft(6, '0'); ; //红旗顺序号不重复,按红旗顺序号排序
|
|
|
|
//if (onlineTime == null)
|
|
|
|
//{
|
|
|
|
// throw new Exception("ToSerialNumStr上线时间不能为空:" + hostSN.ToString());
|
|
|
|
//}
|
|
|
|
//if (hostSN == null)
|
|
|
|
//{
|
|
|
|
// throw new Exception("ToSerialNumStr大众顺序号不能为空!");
|
|
|
|
//}
|
|
|
|
//return ((DateTime)onlineTime).ToString("yyyyMMddHHmmss") + hostSN.ToString().PadLeft(5, '0');
|
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
@ -158,23 +169,29 @@ namespace WY.NewJit |
|
|
|
/// <exception cref="Exception"></exception>
|
|
|
|
public static string ToSerialNumStr(string priorSerialNumStr, int? hostSN) |
|
|
|
{ |
|
|
|
if (priorSerialNumStr == null) |
|
|
|
{ |
|
|
|
throw new Exception("ToSerialNumStr上一个排序字段值不能为空:" + priorSerialNumStr); |
|
|
|
} |
|
|
|
if (hostSN == null) |
|
|
|
{ |
|
|
|
throw new Exception("ToSerialNumStr大众顺序号不能为空!"); |
|
|
|
} |
|
|
|
if (priorSerialNumStr.Length == 17 || priorSerialNumStr.Length == 19) |
|
|
|
{ } |
|
|
|
else |
|
|
|
{ |
|
|
|
throw new Exception("priorSerialNumStr不是17或19位!"); |
|
|
|
} |
|
|
|
string prefix = priorSerialNumStr.Substring(0, priorSerialNumStr.Length - 5); |
|
|
|
return hostSN.ToString().PadLeft(6, '0'); //红旗顺序号不重复,按红旗顺序号排序
|
|
|
|
|
|
|
|
//if (priorSerialNumStr == null)
|
|
|
|
//{
|
|
|
|
// throw new Exception("ToSerialNumStr上一个排序字段值不能为空:" + priorSerialNumStr);
|
|
|
|
//}
|
|
|
|
//if (hostSN == null)
|
|
|
|
//{
|
|
|
|
// throw new Exception("ToSerialNumStr大众顺序号不能为空!");
|
|
|
|
//}
|
|
|
|
//if (priorSerialNumStr.Length == 17 || priorSerialNumStr.Length == 19)
|
|
|
|
//{ }
|
|
|
|
//else
|
|
|
|
//{
|
|
|
|
// throw new Exception("priorSerialNumStr不是17或19位!");
|
|
|
|
//}
|
|
|
|
//string prefix = priorSerialNumStr.Substring(0, priorSerialNumStr.Length - 5);
|
|
|
|
|
|
|
|
return prefix + hostSN.ToString().PadLeft(5, '0'); |
|
|
|
//return prefix + hostSN.ToString().PadLeft(5, '0');
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|