From 266e4bf654c55ce2f7e9271048e4625f1b8b49f6 Mon Sep 17 00:00:00 2001
From: heshaofeng <heshaofeng@hnkhzn.com>
Date: 星期一, 29 十二月 2025 14:36:08 +0800
Subject: [PATCH] Merge branch 'htq20251215' of http://115.159.85.185:8098/r/ZhongRui/ALDbanyunxiangmu into htq20251215
---
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_BasicService/BasicService.cs | 77 ++++++++++++++++++++------------------
1 files changed, 41 insertions(+), 36 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_BasicService/BasicService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_BasicService/BasicService.cs"
index d59f13f..3be1d07 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_BasicService/BasicService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_BasicService/BasicService.cs"
@@ -40,50 +40,55 @@
}
#region
+
+ static object lockObj = new object();
public string CreateCodeByRule(string ruleCode)
{
- string code = string.Empty;
- DateTime dataTime = DateTime.Now;
- DateTime now = DateTime.Now;
-
- try
+ lock (lockObj)
{
- Dt_CodeRuleConfig ruleConfig = _unitOfWorkManage.Db.Queryable<Dt_CodeRuleConfig>().Where(x => x.RuleCode == ruleCode).First();
- if (ruleConfig.ModifyDate != null)
- {
- dataTime = ruleConfig.ModifyDate.Value;
- }
- else
- {
- dataTime = ruleConfig.CreateDate;
- }
+ string code = string.Empty;
+ DateTime dataTime = DateTime.Now;
+ DateTime now = DateTime.Now;
- if (now.Year == dataTime.Year && now.Month == dataTime.Month && now.Day == dataTime.Day)
+ try
{
- now = dataTime;
- ruleConfig.CurrentVal = Convert.ToInt32(ruleConfig.CurrentVal) + 1;
+ Dt_CodeRuleConfig ruleConfig = _unitOfWorkManage.Db.Queryable<Dt_CodeRuleConfig>().Where(x => x.RuleCode == ruleCode).First();
+ if (ruleConfig.ModifyDate != null)
+ {
+ dataTime = ruleConfig.ModifyDate.Value;
+ }
+ else
+ {
+ dataTime = ruleConfig.CreateDate;
+ }
+
+ if (now.Year == dataTime.Year && now.Month == dataTime.Month && now.Day == dataTime.Day)
+ {
+ now = dataTime;
+ ruleConfig.CurrentVal = Convert.ToInt32(ruleConfig.CurrentVal) + 1;
+ }
+ else
+ {
+ ruleConfig.CurrentVal = 1;
+ }
+
+ ruleConfig.ModifyDate = DateTime.Now;
+
+ code = ruleConfig.Format;
+ code = code.Replace($"[{CodeFormatTypeEnum.YYYY}]", now.Year.ToString().PadLeft(4, '0'));
+ code = code.Replace($"[{CodeFormatTypeEnum.MM}]", now.Month.ToString().PadLeft(2, '0'));
+ code = code.Replace($"[{CodeFormatTypeEnum.DD}]", now.Day.ToString().PadLeft(2, '0'));
+ code = code.Replace($"[{CodeFormatTypeEnum.ST}]", ruleConfig.StartStr.ToString());
+ code = code.Replace($"[{CodeFormatTypeEnum.NUM}]", ruleConfig.CurrentVal.ToString().PadLeft(ruleConfig.Length, '0'));
+
+ _unitOfWorkManage.Db.Updateable(ruleConfig).ExecuteCommand();
}
- else
+ catch (Exception ex)
{
- ruleConfig.CurrentVal = 1;
+ throw new Exception(ex.Message);
}
-
- ruleConfig.ModifyDate = DateTime.Now;
-
- code = ruleConfig.Format;
- code = code.Replace($"[{CodeFormatTypeEnum.YYYY}]", now.Year.ToString().PadLeft(4, '0'));
- code = code.Replace($"[{CodeFormatTypeEnum.MM}]", now.Month.ToString().PadLeft(2, '0'));
- code = code.Replace($"[{CodeFormatTypeEnum.DD}]", now.Day.ToString().PadLeft(2, '0'));
- code = code.Replace($"[{CodeFormatTypeEnum.ST}]", ruleConfig.StartStr.ToString());
- code = code.Replace($"[{CodeFormatTypeEnum.NUM}]", ruleConfig.CurrentVal.ToString().PadLeft(ruleConfig.Length, '0'));
-
- _unitOfWorkManage.Db.Updateable(ruleConfig).ExecuteCommand();
+ return code;
}
- catch (Exception ex)
- {
-
- }
- return code;
}
#endregion
@@ -109,7 +114,7 @@
throw new Exception($"杞崲鍚庡崟浣嶄笉鑳戒负绌�");
}
- decimal ratio = 0;
+ decimal ratio = 1;
if (fromUnit.Trim().ToLower() == toUnit.Trim().ToLower())
{
--
Gitblit v1.9.3