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