webapi + task
This commit is contained in:
1 parent
12e16e0c6c
commit
5252e20601
500 files changed
+281
-27576
No files matched your search
@@ -194,59 +194,5 @@ namespace HHWMS.Web
|
||||
}
|
||||
|
||||
#endregion delete
|
||||
|
||||
public string GetSerialNumber(string prefix, int length = 4)
|
||||
{
|
||||
int seq = 0;
|
||||
using (var tran = _data.BeginTransaction())
|
||||
{
|
||||
try
|
||||
{
|
||||
var syscount = FindSingle<SysCount>(x => x.Prefix == prefix);
|
||||
if (syscount == null)
|
||||
{
|
||||
syscount = new SysCount
|
||||
{
|
||||
Prefix = prefix,
|
||||
Value = 1,
|
||||
UpdateTime = DateTime.Now
|
||||
};
|
||||
Add(syscount);
|
||||
seq = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 判断日期是否是当天,否则从1开始
|
||||
if (DateTime.Now.Day == syscount.UpdateTime.Value.Day)
|
||||
{
|
||||
_data.Set<SysCount>().Where(x => x.Prefix == prefix)
|
||||
.Update(x => new SysCount
|
||||
{
|
||||
Value = x.Value + 1,
|
||||
UpdateTime = DateTime.Now
|
||||
});
|
||||
seq = FindSingle<SysCount>(x => x.Prefix == prefix).Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
_data.Set<SysCount>().Where(x => x.Prefix == prefix)
|
||||
.Update(x => new SysCount
|
||||
{
|
||||
Value = 1,
|
||||
UpdateTime = DateTime.Now
|
||||
});
|
||||
seq = 1;
|
||||
}
|
||||
}
|
||||
tran.Commit();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
tran.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
return prefix + DateTime.Now.ToString("yyyyMMdd") + seq.ToString().PadLeft(length, '0');
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user