|
|
|
@ -2460,7 +2460,7 @@ public class CommonService : ICommonService
|
|
|
|
|
case "number": //计数,流水号
|
|
|
|
|
var prefix = sequenceNewNo;//前缀
|
|
|
|
|
businessSeq = await tenantDb.Queryable<BusinessSequence>().Where(x => x.SequenceId == sequence.Id && x.Prefix == prefix).FirstAsync();
|
|
|
|
|
int num = CurrentReset(sequence, item, businessSeq, tenantDb);
|
|
|
|
|
int num = CurrentReset(sequence, item, businessSeq, tenantDb,date);
|
|
|
|
|
//计数拼接
|
|
|
|
|
sequenceNewNo += NumberingSeqRule(item, num).ToString();
|
|
|
|
|
//更新当前序号,
|
|
|
|
@ -2501,7 +2501,7 @@ public class CommonService : ICommonService
|
|
|
|
|
sequence.CurrentCode = sequenceNewNo;
|
|
|
|
|
sequence.CurrentReset = DateTime.Now.ToString("yyyyMMdd");
|
|
|
|
|
businessSeq.CurrentCode = sequenceNewNo;
|
|
|
|
|
businessSeq.CurrentReset = DateTime.Now.ToString("yyyyMMdd");
|
|
|
|
|
businessSeq.CurrentReset = date.HasValue ? date.Value.ToString("yyyyMMdd") : DateTime.Now.ToString("yyyyMMdd");
|
|
|
|
|
|
|
|
|
|
await db.Updateable(sequence).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
@ -2674,7 +2674,7 @@ public class CommonService : ICommonService
|
|
|
|
|
/// <param name="seq"></param>
|
|
|
|
|
/// <param name="seqRule"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
private static int CurrentReset(SysSequence seq, SysSequenceRule seqRule, BusinessSequence businessSeq, SqlSugarScopeProvider tenantDb)
|
|
|
|
|
private static int CurrentReset(SysSequence seq, SysSequenceRule seqRule, BusinessSequence businessSeq, SqlSugarScopeProvider tenantDb, DateTime? date = null)
|
|
|
|
|
{
|
|
|
|
|
int newNo = 0, ruleNo = 0;
|
|
|
|
|
|
|
|
|
@ -2687,20 +2687,20 @@ public class CommonService : ICommonService
|
|
|
|
|
newNo = 1;
|
|
|
|
|
// Log4NetHelper.Error(ex.Message, ex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var DataVar = date.HasValue ? date.Value : DateTime.Now;
|
|
|
|
|
switch (seq.SequenceReset)
|
|
|
|
|
{
|
|
|
|
|
case "D": //每天重置
|
|
|
|
|
if (!string.IsNullOrEmpty(seq.CurrentReset) && seq.CurrentReset != DateTime.Now.ToString("yyyyMMdd"))
|
|
|
|
|
if (businessSeq.IsNotNull() && !string.IsNullOrEmpty(businessSeq.CurrentReset) && businessSeq.CurrentReset != DataVar.ToString("yyyyMMdd"))
|
|
|
|
|
{
|
|
|
|
|
newNo = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case "M": //每月重置
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(seq.CurrentReset))
|
|
|
|
|
if (businessSeq.IsNotNull() && !string.IsNullOrWhiteSpace(businessSeq.CurrentReset))
|
|
|
|
|
{
|
|
|
|
|
if (!seq.CurrentReset.Contains(DateTime.Now.ToString("yyyyMM")))
|
|
|
|
|
if (!businessSeq.CurrentReset.Contains(DataVar.ToString("yyyyMM")))
|
|
|
|
|
{
|
|
|
|
|
newNo = ruleNo;
|
|
|
|
|
}
|
|
|
|
@ -2712,9 +2712,9 @@ public class CommonService : ICommonService
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case "Y": //每年重置
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(seq.CurrentReset))
|
|
|
|
|
if (businessSeq.IsNotNull() && !string.IsNullOrWhiteSpace(businessSeq.CurrentReset))
|
|
|
|
|
{
|
|
|
|
|
if (!seq.CurrentReset.Contains(DateTime.Now.ToString("yyyy")))
|
|
|
|
|
if (!businessSeq.CurrentReset.Contains(DataVar.ToString("yyyy")))
|
|
|
|
|
{
|
|
|
|
|
newNo = ruleNo;
|
|
|
|
|
}
|
|
|
|
|