diff --git a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/Authenticaitons/BaererToken.cs b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/Authenticaitons/BaererToken.cs new file mode 100644 index 000000000..f03e11afd --- /dev/null +++ b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/Authenticaitons/BaererToken.cs @@ -0,0 +1,19 @@ +using System; + +namespace Win_in.Sfs.Wms.DataExchange.Fawtyg.MesAgent.Authenticaitons; + +public class BaererToken +{ + public string access_token { get; set; } + public long expires_in { get; set; } = 3600; + public string token_type { get; set; } + public string refresh_token { get; set; } + public string scope { get; set; } +} + +public class TokenInfo +{ + public BaererToken BaererToken { get; set; } = new(); + public DateTimeOffset GetTime { get; set; } = DateTimeOffset.Now; + public DateTimeOffset ExpireTime => GetTime.AddSeconds(BaererToken.expires_in); +} diff --git a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/Authenticaitons/ITokenService.cs b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/Authenticaitons/ITokenService.cs new file mode 100644 index 000000000..66c7736a7 --- /dev/null +++ b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/Authenticaitons/ITokenService.cs @@ -0,0 +1,9 @@ +using System.Threading.Tasks; +using Volo.Abp.DependencyInjection; + +namespace Win_in.Sfs.Wms.DataExchange.Fawtyg.MesAgent.Authenticaitons; + +public interface ITokenService : ITransientDependency +{ + Task GetTokenAsync(); +} diff --git a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/Authenticaitons/TokenService.cs b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/Authenticaitons/TokenService.cs new file mode 100644 index 000000000..eb1a54651 --- /dev/null +++ b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/Authenticaitons/TokenService.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Net.Http.Json; +using System.Threading.Tasks; +using Microsoft.Extensions.Configuration; +using Volo.Abp; + +namespace Win_in.Sfs.Wms.DataExchange.Fawtyg.MesAgent.Authenticaitons; + +public class TokenService : ITokenService +{ + private readonly IConfiguration _configuration; + + public TokenService(IConfiguration configuration) + { + _configuration = configuration; + } + + public virtual async Task GetTokenAsync() + { + const string routeString = "connect/token"; + + var baseUrl = _configuration["AuthServer:Authority"]; + var client_id = _configuration["Authentication:client_id"]; + var client_secret = _configuration["Authentication:client_secret"]; + var grant_type = _configuration["Authentication:grant_type"]; + var username = _configuration["Authentication:username"]; + var password = _configuration["Authentication:password"]; + var client = new HttpClient(); + client.BaseAddress = new Uri(baseUrl); + client.DefaultRequestHeaders.Accept.Clear(); + client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); + + var content = new FormUrlEncodedContent(new[] + { + new KeyValuePair("client_id",client_id), + new KeyValuePair("client_secret",client_secret), + new KeyValuePair("grant_type",grant_type), + new KeyValuePair("username",username), + new KeyValuePair("password",password), + }); + + var response = await client.PostAsync(routeString, content).ConfigureAwait(false); + Console.WriteLine(response.RequestMessage.RequestUri); + if (!response.IsSuccessStatusCode) + { + var str = await response.Content.ReadAsStringAsync().ConfigureAwait(false); + throw new UserFriendlyException(str); + } + + var dto = await response.Content.ReadFromJsonAsync().ConfigureAwait(false); + return dto; + + } +} diff --git a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/Client/WebApi.cs b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/Client/WebApi.cs new file mode 100644 index 000000000..def81ffb7 --- /dev/null +++ b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/Client/WebApi.cs @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net.Http; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Extensions.Options; +using StackExchange.Redis; +using Volo.Abp.Application.Services; +using Win_in.Sfs.Wms.DataExchange.Domain; +using Win_in.Sfs.Wms.DataExchange.Fawtyg.MesAgent; +using static Volo.Abp.Identity.Settings.IdentitySettingNames; + +namespace Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent.Client; +public class WebServiceAppService : IReader +{ + private readonly IHttpClientFactory _httpClientFactory; + private readonly IOptions _options; + + public WebServiceAppService(IHttpClientFactory httpClientFactory, IOptions options) + { + _httpClientFactory = httpClientFactory; + _options = options; + } + + public Task> ReadAsync() + { + throw new NotImplementedException(); + } + + + + + + /// + /// + /// + /// + /// + public async Task WebApi(int p_type) + { + + //var client = _httpClientFactory.CreateClient(); + //// 设置用户名和密码 + //var credentials = Convert.ToBase64String(Encoding.ASCII.GetBytes($"{username}:{password}")); + //client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", credentials); + //// 发送HTTP请求 + //var response = await client.GetAsync("https://example.com/api/data"); + //if (response.IsSuccessStatusCode) + //{ + // return await response.Content.ReadAsStringAsync(); + //} + // SoapClient + + + + + var address = _options.Value.AutoRemote.IpAddress; + var username = _options.Value.AutoRemote.UserName; + var password=_options.Value.AutoRemote.Password; + var token= _options.Value.AutoRemote.Token; + var client = _httpClientFactory.CreateClient(); + var credentials = Convert.ToBase64String(Encoding.ASCII.GetBytes($"{username}:{password}")); + client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", credentials); + var response = await client.GetAsync("https://example.com/api/data").ConfigureAwait(false); + if (response.IsSuccessStatusCode) + { + return await response.Content.ReadAsStringAsync(); + } + return "Error occurred"; + } +} diff --git a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/FawtygAutoMapperProfile.cs b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/FawtygAutoMapperProfile.cs new file mode 100644 index 000000000..0f32b55f7 --- /dev/null +++ b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/FawtygAutoMapperProfile.cs @@ -0,0 +1,181 @@ +using AutoMapper; +using Volo.Abp.AutoMapper; +using Win_in.Sfs.Shared.Application; +using Win_in.Sfs.Wms.DataExchange.Domain; +using Win_in.Sfs.Wms.DataExchange.WMS.BackFlushNote; +using Win_in.Sfs.Wms.DataExchange.WMS.MaterialRequest; +using Win_in.Sfs.Wms.DataExchange.WMS.PCK; +using Win_in.Sfs.Wms.DataExchange.WMS.ProductReceiptNote; +using Win_in.Sfs.Wms.DataExchange.WMS.ScrapNote; +using Win_in.Sfs.Wms.Store.Application.Contracts; + +namespace Win_in.Sfs.Wms.DataExchange.Fawtyg.MesAgent; + +public class FawtygAutoMapperProfile : Profile +{ + public FawtygAutoMapperProfile() + { + CreateMap(); + CreateMap(); + CreateMap(); + CreateMap(); + CreateMap(); + CreateMap(); + CreateMap() + + .Ignore(x => x.Number) + .Ignore(x => x.ProductionPlanNumber) + .Ignore(x => x.JobNumber) + .Ignore(x => x.WorkShop) //必填 + .Ignore(x => x.ReceiptType) + .Ignore(x => x.SourceNumber) + .Ignore(x => x.Worker) + .Ignore(x => x.Remark) + .Ignore(x => x.Details) + .Ignore(x => x.ExtraProperties); + + CreateMap() + .Ignore(x => x.Shift) + .Ignore(x => x.ProdLine) + .Ignore(x => x.BomVersion) + .Ignore(x => x.Status) + .Ignore(x => x.PackingCode) + .Ignore(x => x.ContainerCode) + .Ignore(x => x.StdPackQty) + .Ignore(x => x.Lot) //必填 + .Ignore(x => x.SupplierBatch) + .Ignore(x => x.ArriveDate) + .Ignore(x => x.ProduceDate) + .Ignore(x => x.ExpireDate) + .Ignore(x => x.ItemName) + .Ignore(x => x.ItemDesc1) + .Ignore(x => x.ItemDesc2) + + .Ignore(x => x.RecommendContainerCode) + .Ignore(x => x.RecommendPackingCode) + .Ignore(x => x.RecommendSupplierBatch) + .Ignore(x => x.RecommendArriveDate) + .Ignore(x => x.RecommendProduceDate) + .Ignore(x => x.RecommendExpireDate) + .Ignore(x => x.RecommendLot) + .Ignore(x => x.RecommendToLocationCode) + .Ignore(x => x.RecommendToLocationArea) + .Ignore(x => x.RecommendToLocationGroup) + .Ignore(x => x.RecommendToLocationErpCode) + .Ignore(x => x.RecommendToWarehouseCode) + .Ignore(x => x.RecommendQty) + + .Ignore(t => t.HandledContainerCode) + .Ignore(x => x.HandledPackingCode) + .Ignore(x => x.HandledSupplierBatch) + .Ignore(x => x.HandledArriveDate) + .Ignore(x => x.HandledProduceDate) + .Ignore(x => x.HandledExpireDate) + .Ignore(x => x.HandledLot) + .Ignore(x => x.HandledToLocationCode) + .Ignore(x => x.HandledToLocationArea) + .Ignore(x => x.HandledToLocationGroup) + .Ignore(x => x.HandledToLocationErpCode) + .Ignore(x => x.HandledToWarehouseCode) + .Ignore(x => x.HandledQty); + + CreateMap() + //必填 + .Ignore(x => x.Workshop) + .Ignore(x => x.ProdLine) + .Ignore(x => x.PreparationPlanNumber) + .Ignore(x => x.AutoSubmit) + .Ignore(x => x.AutoAgree) + .Ignore(x => x.AutoHandle) + .Ignore(x => x.AutoCompleteJob) + .Ignore(x => x.DirectCreateNote) + .Ignore(x => x.Worker) + .Ignore(x => x.ActiveDate) + .Ignore(x => x.Remark) + .Ignore(x => x.Details) + .Ignore(x => x.ExtraProperties); + + CreateMap() + .Ignore(x => x.ProdLine) + .Ignore(x => x.WorkStation) + .Ignore(x => x.ExpiredTime) + .Ignore(x => x.RequestStatus) + .Ignore(x => x.ToLocationErpCode) + .Ignore(x => x.Uom) + .Ignore(x => x.StdPackQty) + .Ignore(x => x.Remark) + .Ignore(x => x.ItemName) + .Ignore(x => x.ItemDesc1) + .Ignore(x => x.ItemDesc2); + + CreateMap() + .Ignore(x => x.Details) + .Ignore(x => x.ExtraProperties) + + .Ignore(x => x.JobNumber) + .Ignore(x => x.Workshop) + .Ignore(x => x.RequestNumber) + .Ignore(x => x.Worker) + .Ignore(x => x.ActiveDate) + ; + + CreateMap() + .Ignore(x => x.ItemName) + .Ignore(x => x.ItemDesc1) + .Ignore(x => x.ItemDesc2) + .Ignore(x => x.IssueTime) + .Ignore(x => x.ExpiredTime) + .Ignore(x => x.ProdLine) + .Ignore(x => x.WorkStation) + .Ignore(x => x.FromContainerCode) + .Ignore(x => x.ToContainerCode) + .Ignore(x => x.FromLot) + .Ignore(x => x.ToLot) + .Ignore(x => x.SupplierBatch) + .Ignore(x => x.ArriveDate) + .Ignore(x => x.ProduceDate) + .Ignore(x => x.ExpireDate) + .Ignore(x => x.FromLocationCode) + .Ignore(x => x.FromLocationErpCode) + .Ignore(x => x.FromWarehouseCode) + .Ignore(x => x.StdPackQty) + .Ignore(x => x.Remark) + .Ignore(x => x.ToPackingCode) + .Ignore(x => x.ToWarehouseCode) + .Ignore(x => x.FromStatus) + .Ignore(x => x.ToStatus) + .Ignore(x => x.Uom) + .IgnoreIHasRecommendAndHandledFrom(); + + CreateMap() + .Ignore(x => x.Detail) + ; + CreateMap(); + + CreateMap() + .Ignore(x => x.Details) + .Ignore(x => x.ExtraProperties) + .Ignore(x => x.Number) + .Ignore(x => x.JobNumber) + ; + CreateMap() + .Ignore(x => x.ItemName) + .Ignore(x => x.ItemDesc1) + .Ignore(x => x.ItemDesc2) + .Ignore(x => x.FromPackingCode) + .Ignore(x => x.ToPackingCode) + .Ignore(x => x.FromContainerCode) + .Ignore(x => x.ToContainerCode) + .Ignore(x => x.FromLot) + .Ignore(x => x.ToLot) + .Ignore(x => x.SupplierBatch) + .Ignore(x => x.ArriveDate) + .Ignore(x => x.ProduceDate) + .Ignore(x => x.ExpireDate) + .Ignore(x => x.ToWarehouseCode) + .Ignore(x => x.ToWarehouseCode) + .Ignore(x => x.Uom) + .Ignore(x => x.StdPackQty) + ; + } +} diff --git a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/HttpAuthorizationHandler.cs b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/HttpAuthorizationHandler.cs new file mode 100644 index 000000000..55ef3d385 --- /dev/null +++ b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/HttpAuthorizationHandler.cs @@ -0,0 +1,40 @@ +using System; +using Microsoft.Extensions.Configuration; +using Volo.Abp.DependencyInjection; +using Win_in.Sfs.Wms.DataExchange.Fawtyg.MesAgent.Authenticaitons; + +namespace Win_in.Sfs.Wms.DataExchange.Fawtyg.MesAgent; + +public class HttpAuthorizationHandler : ISingletonDependency +{ + private readonly ITokenService _tokenService; + private readonly IConfiguration _configuration; + + private static TokenInfo TokenInfo { get; } = new(); + + public HttpAuthorizationHandler(ITokenService tokenService, IConfiguration configuration) + { + _tokenService = tokenService; + _configuration = configuration; + } + + public bool IsLoggedIn() + { + if (!string.IsNullOrEmpty(TokenInfo.BaererToken?.access_token) && + TokenInfo.ExpireTime > DateTimeOffset.Now) + { + return true; + } + + var token = _tokenService.GetTokenAsync().Result; + TokenInfo.BaererToken = token; + TokenInfo.GetTime = DateTimeOffset.Now; + + return true; + } + + public string GetCurrentBearer() + { + return TokenInfo.BaererToken.access_token; + } +} diff --git a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/Incoming/InjectionMoldingRequestReader.cs b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/Incoming/InjectionMoldingRequestReader.cs new file mode 100644 index 000000000..cc8fdbf53 --- /dev/null +++ b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/Incoming/InjectionMoldingRequestReader.cs @@ -0,0 +1,218 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net.Http; +using System.Text; +using System.Text.Json; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; +using Volo.Abp.Application.Services; +using Win_in.Sfs.Basedata.Application.Contracts; +using Win_in.Sfs.Shared.Domain; +using Win_in.Sfs.Shared.Domain.Shared; +using Win_in.Sfs.Wms.DataExchange.Domain; +using Win_in.Sfs.Wms.DataExchange.Domain.Shared; +using Win_in.Sfs.Wms.DataExchange.WMS.PCK; +using Win_in.Sfs.Wms.Store.Application.Contracts; +using System.Text.Json.Serialization; +using System.IdentityModel.Tokens.Jwt; + +namespace Win_in.Sfs.Wms.DataExchange.Fawtyg.MesAgent.Incoming; + +public class InjectionMoldingRequestReader : IReader +{ + + private readonly IInjectionRequestAppService _injectionRequest; + private readonly IItemBasicAppService _itemService; + private readonly ILocationAppService _locService; + + private readonly IIncomingFromExternalManager _incomingFromExternalManager; + private readonly ILogger _logger; + private readonly IOptions _options; + private readonly IHttpClientFactory _httpClientFactory; + + + public InjectionMoldingRequestReader( + IInjectionRequestAppService injectionRequest + , IIncomingFromExternalManager incomingFromExternalManager + , ILogger logger + ,IOptions options + , IHttpClientFactory httpClientFactory + ,IItemBasicAppService itemService + ,ILocationAppService locService + + ) + { + _injectionRequest = injectionRequest; + _incomingFromExternalManager = incomingFromExternalManager; + _logger = logger; + _options = options; + _httpClientFactory = httpClientFactory; + _itemService=itemService; + _locService = locService; + + } + + public virtual async Task> ReadAsync() + { + try + { + var jobCondition = new SfsStoreRequestInputBase(); + Filter filter = new Filter() + { + Action = "<>", + Column = "JobStatus", + Logic = EnumFilterLogic.And.ToString(), + Value = ((int)EnumJobStatus.Done).ToString() + }; + jobCondition.Condition.Filters.Add(filter); + var jobs = await _injectionRequest.GetAllListByFilterAsync(jobCondition).ConfigureAwait(false); + List joblist = new List(); + if (jobs.Count == 0) + { + string camera =await ReaderCameraApi().ConfigureAwait(false); + + List cameraList = new List(); + + if (camera == "Error occured") + { + _logger.LogError($"没有读取到摄像头信息{DateTime.Now},请检查网络"); + return new List(); + } + + + + cameraList = System.Text.Json.JsonSerializer.Deserialize>(camera);//camera转注塑叫料明细任务数据 + + + InjectionRequestEditInput input=new InjectionRequestEditInput(); + List injectionRequestDetails = new List(); + + foreach (var job in cameraList) { + + var detailInput = new InjectionRequestDetailInput() + { + ItemCode = job.ItemCode, + ToLocationCode = job.ToLocCode, + Qty = job.Qty, + }; + injectionRequestDetails.Add(detailInput); + } + input.Details.AddRange(injectionRequestDetails); + var errors=await BindAsync(input.Details).ConfigureAwait(false);//零件仓库赋值 + if (errors.Count > 0) + { + foreach (var error in errors) { + _logger.LogError(error); + } + return new List(); + + } + await _injectionRequest.CreateAsync(input).ConfigureAwait(false); + } + } + catch (Exception ex) + { + _logger.LogError(ex.Message); + } + return new List(); + } + + private async Task> BindAsync(List p_list) + { + List errors = new List(); + + foreach (var request in p_list) + { + var itm =await _itemService.GetByCodeAsync(request.ItemCode).ConfigureAwait(false); + if(itm == null) { errors.Add($"编号:{request.ItemCode}零件表中没找到!" ); }else + { + request.ItemDesc1 = itm.Desc1; + request.ItemDesc2 = itm.Desc2; + request.ItemName = itm.Name; + + } + var loc = await _locService.GetByCodeAsync(request.ToLocationCode).ConfigureAwait(false); + if (loc == null) { errors.Add($"编号:{request.ToLocationCode}库位表中没找到!"); }else + { + request.ToLocationCode = loc.Code; + request.ToLocationGroup = loc.LocationGroupCode; + request.ToLocationErpCode = loc.ErpLocationCode; + request.ToWarehouseCode= loc.WarehouseCode; + } + } + + + return errors; + + } + + + + + + /// + /// + /// + /// + /// + public async Task ReaderCameraApi() + { + + var address = _options.Value.AutoRemote.IpAddress; + var username = _options.Value.AutoRemote.UserName; + var password = _options.Value.AutoRemote.Password; + var token = _options.Value.AutoRemote.Token; + var client = _httpClientFactory.CreateClient(); + var credentials = Convert.ToBase64String(Encoding.ASCII.GetBytes($"{username}:{password}")); + client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", credentials); + var response = await client.GetAsync("https://example.com/api/data").ConfigureAwait(false); + if (response.IsSuccessStatusCode) + { + return await response.Content.ReadAsStringAsync().ConfigureAwait(false); + } + + return "Error occurred"; + } + + public class InjectionRequest + { + /// + /// 零件吗 + /// + public string ItemCode { get; set; } + /// + /// 零件名称 + /// + public string ItemName { get; set; } + /// + /// 发运库位 + /// + public string ToLocCode { get; set; } + /// + /// 来源库位 + /// + public string FromLocCode { get; set; } + /// + /// 数量 + /// + public decimal Qty { get; set; } + + + + + + } + + + + + + + + + + +} diff --git a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/Incoming/InjectionMoldingTaskIncomingBackgroundWorker.cs b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/Incoming/InjectionMoldingTaskIncomingBackgroundWorker.cs new file mode 100644 index 000000000..0c925031a --- /dev/null +++ b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/Incoming/InjectionMoldingTaskIncomingBackgroundWorker.cs @@ -0,0 +1,51 @@ +using System; +using System.Threading.Tasks; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; +using Volo.Abp.BackgroundWorkers; +using Volo.Abp.Threading; +using Volo.Abp.Uow; +using Win_in.Sfs.Wms.DataExchange.Fawtyg.MesAgent.Incoming; +using Win_in.Sfs.Wms.Store.Application.Contracts; + +namespace Win_in.Sfs.Wms.DataExchange.Fawtyg.MesAgent; + +public class InjectionMoldingTaskIncomingBackgroundWorker : AsyncPeriodicBackgroundWorkerBase +{ + private readonly string Incoming = "InjectionMoldingTask Incoming"; + + private readonly IOptions _options; + + public InjectionMoldingTaskIncomingBackgroundWorker( + AbpAsyncTimer timer, + IOptions options, + IServiceScopeFactory serviceScopeFactory + ) : base(timer, serviceScopeFactory) + { + _options = options; + Timer.Period = options.Value.IncomingOptions.PeriodSeconds * 1000; //default 10 minutes + } + + [UnitOfWork] + protected override async Task DoWorkAsync(PeriodicBackgroundWorkerContext workerContext) + { + Logger.LogInformation($"Starting: Handling {Incoming}"); + if (!_options.Value.IncomingOptions.Active) + { + Logger.LogInformation($"{Incoming} is not active!"); + return; + } + int min = DateTime.Now.Hour*60+ DateTime.Now.Minute;//第二天00:05:00与当天23:55:00不执行避免tyrpnumber重复 + if ( (24*60-5)<= min || min <= 5) + { + Logger.LogInformation($"{Incoming} 时间小于第二天00:05:00大于当天23:55:00"); + return; + } + Logger.LogInformation($"注塑任务");//缴库 + var reader = workerContext.ServiceProvider.GetService(); + await reader.ReadAsync().ConfigureAwait(false); + Logger.LogInformation($"Completed: Handling {Incoming}"); + } + +} diff --git a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/InjectionMoldingTaskAgentHostedService.cs b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/InjectionMoldingTaskAgentHostedService.cs new file mode 100644 index 000000000..e74443d3b --- /dev/null +++ b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/InjectionMoldingTaskAgentHostedService.cs @@ -0,0 +1,40 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Extensions.Hosting; +using Volo.Abp; + +namespace Win_in.Sfs.Wms.DataExchange.Fawtyg.MesAgent; + +public class InjectionMoldingTaskAgentHostedService : IHostedService +{ + private readonly IAbpApplicationWithExternalServiceProvider _application; + private readonly IServiceProvider _serviceProvider; + private readonly InjectionMoldingTaskAgentService _agentService; + + public InjectionMoldingTaskAgentHostedService( + IAbpApplicationWithExternalServiceProvider application, + IServiceProvider serviceProvider, + InjectionMoldingTaskAgentService agentService) + { + _application = application; + _serviceProvider = serviceProvider; + _agentService = agentService; + } + + public Task StartAsync(CancellationToken cancellationToken) + { + _application.Initialize(_serviceProvider); + + _agentService.Start(); + + return Task.CompletedTask; + } + + public Task StopAsync(CancellationToken cancellationToken) + { + _application.Shutdown(); + + return Task.CompletedTask; + } +} diff --git a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/InjectionMoldingTaskAgentModule.cs b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/InjectionMoldingTaskAgentModule.cs new file mode 100644 index 000000000..a147e55cd --- /dev/null +++ b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/InjectionMoldingTaskAgentModule.cs @@ -0,0 +1,167 @@ +using System; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Threading.Tasks; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Polly; +using Volo.Abp; +using Volo.Abp.Account; +using Volo.Abp.Autofac; +using Volo.Abp.AutoMapper; +using Volo.Abp.BackgroundJobs; +using Volo.Abp.BackgroundWorkers; +using Volo.Abp.EntityFrameworkCore; +using Volo.Abp.Http.Client; +using Volo.Abp.Modularity; +using Win_in.Sfs.Basedata.Application.Contracts; +using Win_in.Sfs.Label.Application.Contracts; +using Win_in.Sfs.Shared.Host; + +using Win_in.Sfs.Wms.DataExchange.EntityFrameworkCore; + +using Win_in.Sfs.Wms.Inventory.Application.Contracts; +using Win_in.Sfs.Wms.Store.Application.Contracts; + +namespace Win_in.Sfs.Wms.DataExchange.Fawtyg.MesAgent; + +[DependsOn( + typeof(AbpAutofacModule), + typeof(AbpAutoMapperModule), + typeof(AbpBackgroundJobsModule), + typeof(AbpBackgroundWorkersModule), + typeof(AbpHttpClientModule) +)] +[DependsOn( + typeof(StoreApplicationContractsModule), + typeof(InventoryApplicationContractsModule), + typeof(LabelApplicationContractsModule), + typeof(DataExchangeDomainModule), + typeof(DataExchangeEntityFrameworkCoreModule), + //typeof(DataExchangeDomainFawtygMesModule), + //typeof(DataExchangeEntityFrameworkCoreFawtygModule), + typeof(AbpAccountApplicationContractsModule) + )] +public class InjectionMoldingTaskAgentModule : AbpModule +{ + public override void PreConfigureServices(ServiceConfigurationContext context) + { + + PreConfigure(options => + { + //Polly 重试3次 + options.ProxyClientBuildActions.Add((remoteServiceName, clientBuilder) => + { + clientBuilder.AddTransientHttpErrorPolicy(policyBuilder => + policyBuilder.WaitAndRetryAsync( + 3, + i => TimeSpan.FromSeconds(Math.Pow(2, i)) + ) + ); + }); + + //默认添加Authorization Header: Bearer Token + options.ProxyClientActions.Add((a, s, h) => + { + var httpAuthorizationHandler = s.GetService(); + if (httpAuthorizationHandler != null && httpAuthorizationHandler.IsLoggedIn()) + { + h.DefaultRequestHeaders.Authorization = + new AuthenticationHeaderValue("Bearer", httpAuthorizationHandler.GetCurrentBearer()); + } + }); + }); + + } + + public override void ConfigureServices(ServiceConfigurationContext context) + { + var configuration = context.Services.GetConfiguration(); + var env = context.Services.GetSingletonInstance(); + + context.SetConsoleTitleOfConsoleApp("MesAgent", env.EnvironmentName); + + ConfigureDbContext(); + + ConfigureOptions(configuration); + + context.Services.AddHostedService(); + + ConfigureAutoMapper(context); + + ConfigureHttpClientProxies(context); + + ConfigureAuthentication(context, configuration); + } + + private void ConfigureDbContext() + { + Configure(options => + { + options.UseSqlServer(); + //options.UseSqlServer(); + }); + } + + private void ConfigureOptions(IConfiguration configuration) + { + Configure(configuration.GetSection("InjectionMoldingTaskOptions")); + } + + private void ConfigureAutoMapper(ServiceConfigurationContext context) + { + context.Services.AddAutoMapperObjectMapper(); + Configure(options => { options.AddMaps(validate: false); }); + } + + private static void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration) + { + var isAlwaysAllowAuthorization = configuration.GetValue("AuthServer:AlwaysAllowAuthorization"); + if (isAlwaysAllowAuthorization) + { + //绕过授权服务,用于测试 + context.Services.AddAlwaysAllowAuthorization(); + } + else + { + context.Services.AddHttpClient(); + context.Services.AddAuthentication() + .AddJwtBearer(options => + { + options.Authority = configuration["AuthServer:Authority"]; + options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]); + options.Audience = "DataExchange"; + options.BackchannelHttpHandler = new HttpClientHandler + { + ServerCertificateCustomValidationCallback = + HttpClientHandler.DangerousAcceptAnyServerCertificateValidator + }; + }); + } + } + + private static void ConfigureHttpClientProxies(ServiceConfigurationContext context) + { + context.Services.AddHttpClientProxies( + typeof(BasedataApplicationContractsModule).Assembly, + "BaseData" + ); + context.Services.AddHttpClientProxies( + typeof(StoreApplicationContractsModule).Assembly, + "Store" + ); + context.Services.AddHttpClientProxies( + typeof(LabelApplicationContractsModule).Assembly, + "Label" + ); + } + public override void OnApplicationInitialization( + ApplicationInitializationContext context) + { + + context.AddBackgroundWorkerAsync(); + context.AddBackgroundWorkerAsync(); + } +} + diff --git a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/InjectionMoldingTaskAgentService.cs b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/InjectionMoldingTaskAgentService.cs new file mode 100644 index 000000000..ca7ca6964 --- /dev/null +++ b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/InjectionMoldingTaskAgentService.cs @@ -0,0 +1,12 @@ +using System; +using Volo.Abp.DependencyInjection; + +namespace Win_in.Sfs.Wms.DataExchange.Fawtyg.MesAgent; + +public class InjectionMoldingTaskAgentService : ITransientDependency +{ + public void Start() + { + Console.WriteLine("InjectionMoldingTask data exchange service has started..."); + } +} diff --git a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/InjectionMoldingTaskOptions.cs b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/InjectionMoldingTaskOptions.cs new file mode 100644 index 000000000..8a21a7193 --- /dev/null +++ b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/InjectionMoldingTaskOptions.cs @@ -0,0 +1,39 @@ +using System.Net; + +namespace Win_in.Sfs.Wms.DataExchange.Fawtyg.MesAgent; + +public class InjectionMoldingTaskOptions +{ + public DataExchangeOptions IncomingOptions { get; set; } + public DataExchangeOptions OutgoingOptions { get; set; } + + public InjectionAutoRemote AutoRemote { get; set; } + + + + +} + +public class InjectionAutoRemote +{ + + public string IpAddress { set; get; } + public string UserName { set; get; } + public string Password { set; get; } + public string Token { set; get; } + +} + + + + + +public class DataExchangeOptions +{ + public bool Active { get; set; } + public int PeriodSeconds { get; set; } = 60; + public int BatchSize { get; set; } = 10; + public int MaxCount { get; set; } = 100; + public int RetryTimes { get; set; } = 3; + +} diff --git a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/Outgoing/InjectionMoldingTaskOutgoingBackgroundWorker.cs b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/Outgoing/InjectionMoldingTaskOutgoingBackgroundWorker.cs new file mode 100644 index 000000000..65c92619e --- /dev/null +++ b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/Outgoing/InjectionMoldingTaskOutgoingBackgroundWorker.cs @@ -0,0 +1,54 @@ +using System.Threading.Tasks; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; +using Volo.Abp.BackgroundWorkers; +using Volo.Abp.Threading; +using Volo.Abp.Uow; + + +namespace Win_in.Sfs.Wms.DataExchange.Fawtyg.MesAgent; + +public class InjectionMoldingTaskOutgoingBackgroundWorker : AsyncPeriodicBackgroundWorkerBase +{ + private readonly string Outgoing = "InjectionMoldingTaskOptions Outgoing"; + + private readonly IOptions _options; + + public InjectionMoldingTaskOutgoingBackgroundWorker( + AbpAsyncTimer timer + + + + , IOptions options + , IServiceScopeFactory serviceScopeFactory + ) : base(timer, serviceScopeFactory) + { + _options = options; + Timer.Period = options.Value.OutgoingOptions.PeriodSeconds * 1000; //default 10 minutes + + } + + [UnitOfWork] + protected override async Task DoWorkAsync(PeriodicBackgroundWorkerContext workerContext) + { + Logger.LogInformation($"Starting: Handling {Outgoing}"); + if (!_options.Value.IncomingOptions.Active) + { + Logger.LogInformation($"{Outgoing} is not active!"); + return; + } + + Logger.LogInformation($"Write Issue"); + + + + //var issueConvert = workerContext.ServiceProvider.GetRequiredService(); + //var issueNoteList = await issueConvert.ConvertAsync().ConfigureAwait(false); + //var issueWriter = workerContext.ServiceProvider.GetRequiredService(); + //await issueWriter.WriteAsync(issueNoteList).ConfigureAwait(false); + + Logger.LogInformation($"Completed: Handling {Outgoing}"); + } + +} diff --git a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/Program.cs b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/Program.cs new file mode 100644 index 000000000..633c4d089 --- /dev/null +++ b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/Program.cs @@ -0,0 +1,53 @@ +using System; +using System.Threading.Tasks; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Serilog; + +namespace Win_in.Sfs.Wms.DataExchange.Fawtyg.MesAgent; + +public class Program +{ + public static async Task Main(string[] args) + { + IConfigurationRoot configuration = + new ConfigurationBuilder() + .AddJsonFile("serilogsettings.json", false, true) + .Build(); + + Log.Logger = new LoggerConfiguration() + .ReadFrom.Configuration(configuration) + .CreateLogger(); + + try + { + Log.Information("Starting console host."); + await CreateHostBuilder(args).RunConsoleAsync().ConfigureAwait(false); + return 0; + } + catch (Exception ex) + { + Log.Fatal(ex, "Host terminated unexpectedly!"); + return 1; + } + finally + { + Log.CloseAndFlush(); + } + + } + + internal static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .UseAutofac() + .UseSerilog() + .ConfigureAppConfiguration((context, config) => + { + //setup your additional configuration sources + }) + .ConfigureServices((hostContext, services) => + { + services.AddApplication(); + }); +} diff --git a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent.csproj b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent.csproj new file mode 100644 index 000000000..12eff23b3 --- /dev/null +++ b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent.csproj @@ -0,0 +1,43 @@ + + + + Exe + net6.0 + latest + + + + + + + + + + + + + + + + + + + + + + + + + + + Always + PreserveNewest + + + PreserveNewest + true + PreserveNewest + + + + diff --git a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/appsettings.json b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/appsettings.json new file mode 100644 index 000000000..e04cfaf9b --- /dev/null +++ b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/appsettings.json @@ -0,0 +1,88 @@ +{ + "ConnectionStrings": { + "Default": "Server=10.164.113.32,1818\\SHDB;Database=Wms_Dy_ShangHai;uid=ShWmsUser;pwd=Faty@Wms_20230413#SH;TrustServerCertificate=True;Encrypt=false", + "DataExchange": "Server=10.164.113.32,1818\\SHDB;Database=Wms_DataExchange_Main_Dy_ShangHai;uid=ShWmsUser;pwd=Faty@Wms_20230413#SH;TrustServerCertificate=True;Encrypt=false", + "MES": "Server=10.164.113.32,1818\\SHDB;Database=MES_SH;uid=ShWmsUser;pwd=Faty@Wms_20230413#SH;TrustServerCertificate=True;Encrypt=false" + }, + + "AuthServer": { + "Authority": "http://dev.ccwin-in.com:60083", + "RequireHttpsMetadata": "false", + "SwaggerClientId": "admin", + "SwaggerClientSecret": "1q2w3E*", + "grant_type": "password", + "AlwaysAllowAuthorization": true + }, + + "Authentication": { + "client_id": "Auth_App", + "client_secret": "1q2w3e*", + "grant_type": "password", + "username": "jiekou", + "password": "1q2w3E*" + }, + + + "RemoteServices": { + + + "Inventory": { + "BaseUrl": "http://localhost:59095/" + }, + "Job": { + "BaseUrl": "http://localhost:59095/" + }, + "Label": { + "BaseUrl": "http://dev.ccwin-in.com:60082/" + }, + "Message": { + "BaseUrl": "http://dev.ccwin-in.com:60082/" + }, + "Store": { + "BaseUrl": "http://localhost:59095/" + } + + }, + + + + + + //"RemoteServices": { + // "BaseData": { + // "BaseUrl": "http://10.164.113.31:60084/" + // }, + // "Store": { + // "BaseUrl": "http://10.164.113.31:60085/" + // }, + // "Label": { + // "BaseUrl": "http://10.164.113.31:60082/" + // } + + //}, + "InjectionMoldingTaskOptions": { + + "AutoRemote": { + "IpAddress": "http://10.164.113.31:60085/", + "UserName": "", + "Password": "", + "Token": "" + + }, + + "IncomingOptions": { + "Active": true, + "PeriodSeconds": 10, + "BatchSize": 10, + "MaxCount": 100, + "RetryTimes": 3 + }, + "OutgoingOptions": { + "Active": true, + "PeriodSeconds": 10, + "BatchSize": 10, + "MaxCount": 100, + "RetryTimes": 3 + } + } +} diff --git a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/serilogsettings.json b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/serilogsettings.json new file mode 100644 index 000000000..c07a351db --- /dev/null +++ b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/serilogsettings.json @@ -0,0 +1,39 @@ +{ + "Serilog": { + "Using": [ "Serilog.Sinks.File", "Serilog.Sinks.Async", "Serilog.Sinks.Console", "Serilog.Sinks.MSSqlServer" ], + "MinimumLevel": { + "Default": "Debug", + "Override": { + "Microsoft": "Information", + "Microsoft.EntityFrameworkCore": "Warning" + } + }, + "WriteTo": [ + { + "Name": "Async", + "Args": { + "configure": [ + { + "Name": "File", + "Args": { + "path": "..//Logs//MesAgent//MesAgent_.log", + "rollingInterval": "Day", + "fileSizeLimitBytes": "52428800", + "rollOnFileSizeLimit": "true", + "restrictedToMinimumLevel": "Debug" + } + } + ] + } + }, + { + "Name": "Console", + "Args": { + "restrictedToMinimumLevel": "Debug", + "outputTemplate": "{Timestamp:HH:mm:ss.fff} [{Level:u3}] {Message} {NewLine}{Exception}" + } + } + ], + "Enrich": [ "FromLogContext", "WithMachineName", "WithProcessId", "WithThreadId" ] + } +} \ No newline at end of file diff --git a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/tempkey.jwk b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/tempkey.jwk new file mode 100644 index 000000000..a39a188d3 --- /dev/null +++ b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/tempkey.jwk @@ -0,0 +1 @@ +{"AdditionalData":{},"Alg":"RS256","Crv":null,"D":"oAL-OdQF7tHgMYho6jsPrxtuvDFdF0T6IRBihCrz0b_IB-aqWTVMTe5uilRgmY3aAzQC8mCmkFamneGLZy7QplZlOc57TSv64zAeRBSCyIfn1gvWCj7_p6qI7lElu0QHwnaErfDHsV47sIukRf_q2sE9ZVfHBYKNMLR_kbZZlzs3YZCIiiJwFbE6VKZ2HH2s9gf-DSpJ5WIGnyeAswZflNjkQdUbUl8tJCOHyi7BC60sCoPqASEeRIyarMG7AKjMw44rTs5TGpTp8uoPg4XhV4xP4LzX436gFFjrhf_EOo5UI2d6UCLwQNGWmrpWjLUAs7QjjcxH4sSaniDR51DTnQ","DP":"ayJZOPaME1B4c7tLZJdTpXCF5AUXUnS-Bq_buYxZAYXLaOdxJHjltCSLTdQ7p6Y1Y4tISg74uXFzmx18ERbi5WNMzhsGAezSDV_PWePu6Ujpm--F7TcE3aYRs0srsnbFWq57W2DusxwjWr_a-g08zP10O4IJP5WmE5rd4xQDO_s","DQ":"Q80U7ZCxMDcpmO87VHYS9sIZdoHu7PXK7mdjxTuTXYJTOE4BBMwacF-MbPO_Smno9-p32RnH7rJp8dpSevU5sUwT-xEPpGbJILBnFGesmBMiOiK5aKBhZ60T4gw6VNf_iIBHuIYB9MGybJfbf-7iZ7aGgNGdwr5XKITDahq_5Jk","E":"AQAB","K":null,"KeyId":"D6178DB50135E8E220498A66064AEF08","Kid":"D6178DB50135E8E220498A66064AEF08","Kty":"RSA","N":"tqqOx4HSDkuiEXAzYdJxsXyhXnXYaezE5KCHy4Mx6lFDmJfx6IQf9dhcCrumCga_1PfxXdV0R2OHo4i67yiQm-0XRgx7W87S6LR7ARraVme25SiOnZEtwlauYvEXz0cCR-bhvLwLTOPjptSKHl5DVl8Lcw7PjBpJLDP1zqCFMgU-KVusNoaruLFBb3zdgYt7ovzBOj94UkRAy5cLmAJKh73IOyExM-fO7rTR7dyc1jstNbUGhdX3fui3f0hUGsNOCvIyaaJn2SuGbSo5loWHBFtNkLHrXD9dLirJaXqkP7zK4rAYu0KrFqUp9LA_RNK2QLD2LnucCsmLPzz3jnpufQ","Oth":null,"P":"4D4K7xT2s-TJyUzbFZDsGPzD1kLbuB3lQnp6_tkHg0GrXgojf-obIviQPqhKmOQN-qAq0hoSVYXXmUCf-iMsV0XM6UcChI6GSO3dAQyB-e6TdCIw6kSEEJrhr6tadwOnOFb6HssX7n5nxw47dJV7ORQ6tjrTGi3IdlTUl8uo1-c","Q":"0Ikp47a-_VxvflocNK_6YyeNukMOjEmGqIQWQgXGJv6dd2-_ox6BztA9qcmmfuKU5xmD9aOlj_WIATRi3meSH7DdiGYCd-56QDj-Lvwej6_27rX8lISQ2D0TQqgPZCGAE_1PvIAmYfv0D7GrCFevJrJ2Z5zLC6GK61WjC0V3afs","QI":"Xk7BkXcsdP-RQc1VaJqQ9krQftyYlsxM6hC6x80y7fi7tR6g68GwrNdIw-dPE_bHQuD7DKwq8FFMROzR4t2cRTOGhlKj7VgJ8N8soXzXxUAmerhOXMJ1nJOAnNBSTglVFVUqdZMgOfPbClgg29tRBPQgrKnN_-yzXgglCB6rqPU","Use":null,"X":null,"X5t":null,"X5tS256":null,"X5u":null,"Y":null,"KeySize":2048,"HasPrivateKey":true,"CryptoProviderFactory":{"CryptoProviderCache":{},"CustomCryptoProvider":null,"CacheSignatureProviders":true,"SignatureProviderObjectPoolCacheSize":32}} \ No newline at end of file diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Boms/BomManager.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Boms/BomManager.cs index c3f7120bd..692ce3ef0 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Boms/BomManager.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Boms/BomManager.cs @@ -129,7 +129,7 @@ public class BomManager : DomainService, IBomManager { await _repository.BulkDeleteAsync(deleteEntities).ConfigureAwait(false); } - + Cache.Boms.Clear(); await _repository.BulkMergeAsync(mergeEntities).ConfigureAwait(false); } diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Caches/Cache.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Caches/Cache.cs index 0d3bb63ea..4beb6e0d7 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Caches/Cache.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Caches/Cache.cs @@ -9,6 +9,8 @@ namespace Win_in.Sfs.Basedata.Caches; public static class Cache { public static List Boms = new List(); + + public static async void BomsLifeCycle(int lifetime) { var reassigner = new Reassigner(DateTime.Now,new TimeSpan(0,5,0)); diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/Kittings/KittingDbContextModelCreatingExtensions.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/Kittings/KittingDbContextModelCreatingExtensions.cs index 8c4d1a813..bede84ba0 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/Kittings/KittingDbContextModelCreatingExtensions.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/Kittings/KittingDbContextModelCreatingExtensions.cs @@ -49,7 +49,7 @@ public static class KittingDbContextModelCreatingExtensions //Indexes - //b.HasMany(q => q.Details).WithOne().HasForeignKey(d => d.MasterID).IsRequired(); + // b.HasMany(q => q.).WithOne().HasForeignKey(d => d.MasterID).IsRequired(); diff --git a/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Application/Balances/BalanceAppService.cs b/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Application/Balances/BalanceAppService.cs index a38fc1c14..3e911266f 100644 --- a/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Application/Balances/BalanceAppService.cs +++ b/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Application/Balances/BalanceAppService.cs @@ -853,11 +853,9 @@ public class BalanceAppService var entities = await _repository.GetPagedListAsync(expression, input.SkipCount, input.MaxResultCount, input.Sorting, true).ConfigureAwait(false); var list = ObjectMapper.Map, List>(entities); - //var hasDetails = typeof(TEntity) is SfsMasterAggregateRootBase detailEntity; var tt = typeof(Balance).GetBaseClasses(typeof(SfsMasterAggregateRootBase)); var hasDetails = tt.Length > 0 ? true : false; - if (list.Count > 0) { var itemCodes = list.Select(t => t.ItemCode).Distinct(); @@ -870,7 +868,6 @@ public class BalanceAppService }); } } - return ExportImportService.Export(list, detailsProptyName: hasDetails ? nameof(EmptyDetail) : null); } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNoteAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNoteAppService.cs index 3a3ea6b86..b4850d5fd 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNoteAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNoteAppService.cs @@ -92,8 +92,8 @@ public class CustomerProductionReturnNoteAppService : itm.ToStatus=EnumInventoryStatus.OK; itm.FromLocationArea = "OK"; itm.FromLocationErpCode= "OK"; - itm.FromLot = "NONE"; - itm.FromPackingCode = "NONE"; + itm.FromLot = ""; + itm.FromPackingCode = ""; itm.FromWarehouseCode = "OK"; itm.FromLocationGroup = "OK"; itm.FromContainerCode = "OK"; diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/MesNotes/MesNoteAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/MesNotes/MesNoteAppService.cs index 6761b6b39..3b7c91e39 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/MesNotes/MesNoteAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/MesNotes/MesNoteAppService.cs @@ -92,7 +92,7 @@ public class MesNoteAppService : var first = balanceLst.FirstOrDefault(); if (first != null) { - if (detail.Qty <= first.Qty) + if (detail.Qty > first.Qty) { throw new UserFriendlyException($"库存数量不足"); } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/MesNoteEventHandler.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/MesNoteEventHandler.cs index ec09b362f..8e2cd13d9 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/MesNoteEventHandler.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/MesNoteEventHandler.cs @@ -78,7 +78,13 @@ public class MesNoteEventHandler var transferLogs = new List(); foreach (var detail in MesNote.Details.Where(detail => detail.Qty != 0)) { - + + detail.FromPackingCode = ""; + detail.ToPackingCode = ""; + detail.FromContainerCode = ""; + detail.FromLot = ""; + detail.ToContainerCode = ""; + var transferLog = ObjectMapper.Map(detail); transferLog.TransType = Enum.Parse(MesNote.Type); ; transferLog.TransSubType = EnumTransSubType.None; diff --git a/be/WZC2.sln b/be/WZC2.sln index 6daccb5d3..8bc88dfde 100644 --- a/be/WZC2.sln +++ b/be/WZC2.sln @@ -264,6 +264,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Win_in.Sfs.Wms.Store.Domain EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "解决方案项", "解决方案项", "{1295E21B-E615-4C99-93A3-218BB082F610}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent", "DataExchange\Fawtyg\Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent\Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent.csproj", "{1552D8A4-E897-4017-B4C4-834E183AB066}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -650,6 +652,10 @@ Global {666C8442-DF6C-4F1E-855D-851777C2395A}.Debug|Any CPU.Build.0 = Debug|Any CPU {666C8442-DF6C-4F1E-855D-851777C2395A}.Release|Any CPU.ActiveCfg = Release|Any CPU {666C8442-DF6C-4F1E-855D-851777C2395A}.Release|Any CPU.Build.0 = Release|Any CPU + {1552D8A4-E897-4017-B4C4-834E183AB066}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1552D8A4-E897-4017-B4C4-834E183AB066}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1552D8A4-E897-4017-B4C4-834E183AB066}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1552D8A4-E897-4017-B4C4-834E183AB066}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -778,6 +784,7 @@ Global {637A1F71-B29E-4247-B1C6-695790CE0525} = {F17D371C-DF73-4CD7-8BE1-3254110FB20B} {EBC2FEC4-BCCC-4430-953B-2712C0416BC6} = {ED39BD34-B85D-4683-BF54-68996C248C1A} {666C8442-DF6C-4F1E-855D-851777C2395A} = {4D8578B9-A0E1-4A0D-8044-1F417620C34A} + {1552D8A4-E897-4017-B4C4-834E183AB066} = {BA78EB96-38FD-4488-B9AA-9CF85481BC36} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {7A77C2A7-D19D-40B4-AE22-85473900E6F9}