webapi + task

This commit is contained in:
zhougf committed 2024-06-20 12:29:49 +08:00
1 parent 12e16e0c6c
commit 5252e20601
500 files changed
+281 -27576

No files matched your search

-54
View File
@@ -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');
}
}
}