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