ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.878.3237/CodeChunks.dbBinary files differ
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.878.3237/CodeChunks.db-shmBinary files differ
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.878.3237/CodeChunks.db-walBinary files differ
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.878.3237/SemanticSymbols.dbBinary files differ
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.878.3237/SemanticSymbols.db-shmBinary files differ
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.878.3237/SemanticSymbols.db-walBinary files differ
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_AllocateService/AllocateService.cs
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,24 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using WIDESEA_Core.BaseRepository; using WIDESEA_Core.BaseServices; using WIDESEA_IAllocateService; using WIDESEA_Model.Models; using WIDESEA_Model.Models.Allocate; namespace WIDESEA_AllocateService { public partial class AllocateService : ServiceBase<Dt_AllocateOrder, IRepository<Dt_AllocateOrder>>, IAllocateService { public AllocateService(IRepository<Dt_AllocateOrder> BaseDal) : base(BaseDal) { } public IRepository<Dt_AllocateOrder> Repository => BaseDal; } } ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_AllocateService/WIDESEA_AllocateService.csproj
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,15 @@ <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>net6.0</TargetFramework> <ImplicitUsings>enable</ImplicitUsings> <Nullable>enable</Nullable> </PropertyGroup> <ItemGroup> <ProjectReference Include="..\WIDESEA_Core\WIDESEA_Core.csproj" /> <ProjectReference Include="..\WIDESEA_IAllocateService\WIDESEA_IAllocateService.csproj" /> <ProjectReference Include="..\WIDESEA_Model\WIDESEA_Model.csproj" /> </ItemGroup> </Project> ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_BasicService/DailySequenceService.cs
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,245 @@ using Microsoft.Extensions.Caching.Memory; using Microsoft.Extensions.Logging; using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime; using SqlSugar; using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using WIDESEA_Core.BaseRepository; using WIDESEA_Core.BaseServices; using WIDESEA_IBasicService; using WIDESEA_Model.Models; using WIDESEA_Model.Models.Basic; namespace WIDESEA_BasicService { public class DailySequenceService : ServiceBase<DT_DailySequence, IRepository<DT_DailySequence>>, IDailySequenceService { private readonly ILogger<DailySequenceService> _logger; private readonly IMemoryCache _cache; private readonly SemaphoreSlim _lock = new(1, 1); private readonly IUnitOfWorkManage _unitOfWorkManage; public DailySequenceService(IRepository<DT_DailySequence> BaseDal, ILogger<DailySequenceService> logger, IMemoryCache cache, IUnitOfWorkManage unitOfWorkManage) : base(BaseDal) { _logger = logger; _cache = cache; _unitOfWorkManage = unitOfWorkManage; } public IRepository<DT_DailySequence> Repository => BaseDal; public async Task<int> GetNextSequenceAsync() { return await GetNextSequenceAsync("MESBarcode"); } public async Task<int> GetNextSequence2Async(string sequenceKey) { var today = DateTime.Today; var cacheKey = $"DailySequence_{sequenceKey}_{today:yyyyMMdd}"; await _lock.WaitAsync(); try { // å æ£æ¥ç¼å if (_cache.TryGetValue(cacheKey, out int currentValue)) { currentValue++; _cache.Set(cacheKey, currentValue, TimeSpan.FromHours(24)); return currentValue; } // ç¼å䏿²¡æï¼ä»æ°æ®åºè·åæå建 var result= await Repository.Db.Ado.UseTranAsync(async () => { // æ¸ çæ¨å¤©çè®°å½ var yesterday = today.AddDays(-1); await Repository.Db.Deleteable<DT_DailySequence>() .Where(x => x.SequenceDate == yesterday && x.SequenceKey == sequenceKey) .ExecuteCommandAsync(); // æ¥æ¾æå建ä»å¤©çè®°å½ var sequence = await Repository.Db.Queryable<DT_DailySequence>() .Where(x => x.SequenceDate == today && x.SequenceKey == sequenceKey) .With(SqlWith.UpdLock) .FirstAsync(); int nextValue; if (sequence == null) { sequence = new DT_DailySequence { SequenceDate = today, SequenceKey = sequenceKey, CurrentValue = 1, }; await Repository.Db.Insertable(sequence).ExecuteReturnEntityAsync(); nextValue = 1; } else { nextValue = sequence.CurrentValue + 1; sequence.CurrentValue = nextValue; await Repository.Db.Updateable(sequence).ExecuteCommandAsync(); } // 设置ç¼å _cache.Set(cacheKey, nextValue, TimeSpan.FromHours(24)); return nextValue; }); return result.Data; } catch (Exception ex) { _logger.LogError(ex, "è·ååºåå·å¤±è´¥ï¼SequenceKey: {SequenceKey}", sequenceKey); throw; } finally { _lock.Release(); } } public async Task<int> GetNextSequenceAsync(string sequenceKey) { var today = DateTime.Today; var cacheKey = $"DailySequence_{sequenceKey}_{today:yyyyMMdd}"; await _lock.WaitAsync(); try { // æ£æ¥ç¼å䏿¯å¦æä»å¤©çåºåå¼ if (!_cache.TryGetValue(cacheKey, out int currentValue)) { // ç¼å䏿²¡æï¼ä»æ°æ®åºè·åæå建 currentValue = await GetOrCreateSequenceFromDatabase(today, sequenceKey); // 设置ç¼åï¼è¿ææ¶é´ä¸ºä»å¤©ç»æ var _cacheOptions = new MemoryCacheEntryOptions { AbsoluteExpiration = today.AddDays(1) }; _cache.Set(cacheKey, currentValue, _cacheOptions); return currentValue; } // ç¼åä¸åå¨ï¼éå¢å¹¶æ´æ°ç¼å currentValue++; var cacheOptions = new MemoryCacheEntryOptions { AbsoluteExpiration = today.AddDays(1) }; _cache.Set(cacheKey, currentValue, cacheOptions); // 弿¥æ´æ°å°æ°æ®åº _ = Task.Run(async () => { try { await UpdateSequenceInDatabase(today, sequenceKey, currentValue); } catch (Exception ex) { _logger.LogWarning(ex, "弿¥æ´æ°åºåå°æ°æ®åºå¤±è´¥ï¼SequenceKey: {SequenceKey}", sequenceKey); } }); return currentValue; } finally { _lock.Release(); } } private async Task<int> GetOrCreateSequenceFromDatabase(DateTime date, string sequenceKey) { var result= await Repository.Db.Ado.UseTranAsync(async () => { var sequence = await Repository.Db.Queryable<DT_DailySequence>() .Where(x => x.SequenceDate == date && x.SequenceKey == sequenceKey) .With(SqlWith.UpdLock) .FirstAsync(); if (sequence == null) { sequence = new DT_DailySequence { SequenceDate = date, SequenceKey = sequenceKey, CurrentValue = 1, }; await Repository.Db.Insertable(sequence).ExecuteReturnEntityAsync(); return 1; } else { var nextValue = sequence.CurrentValue + 1; sequence.CurrentValue = nextValue; await Repository.Db.Updateable(sequence).ExecuteCommandAsync(); return nextValue; } }) ; return result.Data; } private async Task UpdateSequenceInDatabase(DateTime date, string sequenceKey, int value) { var sequence = await Repository.Db.Queryable<DT_DailySequence>() .Where(x => x.SequenceDate == date && x.SequenceKey == sequenceKey) .FirstAsync(); if (sequence != null) { sequence.CurrentValue = value; await Repository.Db.Updateable(sequence).ExecuteCommandAsync(); } else { // å¦ææ°æ®åºè®°å½ä¸åå¨ï¼åå建 sequence = new DT_DailySequence { SequenceDate = date, SequenceKey = sequenceKey, CurrentValue = value, }; await Repository.Db.Insertable(sequence).ExecuteCommandAsync(); } } public async Task CleanOldSequencesAsync(int keepDays = 30) { try { var deleteBefore = DateTime.Today.AddDays(-keepDays); var deletedCount = await Repository.Db.Deleteable<DT_DailySequence>() .Where(x => x.SequenceDate < deleteBefore) .ExecuteCommandAsync(); for (int i = 1; i < keepDays; i++) { var cacheKey = $"DailySequence_MESBarcode_{DateTime.Now.AddDays(-i):yyyyMMdd}"; _cache.Remove(cacheKey); } _logger.LogInformation("æ¸ çäº {Count} æ¡ {Days} 天åçåºåè®°å½", deletedCount, keepDays); } catch (Exception ex) { _logger.LogError(ex, "æ¸ çæ§åºåè®°å½å¤±è´¥"); throw; } } } } ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_BasicService/ESSApiService.cs
@@ -6,6 +6,7 @@ using System.Linq; using System.Text; using System.Text.Json; using System.Threading; using System.Threading.Tasks; using WIDESEA_DTO.Basic; using WIDESEA_IBasicService; @@ -27,10 +28,17 @@ /// </summary> public async Task MoveContainerAsync(MoveContainerRequest request) { try { var url = "conveyor/moveContainer"; var result = await PostAsync<MoveContainerRequest, ApiResponse<string>>(url, request); } catch (Exception ex) { _logger.LogInformation("容卿µå¨å¤±è´¥: " + ex.Message); } } /// <summary> @@ -39,6 +47,8 @@ /// <param name="request"></param> /// <returns></returns> public async Task<bool> CreateTaskAsync(TaskModel request) { try { _logger.LogInformation("å建任å¡Request: " + JsonConvert.SerializeObject(request)); var url = "task/create"; @@ -50,11 +60,18 @@ } return false; } catch (Exception ex) { _logger.LogInformation("å建任å¡å¤±è´¥: " + ex.Message); return false; } } private async Task<TResponse> PostAsync<TRequest, TResponse>(string url, TRequest request) { string json = JsonConvert.SerializeObject(request, new JsonSerializerSettings { ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver() @@ -74,6 +91,7 @@ } return JsonConvert.DeserializeObject<TResponse>(body); } } } ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_BasicService/ErpApiService.cs
@@ -1,4 +1,5 @@ using NetTaste; using Microsoft.Extensions.Logging; using NetTaste; using Newtonsoft.Json; using Org.BouncyCastle.Ocsp; using SqlSugar.Extensions; @@ -21,13 +22,15 @@ private readonly ISupplierInfoService _supplierInfoService; private readonly IMaterialUnitService _materialUnitService; private readonly IMaterielInfoService _materielInfoService; private readonly ILogger<ErpApiService> _logger; public ErpApiService(IHttpClientFactory httpClientFactory, ISupplierInfoService supplierInfoService, IMaterialUnitService materialUnitService, IMaterielInfoService materielInfoService) public ErpApiService(IHttpClientFactory httpClientFactory, ISupplierInfoService supplierInfoService, IMaterialUnitService materialUnitService, IMaterielInfoService materielInfoService, ILogger<ErpApiService> logger) { _httpClientFactory = httpClientFactory; _supplierInfoService = supplierInfoService; _materialUnitService = materialUnitService; _materielInfoService = materielInfoService; _logger = logger; } /// <summary> @@ -36,10 +39,19 @@ /// <returns></returns> public async Task<string> GetTokenAsync() { try { var request = new TokenRequest { appId = "BG_SYSTEM", secretKey = "7e9239c1e132462a9cf03bfa342a044aMTcxODE5MzgxODI4Mw" }; var response = await PostAsync<TokenRequest, TokenResponse>("auth/getAccessToken", request, includeToken: false); var _token = response?.data?.access_token; return _token ?? ""; } catch (Exception ex) { _logger.LogInformation("ErpApiService GetTokenAsync失败: " + ex.Message); return ""; } } @@ -49,6 +61,8 @@ /// <param name="vendorCode"></param> /// <returns></returns> public async Task GetSuppliersAsync(string vendorCode = null) { try { var req = new SupplierRequest { vendorCode = vendorCode }; var result = await PostAsync<SupplierRequest, SupplierResponse>("erp/getVendorInfo", req, includeToken: true); @@ -94,6 +108,12 @@ } } } } catch (Exception ex) { _logger.LogInformation("ErpApiService GetSuppliersAsync失败: " + ex.Message); } } @@ -103,6 +123,8 @@ /// <param name="vendorCode"></param> /// <returns></returns> public async Task GetMaterialUnitAsync(string itemNo = null) { try { var req = new MaterialUnitRequest { itemNo = itemNo }; var result = await PostAsync<MaterialUnitRequest, MaterialUnitResponse>("erp/getMaterialUnit", req, true); @@ -152,9 +174,17 @@ } } } } catch (Exception ex) { _logger.LogInformation("ErpApiService GetMaterialUnitAsync 失败: " + ex.Message); } } public async Task GetMaterialInfoAsync(MaterialRequest materialRequest) { try { var first = WIDESEA_Core.Helper.AppSettings.GetValue("FirstMaterialSync").ObjToBool(); if (first) @@ -257,8 +287,13 @@ } } } catch (Exception ex) { _logger.LogInformation("ErpApiService GetMaterialInfoAsync 失败: " + ex.Message); } } private async Task<TResponse> PostAsync<TRequest, TResponse>(string url, TRequest request, string _token, bool isNullSerialize = false) { ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_BasicService/InvokeMESService.cs
@@ -1,4 +1,5 @@ using Newtonsoft.Json; using Microsoft.Extensions.Logging; using Newtonsoft.Json; using Org.BouncyCastle.Asn1.Ocsp; using System; using System.Collections.Generic; @@ -18,12 +19,13 @@ public class InvokeMESService : IInvokeMESService { private readonly IHttpClientFactory _httpClientFactory; private readonly ILogger<InvokeMESService> _logger; private string UserName = "12312"; private string Password = "1"; public InvokeMESService(IHttpClientFactory httpClientFactory) public InvokeMESService(IHttpClientFactory httpClientFactory, ILogger<InvokeMESService> logger) { _httpClientFactory = httpClientFactory; _logger = logger; } public async Task FeedbackInbound(string url, FeedbackInboundRequestModel model) ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_BasicService/LocationInfoService.cs
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_BasicService/MaterialUnitService.cs
@@ -1,4 +1,5 @@ using System; using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -13,11 +14,172 @@ { public class MaterialUnitService : ServiceBase<Dt_MaterialUnit, IRepository<Dt_MaterialUnit>>, IMaterialUnitService { private readonly ILogger<MaterialUnitService> _logger; public IRepository<Dt_MaterialUnit> Repository => BaseDal; public MaterialUnitService(IRepository<Dt_MaterialUnit> BaseDal) : base(BaseDal) public IRepository<Dt_MaterielInfo> _materielInfoRepository; public MaterialUnitService(IRepository<Dt_MaterialUnit> BaseDal, ILogger<MaterialUnitService> logger, IRepository<Dt_MaterielInfo> materielInfoRepository) : base(BaseDal) { _logger = logger; _materielInfoRepository = materielInfoRepository; } /// <summary> /// åä½è½¬æ¢ /// </summary> public async Task<decimal> ConvertAsync(string materialCode, decimal quantity, string fromUnit, string toUnit) { if (string.IsNullOrEmpty(materialCode)) throw new ArgumentException("ç©æç¼å·ä¸è½ä¸ºç©º"); if (string.IsNullOrEmpty(fromUnit) || string.IsNullOrEmpty(toUnit)) throw new ArgumentException("åä½ä¸è½ä¸ºç©º"); // 妿åä½ç¸åï¼ç´æ¥è¿å if (fromUnit.Equals(toUnit, StringComparison.OrdinalIgnoreCase)) return quantity; var ratio = await GetConversionRatioAsync(materialCode, fromUnit, toUnit); if (ratio == null) { _logger.LogWarning($"æªæ¾å°ç©æ {materialCode} ä» {fromUnit} å° {toUnit} çåä½è½¬æ¢å ³ç³»"); throw new InvalidOperationException($"æªæ¾å°ç©æ {materialCode} ä» {fromUnit} å° {toUnit} çåä½è½¬æ¢å ³ç³»"); } return quantity * ratio.Value; } /// <summary> /// éè´åä½è½¬åºååä½ /// </summary> public async Task<decimal> ConvertPurchaseToStockAsync(string materialCode, decimal quantity) { // è·åç©æä¿¡æ¯ var material = await _materielInfoRepository.Db.Queryable<Dt_MaterielInfo>() .Where(x => x.MaterielCode == materialCode) .FirstAsync(); if (material == null) { throw new ArgumentException($"æªæ¾å°ç©æç¼å·: {materialCode}"); } return await ConvertAsync(materialCode, quantity, material.purchaseUOM, material.inventoryUOM); } /// <summary> /// 颿åä½è½¬åºååä½ /// </summary> public async Task<decimal> ConvertIssueToStockAsync(string materialCode, decimal quantity) { // è·åç©æä¿¡æ¯ var material = await _materielInfoRepository.Db.Queryable<Dt_MaterielInfo>() .Where(x => x.MaterielCode == materialCode) .FirstAsync(); if (material == null) { throw new ArgumentException($"æªæ¾å°ç©æç¼å·: {materialCode}"); } return await ConvertAsync(materialCode, quantity, material.usageUOM, material.inventoryUOM); } /// <summary> /// è·ååä½è½¬æ¢æ¯ç /// </summary> public async Task<decimal?> GetConversionRatioAsync(string materialCode, string fromUnit, string toUnit) { // å°è¯ç´æ¥æ¥æ¾è½¬æ¢å ³ç³» var conversion = await Repository.Db.Queryable<Dt_MaterialUnit>() .Where(x => x.ItemNo == materialCode && x.FromUom == fromUnit && x.ToUom == toUnit) .FirstAsync(); if (conversion != null) { return conversion.Ratio; } // å°è¯æ¥æ¾åå转æ¢å ³ç³»ï¼ååæ°ï¼ var reverseConversion = await Repository.Db.Queryable<Dt_MaterialUnit>() .Where(x => x.ItemNo == materialCode && x.FromUom == toUnit && x.ToUom == fromUnit) .FirstAsync(); if (reverseConversion != null) { return 1 / reverseConversion.Ratio; } // å°è¯éè¿ä¸é´åä½ï¼åºååä½ï¼è¿è¡è½¬æ¢ var material = await _materielInfoRepository.Db.Queryable<Dt_MaterielInfo>() .Where(x => x.MaterielCode == materialCode) .FirstAsync(); if (material != null) { var stockUnit = material.inventoryUOM; // å¦æç®æ åä½å·²ç»æ¯åºååä½ï¼ç´æ¥æ¥æ¾æºåä½å°åºååä½çè½¬æ¢ if (toUnit.Equals(stockUnit, StringComparison.OrdinalIgnoreCase)) { var toStockRatio = await GetDirectRatioAsync(materialCode, fromUnit, stockUnit); if (toStockRatio != null) return toStockRatio; } // 妿æºå使¯åºååä½ï¼ç´æ¥æ¥æ¾åºååä½å°ç®æ åä½çè½¬æ¢ if (fromUnit.Equals(stockUnit, StringComparison.OrdinalIgnoreCase)) { var fromStockRatio = await GetDirectRatioAsync(materialCode, stockUnit, toUnit); if (fromStockRatio != null) return fromStockRatio; } // éè¿åºååä½è¿è¡é´æ¥è½¬æ¢ï¼fromUnit -> stockUnit -> toUnit var ratio1 = await GetDirectRatioAsync(materialCode, fromUnit, stockUnit); var ratio2 = await GetDirectRatioAsync(materialCode, stockUnit, toUnit); if (ratio1 != null && ratio2 != null) { return ratio1 * ratio2; } } return null; } /// <summary> /// è·åç´æ¥è½¬æ¢æ¯çï¼å 嫿£ååå忥æ¾ï¼ /// </summary> private async Task<decimal?> GetDirectRatioAsync(string materialCode, string fromUnit, string toUnit) { // æ£åæ¥æ¾ var conversion = await Repository.Db.Queryable<Dt_MaterialUnit>() .Where(x => x.ItemNo == materialCode && x.FromUom == fromUnit && x.ToUom == toUnit) .FirstAsync(); if (conversion != null) { return conversion.Ratio; } // ååæ¥æ¾ var reverseConversion = await Repository.Db.Queryable<Dt_MaterialUnit>() .Where(x => x.ItemNo == materialCode && x.FromUom == toUnit && x.ToUom == fromUnit) .FirstAsync(); if (reverseConversion != null) { return 1 / reverseConversion.Ratio; } return null; } } } ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_Common/LocationEnum/LocationStatusEnum.cs
@@ -23,6 +23,7 @@ [Description("éå®")] Lock = 1, /// <summary> /// æè´§éå® /// </summary> @@ -40,11 +41,10 @@ /// </summary> [Description("æè´§")] InStock = 100, /// <summary> /// 大æçéå® /// 空æç /// </summary> [Description("大æçéå®")] PalletLock = 99 [Description("空æç")] Pallet = 99 } } ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_Common/OrderEnum/InboundOrderMenu.cs
@@ -90,4 +90,71 @@ [Description("å ¶ä»å ¥åºå")] Other = 130 } /// <summary> /// åæ®ç±»åæä¸¾ /// </summary> public enum DocumentType { /// <summary> /// éè´å ¥åºå /// </summary> [Description("éè´å ¥åº")] PurchaseInbound = 11, /// <summary> /// ææ¶å /// </summary> [Description("ææ¶å")] MiscellaneousReceipt = 12, /// <summary> /// ç产éæå /// </summary> [Description("ç产éæå")] ProductionReturn = 13, /// <summary> /// å¤åéæå /// </summary> [Description("å¤åéæå")] OutsourcingReturn = 14, /// <summary> /// éå®éåºå /// </summary> [Description("éå®éåºå")] SalesReturn = 15, /// <summary> /// å·¥å颿å /// </summary> [Description("å·¥å颿åºåºå")] WorkOrderPicking = 21, /// <summary> /// æåå /// </summary> [Description("æåå")] MiscellaneousIssue = 22, /// <summary> /// éè´§å /// </summary> [Description("éè´§å")] ReturnGoods = 23, /// <summary> /// éå®åºåºå /// </summary> [Description("éå®åºåºå")] SalesOutbound = 24, /// <summary> /// å¤å颿ç³è¯·å /// </summary> [Description("å¤å颿ç³è¯·å")] OutsourcingPickingRequest = 25 } } ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_Common/TaskEnum/TaskTypeEnum.cs
@@ -7,6 +7,41 @@ namespace WIDESEA_Common.TaskEnum { /// <summary> /// ä»»å¡ç±»å /// </summary> public enum TaskType { /// <summary> /// ç»ç /// </summary> [Description("ç»ç")] SetPlate = 0, /// <summary> /// å ¥åº /// </summary> [Description("å ¥åº")] EnterDepot = 1, /// <summary> /// åºåº /// </summary> [Description("åºåº")] OutDepot = 2, /// <summary> /// ç§»åº /// </summary> [Description("ç§»åº")] TransferDepot = 3, /// <summary> /// æ¬è¿ /// </summary> [Description("æ¬è¿")] Delivery = 5, } public enum TaskTypeEnum { /// <summary> ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_DTO/Allocate/AllocateDto.cs
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,139 @@ using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace WIDESEA_DTO.Allocate { /// <summary> /// /// </summary> [JsonObject(MemberSerialization.OptIn)] public class AllocateDto { /// <summary> /// 请æ±ç¼ç /// </summary> [JsonProperty("reqCode")] public string ReqCode { get; set; } /// <summary> /// è¯·æ±æ¶é´ /// </summary> [JsonProperty("reqTime")] public DateTime ReqTime { get; set; } /// <summary> /// 订åç¼å· /// </summary> [JsonProperty("orderNo")] public string OrderNo { get; set; } /// <summary> /// ä¸å¡ç±»å /// </summary> [JsonProperty("business_type")] public string BusinessType { get; set; } /// <summary> /// æ¯å¦åæ¹ /// </summary> [JsonProperty("isBatch")] public bool IsBatch { get; set; } /// <summary> /// ååºä»£ç /// </summary> [JsonProperty("factoryArea")] public string FactoryArea { get; set; } /// <summary> /// æä½ç±»å /// </summary> [JsonProperty("operationType")] public int OperationType { get; set; } /// <summary> /// 订å详æ å表 /// </summary> [JsonProperty("details")] public List<AllocateDtoDetail> Details { get; set; } } /// <summary> /// 订å详æ /// </summary> [JsonObject(MemberSerialization.OptIn)] public class AllocateDtoDetail { /// <summary> /// ä»åºç¼ç /// </summary> [JsonProperty("warehouseCode")] public string WarehouseCode { get; set; } /// <summary> /// ç©æç¼ç /// </summary> [JsonProperty("materialCode")] public string MaterialCode { get; set; } /// <summary> /// è¡å· /// </summary> [JsonProperty("lineNo")] public string LineNo { get; set; } /// <summary> /// æ°é /// </summary> [JsonProperty("qty")] public decimal Qty { get; set; } /// <summary> /// åä½ /// </summary> [JsonProperty("unit")] public string Unit { get; set; } /// <summary> /// æ¡ç å表 /// </summary> [JsonProperty("barcodes")] public List<BarcodeInfo>? Barcodes { get; set; } } /// <summary> /// æ¡ç ä¿¡æ¯ /// </summary> [JsonObject(MemberSerialization.OptIn)] public class BarcodeInfo { /// <summary> /// æ¡ç /// </summary> [JsonProperty("barcode")] public string Barcode { get; set; } /// <summary> /// æ¹æ¬¡å· /// </summary> [JsonProperty("batchNo")] public string BatchNo { get; set; } /// <summary> /// æ°é /// </summary> [JsonProperty("qty")] public decimal Qty { get; set; } /// <summary> /// åä½ /// </summary> [JsonProperty("unit")] public string Unit { get; set; } } } ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_IAllocateService/IAllocateService.cs
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,18 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using WIDESEA_Core.BaseRepository; using WIDESEA_Core.BaseServices; using WIDESEA_Model.Models; using WIDESEA_Model.Models.Allocate; namespace WIDESEA_IAllocateService { public interface IAllocateService : IService<Dt_AllocateOrder> { IRepository<Dt_AllocateOrder> Repository { get; } } } ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_IAllocateService/WIDESEA_IAllocateService.csproj
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,14 @@ <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>net6.0</TargetFramework> <ImplicitUsings>enable</ImplicitUsings> <Nullable>enable</Nullable> </PropertyGroup> <ItemGroup> <ProjectReference Include="..\WIDESEA_Core\WIDESEA_Core.csproj" /> <ProjectReference Include="..\WIDESEA_Model\WIDESEA_Model.csproj" /> </ItemGroup> </Project> ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_IBasicService/IDailySequenceService.cs
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,19 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using WIDESEA_Core.BaseRepository; using WIDESEA_Core.BaseServices; using WIDESEA_Model.Models; using WIDESEA_Model.Models.Basic; namespace WIDESEA_IBasicService { public interface IDailySequenceService : IService<DT_DailySequence> { IRepository<DT_DailySequence> Repository { get; } Task<int> GetNextSequenceAsync(); } } ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_IBasicService/IMaterialUnitService.cs
@@ -13,5 +13,11 @@ public interface IMaterialUnitService : IService<Dt_MaterialUnit> { IRepository<Dt_MaterialUnit> Repository { get; } Task<decimal> ConvertAsync(string materialCode, decimal quantity, string fromUnit, string toUnit); Task<decimal> ConvertPurchaseToStockAsync(string materialCode, decimal quantity); Task<decimal> ConvertIssueToStockAsync(string materialCode, decimal quantity); } } ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_ITaskInfoService/ITaskService.cs
@@ -39,5 +39,7 @@ IRepository<Dt_Task> Repository { get; } Task<WebResponseContent> RequestInboundTask(string palletCode, string stationCode); Task<WebResponseContent> TaskCompleted(string taskNum); } } ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_InboundService/InboundOrderService.cs
@@ -179,6 +179,7 @@ } catch (Exception ex) { _unitOfWorkManage.RollbackTran(); return WebResponseContent.Instance.Error(ex.Message); } } @@ -211,6 +212,7 @@ } catch (Exception ex) { _unitOfWorkManage.RollbackTran(); return WebResponseContent.Instance.Error(ex.Message); } } @@ -337,6 +339,7 @@ StockQuantity = item.BarcodeQty, Status = 0, OrderNo = inboundOrder.InboundOrderNo, BusinessType=inboundOrder.BusinessType, }); item.ReceiptQuantity = item.BarcodeQty; ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_Model/Models/Allocate/Dt_ AllocateOrder.cs
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,18 @@ using SqlSugar; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using WIDESEA_Core.DB.Models; namespace WIDESEA_Model.Models.Allocate { /// <summary> /// /// </summary> [SugarTable(nameof(Dt_InboundOrder), "å ¥åºå")] public class Dt_AllocateOrder : BaseEntity { } } ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_Model/Models/Allocate/Dt_AllocateOrderDetail.cs
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,12 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace WIDESEA_Model.Models.Allocate { public class Dt_AllocateOrderDetail { } } ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_Model/Models/Basic/DT_DailySequence.cs
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,35 @@ using SqlSugar; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using WIDESEA_Core.DB.Models; namespace WIDESEA_Model.Models.Basic { /// <summary> /// /// </summary> [SugarTable("DT_DailySequence")] public class DT_DailySequence : BaseEntity { /// <summary> /// /// </summary> [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] public long Id { get; set; } [SugarColumn(IsNullable = false)] public DateTime SequenceDate { get; set; } [SugarColumn(Length = 50, IsNullable = false)] public string SequenceKey { get; set; } = "MESBarcode"; [SugarColumn(IsNullable = false)] public int CurrentValue { get; set; } } } ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_Model/Models/Stock/Dt_StockInfoDetail.cs
@@ -118,6 +118,14 @@ [SugarColumn(ColumnName = "barcode", ColumnDescription = "æ¡ç ")] public string? Barcode { get; set; } /// <summary> /// å¤ æ³¨:ä¸å¡ç±»å /// é»è®¤å¼: ///</summary> [SugarColumn(ColumnName = "businessType", ColumnDescription = "ä¸å¡ç±»å")] public string? BusinessType { get; set; } /// <summary> /// 夿³¨ /// </summary> ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_Model/Models/TaskInfo/Dt_Task.cs
@@ -42,7 +42,7 @@ public string PalletCode { get; set; } /// <summary> /// æçç±»å /// æçç±»å -1 空æç /// </summary> [SugarColumn(IsNullable = false, ColumnDescription = "æçç±»å")] public int PalletType { get; set; } @@ -119,6 +119,8 @@ [SugarColumn(IsNullable = true, Length = 50, ColumnDescription = "åæ®ç¼å·")] public string? OrderNo { get; set; } /// <summary> /// ä¼å 级 /// </summary> ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundOrderService.cs
@@ -143,6 +143,7 @@ } catch (Exception ex) { _unitOfWorkManage.RollbackTran(); return WebResponseContent.Instance.Error(ex.Message); } } @@ -173,6 +174,7 @@ } catch (Exception ex) { _unitOfWorkManage.RollbackTran(); return WebResponseContent.Instance.Error(ex.Message); } } ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs
@@ -21,7 +21,10 @@ using Newtonsoft.Json; using Org.BouncyCastle.Asn1.Ocsp; using SqlSugar; using System.Reflection; using System.Reflection.Emit; using System.Threading.Tasks; using System.Xml.Linq; using WIDESEA_Common.CommonEnum; using WIDESEA_Common.LocationEnum; using WIDESEA_Common.OrderEnum; @@ -31,6 +34,7 @@ using WIDESEA_Core; using WIDESEA_Core.BaseRepository; using WIDESEA_Core.BaseServices; using WIDESEA_Core.Enums; using WIDESEA_Core.Helper; using WIDESEA_DTO.Basic; using WIDESEA_DTO.Task; @@ -53,8 +57,11 @@ private readonly IRepository<Dt_StockInfo> _stockRepository; private readonly ILocationInfoService _locationInfoService; private readonly IInboundOrderService _inboundOrderService; private readonly IInboundOrderDetailService _inboundOrderDetailService; private readonly ILocationStatusChangeRecordService _locationStatusChangeRecordService; private readonly IESSApiService _eSSApiService; private readonly IStockService _stockService; private readonly IRecordService _recordService; public IRepository<Dt_Task> Repository => BaseDal; private Dictionary<string, SqlSugar.OrderByType> _taskOrderBy = new() @@ -74,7 +81,7 @@ public List<int> TaskOutboundTypes => typeof(TaskTypeEnum).GetEnumIndexList(); public TaskService(IRepository<Dt_Task> BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IRepository<Dt_StockInfo> stockRepository, ILocationInfoService locationInfoService, IInboundOrderService inboundOrderService, ILocationStatusChangeRecordService locationStatusChangeRecordService, IESSApiService eSSApiService, ILogger<TaskService> logger) : base(BaseDal) public TaskService(IRepository<Dt_Task> BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IRepository<Dt_StockInfo> stockRepository, ILocationInfoService locationInfoService, IInboundOrderService inboundOrderService, ILocationStatusChangeRecordService locationStatusChangeRecordService, IESSApiService eSSApiService, ILogger<TaskService> logger, IStockService stockService, IRecordService recordService, IInboundOrderDetailService inboundOrderDetailService) : base(BaseDal) { _mapper = mapper; _unitOfWorkManage = unitOfWorkManage; @@ -84,247 +91,9 @@ _locationStatusChangeRecordService = locationStatusChangeRecordService; _eSSApiService = eSSApiService; _logger = logger; } public async Task<WebResponseContent> RequestInboundTask(string palletCode, string stationCode) { try { Dt_Task dbtask = Repository.QueryFirst(x => x.PalletCode == palletCode); if (dbtask != null) { return WebResponseContent.Instance.Error($"该æçå·²çæä»»å¡"); } Dt_StockInfo stockInfo = _stockRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.PalletCode == palletCode).Includes(x => x.Details).First(); if (stockInfo == null) { return WebResponseContent.Instance.Error($"æªæ¾å°ç»çä¿¡æ¯"); } if (stockInfo.StockStatus != StockStatusEmun.ç»çæå.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.æå¨ç»çæå.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.æ£é宿.ObjToInt()) { return WebResponseContent.Instance.Error($"该æçç¶æä¸æ£ç¡®,ä¸å¯ç³è¯·å ¥åº"); } if (!string.IsNullOrEmpty(stockInfo.LocationCode)) { return WebResponseContent.Instance.Error($"该æçå·²ç»å®è´§ä½"); } Dt_LocationInfo? locationInfo = _locationInfoService.AssignLocation(); if (locationInfo == null) { return WebResponseContent.Instance.Error($"è´§ä½åé 失败,æªæ¾å°å¯åé è´§ä½"); } var newTask = new Dt_Task() { CurrentAddress = stationCode, Grade = 0, NextAddress = stations.GetValueOrDefault(stationCode) ?? "", PalletCode = palletCode, Roadway = locationInfo.RoadwayNo, SourceAddress = stationCode, TargetAddress = locationInfo.LocationCode, TaskType = TaskTypeEnum.Inbound.ObjToInt(), TaskStatus = TaskStatusEnum.New.ObjToInt(), WarehouseId = stockInfo.WarehouseId, PalletType = stockInfo.PalletType, }; if (stockInfo.PalletType == PalletTypeEnum.Empty.ObjToInt()) { _unitOfWorkManage.BeginTran(); int taskId = BaseDal.AddData(newTask); newTask.TaskId = taskId; locationInfo.LocationStatus = LocationStatusEnum.Lock.ObjToInt(); _locationInfoService.UpdateData(locationInfo); stockInfo.StockStatus = StockStatusEmun.å ¥åºç¡®è®¤.ObjToInt(); _stockRepository.UpdateData(stockInfo); _unitOfWorkManage.CommitTran(); } else { //è·åæ¯å¦åå¨å ¥åºå Dt_InboundOrder? inboundOrder = null; if (stockInfo != null && stockInfo.Details.Count > 0) { string? orderNo = stockInfo.Details.FirstOrDefault()?.OrderNo ?? ""; inboundOrder = _inboundOrderService.Repository.QueryFirst(x => x.InboundOrderNo == orderNo && x.OrderStatus < InOrderStatusEnum.å ¥åºå®æ.ObjToInt()); } if (inboundOrder != null) { if (inboundOrder.OrderType == InOrderTypeEnum.Allocat.ObjToInt()) { newTask.TaskType = TaskTypeEnum.InAllocate.ObjToInt(); } else if (inboundOrder.OrderType == InOrderTypeEnum.Return.ObjToInt()) { newTask.TaskType = TaskTypeEnum.ProductionReturn.ObjToInt(); } } if (stockInfo.StockStatus == StockStatusEmun.æå¨ç»çæå.ObjToInt()) { stockInfo.StockStatus = StockStatusEmun.æå¨ç»çå ¥åºç¡®è®¤.ObjToInt(); } else if (stockInfo.StockStatus == StockStatusEmun.MESéåº.ObjToInt()) { newTask.TaskType = TaskTypeEnum.MesMatReturn.ObjToInt(); } else if (stockInfo.StockStatus == StockStatusEmun.æ£é宿.ObjToInt()) { stockInfo.StockStatus = StockStatusEmun.å ¥åºç¡®è®¤.ObjToInt(); newTask.TaskType = TaskTypeEnum.InPick.ObjToInt(); } else if (stockInfo.StockStatus == StockStatusEmun.鿣åºå宿.ObjToInt()) { stockInfo.StockStatus = StockStatusEmun.æå¨ç»çå ¥åºç¡®è®¤.ObjToInt(); newTask.TaskType = TaskTypeEnum.InQuality.ObjToInt(); } else if (stockInfo.StockStatus == StockStatusEmun.çç¹åºå宿.ObjToInt()) { stockInfo.StockStatus = StockStatusEmun.æå¨ç»çå ¥åºç¡®è®¤.ObjToInt(); newTask.TaskType = TaskTypeEnum.InInventory.ObjToInt(); } else { stockInfo.StockStatus = StockStatusEmun.å ¥åºç¡®è®¤.ObjToInt(); } LocationStatusEnum lastStatus = (LocationStatusEnum)locationInfo.LocationStatus; _unitOfWorkManage.BeginTran(); int taskId = BaseDal.AddData(newTask); newTask.TaskId = taskId; _locationStatusChangeRecordService.AddLocationStatusChangeRecord(locationInfo, locationInfo.LocationStatus, StockChangeType.Inbound.ObjToInt(), inboundOrder.InboundOrderNo, newTask.TaskNum); locationInfo.LocationStatus = LocationStatusEnum.Lock.ObjToInt(); _locationInfoService.UpdateData(locationInfo); _stockRepository.UpdateData(stockInfo); _unitOfWorkManage.CommitTran(); } TaskModel esstask = new TaskModel() { taskType = "putaway", taskGroupCode = "", groupPriority = 0, tasks = new List<TasksType> { new() { taskCode=newTask.TaskNum.ToString(), taskPriority=0, taskDescribe=new TaskDescribeType{ containerCode=palletCode, containerType= "CT_KUBOT_STANDARD", fromLocationCode=stations.GetValueOrDefault(stationCode)??"", toStationCode="", toLocationCode=locationInfo.LocationCode, deadline=0,storageTag="" } } } }; _logger.LogInformation("å建任å¡Request: " + JsonConvert.SerializeObject(esstask)); var result = await _eSSApiService.CreateTaskAsync(esstask); _logger.LogInformation("å建任å¡è¿å: " + result); if (result) { return WebResponseContent.Instance.OK(); } else { return WebResponseContent.Instance.Error("ä¸åæºå¨äººä»»å¡å¤±è´¥ï¼"); } } catch (Exception ex) { return WebResponseContent.Instance.Error(ex.Message); } } /// <summary> /// å ¥ç©ºç®± /// </summary> /// <param name="palletCode"></param> /// <param name="address"></param> /// <param name="WarehouseId"></param> /// <returns></returns> public WebResponseContent InEmpty(string palletCode, string address, int WarehouseId) { try { Dt_Task dbtask = Repository.QueryFirst(x => x.PalletCode == palletCode); if (dbtask != null) { return WebResponseContent.Instance.Error($"该æçå·²çæä»»å¡"); } Dt_StockInfo stockInfo = _stockRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.PalletCode == palletCode).First(); if (stockInfo == null) { return WebResponseContent.Instance.Error($"æªæ¾å°ç»çä¿¡æ¯"); } if (stockInfo.StockStatus != StockStatusEmun.ç»çæå.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.æå¨ç»çæå.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.æ£é宿.ObjToInt()) { return WebResponseContent.Instance.Error($"该æçç¶æä¸æ£ç¡®,ä¸å¯ç³è¯·å ¥åº"); } if (!string.IsNullOrEmpty(stockInfo.LocationCode)) { return WebResponseContent.Instance.Error($"该æçå·²ç»å®è´§ä½"); } //stockInfo = new Dt_StockInfo() //{ // PalletCode = barcode, // StockStatus = StockStatusEmun.å ¥åºç¡®è®¤.ObjToInt(), // WarehouseId = WarehouseId, // PalletType = PalletTypeEnum.Empty.ObjToInt(), // Details = new List<Dt_StockInfoDetail>() //}; var locationInfo = _locationInfoService.AssignLocation(); if (locationInfo == null) { return WebResponseContent.Instance.Error($"è´§ä½åé 失败,æªæ¾å°å¯åé è´§ä½"); } Dt_Task newTask = new Dt_Task() { CurrentAddress = address, Grade = 0, NextAddress = locationInfo.LocationCode, PalletCode = palletCode, Roadway = locationInfo.RoadwayNo, SourceAddress = address, TargetAddress = locationInfo.LocationCode, TaskType = TaskTypeEnum.InEmpty.ObjToInt(), TaskStatus = TaskStatusEnum.New.ObjToInt(), WarehouseId = stockInfo.WarehouseId, PalletType = stockInfo.PalletType }; locationInfo.LocationStatus = LocationStatusEnum.Lock.ObjToInt(); _unitOfWorkManage.BeginTran(); int taskId = BaseDal.AddData(newTask); newTask.TaskId = taskId; _locationInfoService.UpdateData(locationInfo); stockInfo.StockStatus = StockStatusEmun.å ¥åºç¡®è®¤.ObjToInt(); _stockRepository.AddData(stockInfo); _unitOfWorkManage.CommitTran(); return WebResponseContent.Instance.OK(); } catch (Exception ex) { _unitOfWorkManage.RollbackTran(); return WebResponseContent.Instance.Error(ex.Message); } _stockService = stockService; _recordService = recordService; _inboundOrderDetailService = inboundOrderDetailService; } /// <summary> @@ -332,22 +101,151 @@ /// </summary> /// <param name="taskNum"></param> /// <returns></returns> public async Task<WebResponseContent> TaskCompleted(int taskNum) public async Task<WebResponseContent> TaskCompleted(string taskNum) { try { Dt_Task task; if (int.TryParse(taskNum, out var newTaskNum)) { task = BaseDal.QueryFirst(x => x.TaskNum == newTaskNum); if (task == null) { return WebResponseContent.Instance.Error("æªæ¾å°ä»»å¡ä¿¡æ¯"); } } else { return WebResponseContent.Instance.Error("æªæ¾å°ä»»å¡ä¿¡æ¯"); } MethodInfo? methodInfo = GetType().GetMethod(((TaskTypeEnum)task.TaskType) + "TaskCompleted"); if (methodInfo != null) { WebResponseContent? responseContent = (WebResponseContent?)methodInfo.Invoke(this, new object[] { task }); if (responseContent != null) { return responseContent; } } return WebResponseContent.Instance.Error("æªæ¾å°ä»»å¡ç±»å对åºä¸å¡å¤çé»è¾"); } catch (Exception ex) { return WebResponseContent.Instance.Error(ex.Message); } } /// <summary> /// å ¥åºå®æ /// </summary> /// <param name="task"></param> /// <returns></returns> public WebResponseContent InboundTaskCompleted(Dt_Task task) { decimal beforeQuantity = 0; //æ¥åºå Dt_StockInfo stockInfo = _stockRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.PalletCode == task.PalletCode && x.WarehouseId == task.WarehouseId).First(); if (stockInfo == null) { return WebResponseContent.Instance.Error($"æªæ¾å°æç对åºçç»çä¿¡æ¯"); } if (stockInfo.Details.Count == 0 && stockInfo.PalletType != PalletTypeEnum.Empty.ObjToInt()) { return WebResponseContent.Instance.Error($"æªæ¾å°è¯¥æçåºåæç»ä¿¡æ¯"); } //æ¥è´§ä½ Dt_LocationInfo locationInfo = _locationInfoService.Repository.QueryFirst(x => x.LocationCode == task.TargetAddress); if (locationInfo == null) { return WebResponseContent.Instance.Error($"æªæ¾å°å¯¹åºçç»ç¹è´§ä½ä¿¡æ¯"); } var ordernos = stockInfo.Details.GroupBy(x => x.OrderNo).Select(o => o.Key).ToList(); var inboundOrders = _inboundOrderService.Repository.Db.Queryable<Dt_InboundOrder>().Where(x => ordernos.Contains(x.InboundOrderNo)).Includes(x => x.Details).ToList(); Dt_InboundOrderDetail? inboundOrderDetail = null; foreach (var inboundOrder in inboundOrders) { //æ åå ¥åºæµç¨æ¥æ¾å ¥åºåæ® if (inboundOrder != null && stockInfo.StockStatus == StockStatusEmun.å ¥åºç¡®è®¤.ObjToInt()) { foreach (var item in stockInfo.Details.Where(x => x.OrderNo == inboundOrder.InboundOrderNo).ToList()) { var inbounddetail = inboundOrder.Details.Where(x => x.lineNo == item.InboundOrderRowNo && x.Barcode == item.Barcode).FirstOrDefault(); if (inbounddetail != null) { inbounddetail.OverInQuantity += item.StockQuantity; if (inbounddetail.OverInQuantity == inbounddetail.OrderQuantity) { inbounddetail.OrderDetailStatus = OrderDetailStatusEnum.Over.ObjToInt(); } else if (inbounddetail.OrderDetailStatus == OrderDetailStatusEnum.New.ObjToInt()) { inbounddetail.OrderDetailStatus = OrderDetailStatusEnum.Inbounding.ObjToInt(); } _inboundOrderDetailService.UpdateData(inbounddetail); } } if (inboundOrder.Details.Count == inboundOrder.Details.Where(x => x.OrderQuantity == x.OverInQuantity).Count()) { inboundOrder.OrderStatus = InOrderStatusEnum.å ¥åºå®æ.ObjToInt(); } else if (inboundOrder.OrderStatus == InOrderStatusEnum.æªå¼å§.ObjToInt()) { inboundOrder.OrderStatus = InOrderStatusEnum.å ¥åºä¸.ObjToInt(); } _inboundOrderService.UpdateData(inboundOrder); } } stockInfo.LocationCode = task.TargetAddress; stockInfo.StockStatus = StockStatusEmun.å ¥åºå®æ.ObjToInt(); stockInfo.Details.ForEach(x => { x.Status = StockStatusEmun.å ¥åºå®æ.ObjToInt(); }); _stockService.StockInfoService.Repository.UpdateData(stockInfo); _stockService.StockInfoDetailService.Repository.UpdateData(stockInfo.Details); beforeQuantity = stockInfo.Details.Where(x => x.Id != 0).Sum(x => x.StockQuantity); int beforeStatus = locationInfo.LocationStatus; if (stockInfo.PalletType == PalletTypeEnum.Empty.ObjToInt()) { locationInfo.LocationStatus = LocationStatusEnum.Pallet.ObjToInt(); } else { locationInfo.LocationStatus = LocationStatusEnum.InStock.ObjToInt(); } _locationInfoService.Repository.UpdateData(locationInfo); task.TaskStatus = TaskStatusEnum.Finish.ObjToInt(); BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateTypeEnum.èªå¨å®æ : OperateTypeEnum.äººå·¥å®æ); _locationStatusChangeRecordService.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Inbound.ObjToInt(), "", task.TaskNum); _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfo, stockInfo.Details, beforeQuantity, stockInfo.Details.Sum(x => x.StockQuantity) + beforeQuantity, WIDESEA_Common.StockEnum.StockChangeType.MaterielGroup); return WebResponseContent.Instance.OK(); } public async Task<WebResponseContent> InEmptyTaskCompleted(Dt_Task task) { WebResponseContent content = new WebResponseContent(); try { Dt_Task task = await Repository.QueryFirstAsync(x => x.TaskNum == taskNum); if (task == null) { return await Task.FromResult(WebResponseContent.Instance.Error($"æªæ¾å°ä»»å¡ä¿¡æ¯")); } Dt_LocationInfo locationInfo = _locationInfoService.Repository.QueryFirst(x => x.LocationCode == task.TargetAddress); if (locationInfo == null) { return content.Error($"æªæ¾å°å¯¹åºçç»ç¹è´§ä½ä¿¡æ¯"); } Dt_StockInfo stockInfo = _stockRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.PalletCode == task.PalletCode && x.WarehouseId == task.WarehouseId).Includes(x => x.Details).First(); Dt_StockInfo stockInfo = _stockRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.PalletCode == task.PalletCode && x.WarehouseId == task.WarehouseId).First(); if (stockInfo == null) { return WebResponseContent.Instance.Error($"æªæ¾å°æç对åºçç»çä¿¡æ¯"); @@ -361,13 +259,24 @@ { return WebResponseContent.Instance.Error($"è´§ä½ç¶æä¸æ£ç¡®"); } LocationStatusEnum lastStatus = (LocationStatusEnum)locationInfo.LocationStatus; locationInfo.LocationStatus = LocationStatusEnum.InStock.ObjToInt(); var beforelocationStatus = locationInfo.LocationStatus; locationInfo.LocationStatus = LocationStatusEnum.Pallet.ObjToInt(); _locationInfoService.Repository.UpdateData(locationInfo); stockInfo.LocationCode = locationInfo.LocationCode; stockInfo.PalletCode = task.PalletCode; stockInfo.LocationCode = task.TargetAddress; stockInfo.StockStatus = StockStatusEmun.å ¥åºå®æ.ObjToInt(); _stockRepository.UpdateData(stockInfo); Dt_InboundOrder? inboundOrder = _inboundOrderService.Repository.Db.Queryable<Dt_InboundOrder>().Where(x => x.InboundOrderNo == stockInfo.Details.FirstOrDefault().OrderNo).Includes(x => x.Details).First(); Dt_InboundOrderDetail? inboundOrderDetail = null; task.TaskStatus = TaskStatusEnum.Finish.ObjToInt(); BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? WIDESEA_Core.Enums.OperateTypeEnum.èªå¨å®æ : OperateTypeEnum.äººå·¥å®æ); _locationStatusChangeRecordService.AddLocationStatusChangeRecord(locationInfo, beforelocationStatus, StockChangeType.Inbound.ObjToInt(), "", task.TaskNum); return content; } @@ -376,5 +285,49 @@ return await Task.FromResult(WebResponseContent.Instance.Error(ex.Message)); } } public async Task<WebResponseContent> OutEmptyTaskCompleted(Dt_Task task) { WebResponseContent content = new WebResponseContent(); try { Dt_StockInfo stockInfo = _stockRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.PalletCode == task.PalletCode && x.WarehouseId == task.WarehouseId).First(); if (stockInfo == null) { return WebResponseContent.Instance.Error($"æªæ¾å°æç对åºçåºåä¿¡æ¯"); } Dt_LocationInfo locationInfo = _locationInfoService.Repository.QueryFirst(x => x.LocationCode == task.SourceAddress); if (locationInfo == null) { return content.Error($"æªæ¾å°å¯¹åºçç»ç¹è´§ä½ä¿¡æ¯"); } _stockRepository.Db.Deleteable(stockInfo); int beforeStatus = locationInfo.LocationStatus; locationInfo.LocationStatus = LocationStatusEnum.Free.ObjToInt(); _locationInfoService.Repository.UpdateData(locationInfo); task.TaskStatus = TaskStatusEnum.Finish.ObjToInt(); BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateTypeEnum.èªå¨å®æ : OperateTypeEnum.äººå·¥å®æ); _stockService.StockInfoService.Repository.DeleteAndMoveIntoHty(stockInfo, App.User.UserId == 0 ? OperateTypeEnum.èªå¨å®æ : OperateTypeEnum.äººå·¥å®æ); _locationStatusChangeRecordService.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Outbound.ObjToInt(), stockInfo.Details.FirstOrDefault()?.OrderNo ?? "", task.TaskNum); return WebResponseContent.Instance.OK(); } catch (Exception ex) { return await Task.FromResult(WebResponseContent.Instance.Error(ex.Message)); } } } } ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Inbound.cs
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,233 @@ using Microsoft.Extensions.Logging; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using WIDESEA_Common.CommonEnum; using WIDESEA_Common.LocationEnum; using WIDESEA_Common.OrderEnum; using WIDESEA_Common.StockEnum; using WIDESEA_Common.TaskEnum; using WIDESEA_Core; using WIDESEA_Core.Helper; using WIDESEA_DTO.Basic; using WIDESEA_Model.Models; namespace WIDESEA_TaskInfoService { public partial class TaskService { public async Task<WebResponseContent> RequestInboundTask(string palletCode, string stationCode) { try { Dt_Task dbtask = Repository.QueryFirst(x => x.PalletCode == palletCode); if (dbtask != null) { return WebResponseContent.Instance.Error($"该æçå·²çæä»»å¡"); } Dt_StockInfo stockInfo = _stockRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.PalletCode == palletCode).Includes(x => x.Details).First(); if (stockInfo == null) { return WebResponseContent.Instance.Error($"æªæ¾å°ç»çä¿¡æ¯"); } if (stockInfo.StockStatus != StockStatusEmun.ç»çæå.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.æå¨ç»çæå.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.æ£é宿.ObjToInt()) { return WebResponseContent.Instance.Error($"该æçç¶æä¸æ£ç¡®,ä¸å¯ç³è¯·å ¥åº"); } if (!string.IsNullOrEmpty(stockInfo.LocationCode)) { return WebResponseContent.Instance.Error($"该æçå·²ç»å®è´§ä½"); } Dt_LocationInfo? locationInfo = _locationInfoService.AssignLocation(); if (locationInfo == null) { return WebResponseContent.Instance.Error($"è´§ä½åé 失败,æªæ¾å°å¯åé è´§ä½"); } var newTask = new Dt_Task() { CurrentAddress = stationCode, Grade = 0, NextAddress = stations.GetValueOrDefault(stationCode) ?? "", PalletCode = palletCode, Roadway = locationInfo.RoadwayNo, SourceAddress = stationCode, TargetAddress = locationInfo.LocationCode, TaskType = TaskTypeEnum.Inbound.ObjToInt(), TaskStatus = TaskStatusEnum.New.ObjToInt(), WarehouseId = stockInfo.WarehouseId, PalletType = stockInfo.PalletType, }; //空箱 if (stockInfo.PalletType == PalletTypeEnum.Empty.ObjToInt()) { _unitOfWorkManage.BeginTran(); newTask.TaskType = TaskTypeEnum.InEmpty.ObjToInt(); int taskId = BaseDal.AddData(newTask); newTask.TaskId = taskId; locationInfo.LocationStatus = LocationStatusEnum.Lock.ObjToInt(); _locationInfoService.UpdateData(locationInfo); stockInfo.StockStatus = StockStatusEmun.å ¥åºç¡®è®¤.ObjToInt(); _stockRepository.UpdateData(stockInfo); _unitOfWorkManage.CommitTran(); } else { //è·åæ¯å¦åå¨å ¥åºå Dt_InboundOrder? inboundOrder = null; if (stockInfo != null && stockInfo.Details.Count > 0) { string? orderNo = stockInfo.Details.FirstOrDefault()?.OrderNo ?? ""; inboundOrder = _inboundOrderService.Repository.QueryFirst(x => x.InboundOrderNo == orderNo && x.OrderStatus < InOrderStatusEnum.å ¥åºå®æ.ObjToInt()); } stockInfo.StockStatus = StockStatusEmun.å ¥åºç¡®è®¤.ObjToInt(); LocationStatusEnum lastStatus = (LocationStatusEnum)locationInfo.LocationStatus; _unitOfWorkManage.BeginTran(); int taskId = BaseDal.AddData(newTask); newTask.TaskId = taskId; _locationStatusChangeRecordService.AddLocationStatusChangeRecord(locationInfo, locationInfo.LocationStatus, StockChangeType.Inbound.ObjToInt(), inboundOrder?.InboundOrderNo, newTask.TaskNum); locationInfo.LocationStatus = LocationStatusEnum.Lock.ObjToInt(); _locationInfoService.UpdateData(locationInfo); _stockRepository.UpdateData(stockInfo); _unitOfWorkManage.CommitTran(); } TaskModel esstask = new TaskModel() { taskType = "putaway", taskGroupCode = "", groupPriority = 0, tasks = new List<TasksType> { new() { taskCode=newTask.TaskNum.ToString(), taskPriority=0, taskDescribe=new TaskDescribeType{ containerCode=palletCode, containerType= "CT_KUBOT_STANDARD", fromLocationCode=stations.GetValueOrDefault(stationCode)??"", toStationCode="", toLocationCode=locationInfo.LocationCode, deadline=0,storageTag="" } } } }; _logger.LogInformation("å建任å¡Request: " + JsonConvert.SerializeObject(esstask)); var result = await _eSSApiService.CreateTaskAsync(esstask); _logger.LogInformation("å建任å¡è¿å: " + result); if (result) { return WebResponseContent.Instance.OK(); } else { return WebResponseContent.Instance.Error("ä¸åæºå¨äººä»»å¡å¤±è´¥ï¼"); } } catch (Exception ex) { return WebResponseContent.Instance.Error(ex.Message); } } /// <summary> /// å ¥ç©ºç®± /// </summary> /// <param name="palletCode"></param> /// <param name="address"></param> /// <param name="WarehouseId"></param> /// <returns></returns> public WebResponseContent InEmpty(string palletCode, string address, int WarehouseId) { try { Dt_Task dbtask = Repository.QueryFirst(x => x.PalletCode == palletCode); if (dbtask != null) { return WebResponseContent.Instance.Error($"该æçå·²çæä»»å¡"); } Dt_StockInfo stockInfo = _stockRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.PalletCode == palletCode).First(); if (stockInfo == null) { return WebResponseContent.Instance.Error($"æªæ¾å°ç»çä¿¡æ¯"); } if (stockInfo.StockStatus != StockStatusEmun.ç»çæå.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.æå¨ç»çæå.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.æ£é宿.ObjToInt()) { return WebResponseContent.Instance.Error($"该æçç¶æä¸æ£ç¡®,ä¸å¯ç³è¯·å ¥åº"); } if (!string.IsNullOrEmpty(stockInfo.LocationCode)) { return WebResponseContent.Instance.Error($"该æçå·²ç»å®è´§ä½"); } //stockInfo = new Dt_StockInfo() //{ // PalletCode = barcode, // StockStatus = StockStatusEmun.å ¥åºç¡®è®¤.ObjToInt(), // WarehouseId = WarehouseId, // PalletType = PalletTypeEnum.Empty.ObjToInt(), // Details = new List<Dt_StockInfoDetail>() //}; var locationInfo = _locationInfoService.AssignLocation(); if (locationInfo == null) { return WebResponseContent.Instance.Error($"è´§ä½åé 失败,æªæ¾å°å¯åé è´§ä½"); } Dt_Task newTask = new Dt_Task() { CurrentAddress = address, Grade = 0, NextAddress = locationInfo.LocationCode, PalletCode = palletCode, Roadway = locationInfo.RoadwayNo, SourceAddress = address, TargetAddress = locationInfo.LocationCode, TaskType = TaskTypeEnum.InEmpty.ObjToInt(), TaskStatus = TaskStatusEnum.New.ObjToInt(), WarehouseId = stockInfo.WarehouseId, PalletType = stockInfo.PalletType }; locationInfo.LocationStatus = LocationStatusEnum.Lock.ObjToInt(); _unitOfWorkManage.BeginTran(); int taskId = BaseDal.AddData(newTask); newTask.TaskId = taskId; _locationInfoService.UpdateData(locationInfo); stockInfo.StockStatus = StockStatusEmun.å ¥åºç¡®è®¤.ObjToInt(); _stockRepository.AddData(stockInfo); _unitOfWorkManage.CommitTran(); return WebResponseContent.Instance.OK(); } catch (Exception ex) { _unitOfWorkManage.RollbackTran(); return WebResponseContent.Instance.Error(ex.Message); } } } } ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Outbound.cs
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,126 @@ using Microsoft.Extensions.Logging; using Newtonsoft.Json; using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using WIDESEA_Common.CommonEnum; using WIDESEA_Common.LocationEnum; using WIDESEA_Common.OtherEnum; using WIDESEA_Common.StockEnum; using WIDESEA_Common.TaskEnum; using WIDESEA_Core; using WIDESEA_Core.Helper; using WIDESEA_DTO.Basic; using WIDESEA_Model.Models; namespace WIDESEA_TaskInfoService { public partial class TaskService { /// <summary> /// 空æçåºåºä»»å¡ /// </summary> /// <param name="inTask"></param> /// <returns></returns> public async Task<WebResponseContent> PalletOutboundTask(string endStation, string palletCode = "") { try { Dt_StockInfo stockInfo ; if (string.IsNullOrEmpty(palletCode)) { stockInfo = _stockRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.PalletType == PalletTypeEnum.Empty.ObjToInt()).First(); } else { stockInfo = _stockRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.PalletCode == palletCode) .First(); } if (stockInfo == null) { return WebResponseContent.Instance.Error("æªæ¾å°ç©ºæçåºå"); } Dt_LocationInfo locationInfo = _locationInfoService.Repository.QueryFirst(x => x.LocationCode == stockInfo.LocationCode); if (locationInfo == null) { return WebResponseContent.Instance.Error("æªæ¾å°ç©ºæçåºå对åºçè´§ä½ä¿¡æ¯"); } Dt_Task task = new Dt_Task() { CurrentAddress = stockInfo.LocationCode, Grade = 0, NextAddress = endStation, PalletCode = stockInfo.PalletCode, Roadway = locationInfo.RoadwayNo, SourceAddress = stockInfo.LocationCode, TargetAddress = endStation, TaskStatus = TaskStatusEnum.New.ObjToInt(), TaskType = TaskTypeEnum.OutEmpty.ObjToInt(), WarehouseId = stockInfo.WarehouseId, PalletType = stockInfo.PalletType }; int beforeStatus = locationInfo.LocationStatus; _unitOfWorkManage.BeginTran(); stockInfo.StockStatus = StockStatusEmun.åºåºéå®.ObjToInt(); locationInfo.LocationStatus = LocationStatusEnum.Lock.ObjToInt(); int taskId = BaseDal.AddData(task); task.TaskId = taskId; _stockService.StockInfoService.UpdateData(stockInfo); _locationInfoService.UpdateData(locationInfo); _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Outbound.ObjToInt(), "", task.TaskNum); _unitOfWorkManage.CommitTran(); TaskModel esstask = new TaskModel() { taskType = "carry", taskGroupCode = "", groupPriority = 0, tasks = new List<TasksType> { new() { taskCode=task.TaskNum.ToString(), taskPriority=0, taskDescribe=new TaskDescribeType{ containerCode=stockInfo.PalletCode, containerType= "CT_KUBOT_STANDARD", fromLocationCode=stockInfo.LocationCode??"", toStationCode="", toLocationCode=endStation, deadline=0,storageTag="" } } } }; _logger.LogInformation("å建任å¡PalletOutboundTask Request: " + JsonConvert.SerializeObject(esstask)); var result = await _eSSApiService.CreateTaskAsync(esstask); _logger.LogInformation("å建任å¡PalletOutboundTask è¿å: " + result); if (result) { return WebResponseContent.Instance.OK(); } else { return WebResponseContent.Instance.Error("ä¸åæºå¨äººä»»å¡å¤±è´¥ï¼"); } } catch (Exception ex) { return WebResponseContent.Instance.Error(ex.Message); } } } } ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_WMSServer.sln
@@ -68,6 +68,12 @@ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WIDESEA_CheckService", "WIDESEA_CheckService\WIDESEA_CheckService.csproj", "{C57C16CE-88A7-499A-8CE1-855D55482891}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Allocate", "Allocate", "{02EA681E-C7D8-13C7-8484-4AC65E1B71E8}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WIDESEA_AllocateService", "WIDESEA_AllocateService\WIDESEA_AllocateService.csproj", "{D35E0897-0E66-4E1E-B8DA-28701BE3B2B7}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WIDESEA_IAllocateService", "WIDESEA_IAllocateService\WIDESEA_IAllocateService.csproj", "{A6E822A3-5A09-4B18-BEE6-57CC7D7B8BEC}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -330,6 +336,30 @@ {C57C16CE-88A7-499A-8CE1-855D55482891}.Release|Any CPU.Build.0 = Release|Any CPU {C57C16CE-88A7-499A-8CE1-855D55482891}.Release|x86.ActiveCfg = Release|Any CPU {C57C16CE-88A7-499A-8CE1-855D55482891}.Release|x86.Build.0 = Release|Any CPU {D35E0897-0E66-4E1E-B8DA-28701BE3B2B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D35E0897-0E66-4E1E-B8DA-28701BE3B2B7}.Debug|Any CPU.Build.0 = Debug|Any CPU {D35E0897-0E66-4E1E-B8DA-28701BE3B2B7}.Debug|x86.ActiveCfg = Debug|Any CPU {D35E0897-0E66-4E1E-B8DA-28701BE3B2B7}.Debug|x86.Build.0 = Debug|Any CPU {D35E0897-0E66-4E1E-B8DA-28701BE3B2B7}.Dev|Any CPU.ActiveCfg = Release|Any CPU {D35E0897-0E66-4E1E-B8DA-28701BE3B2B7}.Dev|Any CPU.Build.0 = Release|Any CPU {D35E0897-0E66-4E1E-B8DA-28701BE3B2B7}.Dev|x86.ActiveCfg = Release|Any CPU {D35E0897-0E66-4E1E-B8DA-28701BE3B2B7}.Dev|x86.Build.0 = Release|Any CPU {D35E0897-0E66-4E1E-B8DA-28701BE3B2B7}.Release|Any CPU.ActiveCfg = Release|Any CPU {D35E0897-0E66-4E1E-B8DA-28701BE3B2B7}.Release|Any CPU.Build.0 = Release|Any CPU {D35E0897-0E66-4E1E-B8DA-28701BE3B2B7}.Release|x86.ActiveCfg = Release|Any CPU {D35E0897-0E66-4E1E-B8DA-28701BE3B2B7}.Release|x86.Build.0 = Release|Any CPU {A6E822A3-5A09-4B18-BEE6-57CC7D7B8BEC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A6E822A3-5A09-4B18-BEE6-57CC7D7B8BEC}.Debug|Any CPU.Build.0 = Debug|Any CPU {A6E822A3-5A09-4B18-BEE6-57CC7D7B8BEC}.Debug|x86.ActiveCfg = Debug|Any CPU {A6E822A3-5A09-4B18-BEE6-57CC7D7B8BEC}.Debug|x86.Build.0 = Debug|Any CPU {A6E822A3-5A09-4B18-BEE6-57CC7D7B8BEC}.Dev|Any CPU.ActiveCfg = Release|Any CPU {A6E822A3-5A09-4B18-BEE6-57CC7D7B8BEC}.Dev|Any CPU.Build.0 = Release|Any CPU {A6E822A3-5A09-4B18-BEE6-57CC7D7B8BEC}.Dev|x86.ActiveCfg = Release|Any CPU {A6E822A3-5A09-4B18-BEE6-57CC7D7B8BEC}.Dev|x86.Build.0 = Release|Any CPU {A6E822A3-5A09-4B18-BEE6-57CC7D7B8BEC}.Release|Any CPU.ActiveCfg = Release|Any CPU {A6E822A3-5A09-4B18-BEE6-57CC7D7B8BEC}.Release|Any CPU.Build.0 = Release|Any CPU {A6E822A3-5A09-4B18-BEE6-57CC7D7B8BEC}.Release|x86.ActiveCfg = Release|Any CPU {A6E822A3-5A09-4B18-BEE6-57CC7D7B8BEC}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -359,6 +389,9 @@ {294A53A4-1311-4B71-A812-378A2BCB8346} = {60DE2920-37C6-4C2B-A053-6B1B2DAF047A} {82EBBC95-FD6E-4E30-9F21-625DE1991C2C} = {294A53A4-1311-4B71-A812-378A2BCB8346} {C57C16CE-88A7-499A-8CE1-855D55482891} = {294A53A4-1311-4B71-A812-378A2BCB8346} {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} = {60DE2920-37C6-4C2B-A053-6B1B2DAF047A} {D35E0897-0E66-4E1E-B8DA-28701BE3B2B7} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} {A6E822A3-5A09-4B18-BEE6-57CC7D7B8BEC} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {599A7267-7402-4143-84AE-9B407FC2BB69} ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Allocate/AllocateOrderController.cs
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,25 @@ using Microsoft.AspNetCore.Mvc; using WIDESEA_Core.BaseController; using WIDESEA_IAllocateService; using WIDESEA_IInboundService; using WIDESEA_Model.Models; using WIDESEA_Model.Models.Allocate; namespace WIDESEA_WMSServer.Controllers.Allocate { /// <summary> /// è°æ¨å /// </summary> [Route("api/AllocateOrder")] [ApiController] public class AllocateOrderController : ApiBaseController<IAllocateService, Dt_AllocateOrder> { public AllocateOrderController(IAllocateService service) : base(service) { } } } ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/ESSController.cs
@@ -1,5 +1,6 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Caching.Memory; using Newtonsoft.Json; using System.DirectoryServices.Protocols; using System.Threading.Tasks; @@ -24,10 +25,13 @@ public readonly ITaskService _taskService; private readonly ILogger<ESSController> _logger; public ESSController(ITaskService taskService, ILogger<ESSController> logger) private readonly IMemoryCache _memoryCache; private static readonly SemaphoreSlim _semaphore = new SemaphoreSlim(1, 1); public ESSController(ITaskService taskService, ILogger<ESSController> logger, IMemoryCache memoryCache) { _taskService = taskService; _logger = logger; _memoryCache = memoryCache; } /// <summary> @@ -38,6 +42,8 @@ [HttpPost("ContainerArrivalReport"), AllowAnonymous] public async Task<IActionResult> ContainerArrivalReport([FromBody] ContainerArrivalRequest request) { //è¿éè¦å¤æåºåºçæ¶åï¼æç®±ä¼å°æ«ç å¤ãä¹ä¼è¯·æ±è¿ä¸ªæ¥å£ã var response = new ApiResponse<ContainerArrivalResponseData> { Code = 0, @@ -47,9 +53,51 @@ direction = "100" // 示ä¾å¼ï¼å¯æ ¹æ®å®é æ åµè¿åæ¹åæå ¶ä»ä¿¡æ¯ } }; // çæè¯·æ±çå¯ä¸æ è¯ï¼åºäºcallId + æ¶é´æ³ï¼ var requestKey = $"callback_{request.CallId}-{request.ContainerCode}_{DateTime.UtcNow:yyyyMMddHH}"; // æ£æ¥æ¯å¦å·²ç»å¤çè¿ç¸åçè¯·æ± if (_memoryCache.TryGetValue(requestKey, out bool _)) { _logger.LogWarning("æ£æµå°éå¤è¯·æ±ï¼å·²å¿½ç¥: CallId={CallId}", request.CallId); response.Code = 1; response.Msg = "error"; response.Data.direction = "0"; return Ok(response); } await _semaphore.WaitAsync(); try { if (_memoryCache.TryGetValue(requestKey, out bool _)) { _logger.LogWarning("åéæ£æ¥æ£æµå°éå¤è¯·æ±ï¼å·²å¿½ç¥: CallId={CallId}", request.CallId); response.Code = 1; response.Msg = "error"; response.Data.direction = "0"; return Ok(response); } var result = await _taskService.RequestInboundTask(request.ContainerCode, request.SlotCode); var cacheOptions = new MemoryCacheEntryOptions { AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(1) }; _memoryCache.Set(requestKey, true, cacheOptions); if (result.Status) { response = new ApiResponse<ContainerArrivalResponseData> { Code = 0, Msg = "", Data = new ContainerArrivalResponseData { direction = "100" } }; return Ok(response); } else @@ -58,6 +106,16 @@ response.Msg = "error"; response.Data.direction = "0"; return Ok(response); } } catch (Exception ex) { _logger.LogError(ex, "å¤çä»»å¡ç¶æåè°æ¶åçå¼å¸¸: CallId={CallId}", request.CallId); return Ok($"å¤çåè°æ¶åçå¼å¸¸: {ex.Message}"); } finally { _semaphore.Release(); } } @@ -94,12 +152,6 @@ // æ ¹æ®äºä»¶ç±»ååç¶æè¿è¡ä¸åçä¸å¡å¤ç switch (request.EventType) { case EventType.task: await HandleTaskStatusChange(request); break; case EventType.task_allocated: await HandleTaskAllocated(request); break; case EventType.tote_load: await HandleToteLoad(request); break; @@ -109,6 +161,13 @@ case EventType.robot_reach: await HandleRobotReach(request); break; case EventType.task: await HandleTaskStatusChange(request); break; case EventType.task_allocated: await HandleTaskAllocated(request); break; default: _logger.LogWarning("æªç¥çäºä»¶ç±»å: {EventType}", request.EventType); break; @@ -156,6 +215,7 @@ _logger.LogInformation("ä»»å¡å®æ: TaskCode={TaskCode}, Container={Container}, Robot={Robot}", request.TaskCode, request.ContainerCode, request.RobotCode); _taskService.TaskCompleted(request.TaskCode); // æ ¹æ®ä¸åçä»»å¡ç±»åè¿è¡ç¹æ®å¤ç if (request.Weight.HasValue) { ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Inbound/InboundOrderController.cs
@@ -5,6 +5,7 @@ using SqlSugar; using System.Net; using System.Threading.Tasks; using WIDESEA_BasicService; using WIDESEA_Common.OrderEnum; using WIDESEA_Core; using WIDESEA_Core.Attributes; @@ -30,16 +31,20 @@ private readonly WIDESEA_IBasicService.IInvokeMESService _invokeMESService; private readonly IESSApiService _eSSApiService; public InboundOrderController(IInboundOrderService service, WIDESEA_IBasicService.IErpApiService erpApiService, WIDESEA_IBasicService.IInvokeMESService invokeMESService, IESSApiService eSSApiService) : base(service) private readonly IDailySequenceService _dailySequenceService; public InboundOrderController(IInboundOrderService service, WIDESEA_IBasicService.IErpApiService erpApiService, WIDESEA_IBasicService.IInvokeMESService invokeMESService, IESSApiService eSSApiService, IDailySequenceService dailySequenceService) : base(service) { this.erpApiService = erpApiService; _invokeMESService = invokeMESService; _eSSApiService = eSSApiService; _dailySequenceService = dailySequenceService; } [HttpPost, Route("Test"), AllowAnonymous, MethodParamsValidate] public async Task<WebResponseContent> Test() { await _dailySequenceService.GetNextSequenceAsync(); //erpApiService.GetSuppliersAsync(); //erpApiService.GetMaterialUnitAsync(); ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_WMSServer/WIDESEA_WMSServer.csproj
@@ -53,6 +53,7 @@ </ItemGroup> <ItemGroup> <ProjectReference Include="..\WIDESEA_AllocateService\WIDESEA_AllocateService.csproj" /> <ProjectReference Include="..\WIDESEA_BasicService\WIDESEA_BasicService.csproj" /> <ProjectReference Include="..\WIDESEA_CheckService\WIDESEA_CheckService.csproj" /> <ProjectReference Include="..\WIDESEA_InboundService\WIDESEA_InboundService.csproj" />