diff --git a/Controllers/IsAliveController.cs b/Controllers/IsAliveController.cs new file mode 100644 index 0000000..aa5e51c --- /dev/null +++ b/Controllers/IsAliveController.cs @@ -0,0 +1,16 @@ +using Microsoft.AspNetCore.Mvc; + +namespace WMS_GIRAF_Interface.Controllers +{ + [ApiController, Route("api/[controller]")] + public class IsAliveController : ControllerBase + { + + [HttpGet] + public bool SendWmsStatus() + { + + return true; + } + } +} diff --git a/Controllers/SendInputStorageLinePathStateController.cs b/Controllers/SendInputStorageLinePathStateController.cs new file mode 100644 index 0000000..4ac0cda --- /dev/null +++ b/Controllers/SendInputStorageLinePathStateController.cs @@ -0,0 +1,45 @@ +using Microsoft.AspNetCore.Mvc; +using WMS_GIRAF_Interface.Models; +using WMS_GIRAF_Interface.Repositories.Implement; +using WMS_GIRAF_Interface.Repositories.Interface; + +namespace WMS_GIRAF_Interface.Controllers +{ + + [ApiController, Route("api/[controller]")] + public class SendInputStorageLinePathStateController :ControllerBase + { + private readonly IdestinationIdRepository _destinationIdRepository; + + public SendInputStorageLinePathStateController(IdestinationIdRepository destinationIdRepository) + { + _destinationIdRepository = destinationIdRepository; + } + /// + /// 更新入库路径状态 + /// + [HttpPost] + public void GetInputStatusFromGiraf(InputStorageLinePathState.Rootobject inputStorageLinePathState ) + { + //根据LineNumber获取巷道信息 + if (inputStorageLinePathState.LineNumber!=0) + { + var LaneWayInfo = _destinationIdRepository.GetDestinationId(inputStorageLinePathState.LineNumber); + if (LaneWayInfo!=null) + { + + } + + } + else + { + //tlt:line number不可以为0 + + } + + } + + } + + +} diff --git a/Controllers/WeatherForecastController.cs b/Controllers/WeatherForecastController.cs new file mode 100644 index 0000000..7c3f49e --- /dev/null +++ b/Controllers/WeatherForecastController.cs @@ -0,0 +1,33 @@ +using Microsoft.AspNetCore.Mvc; + +namespace WMS_GIRAF_Interface.Controllers +{ + [ApiController] + [Route("[controller]")] + public class WeatherForecastController : ControllerBase + { + private static readonly string[] Summaries = new[] + { + "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" + }; + + private readonly ILogger _logger; + + public WeatherForecastController(ILogger logger) + { + _logger = logger; + } + + [HttpGet(Name = "GetWeatherForecast")] + public IEnumerable Get() + { + return Enumerable.Range(1, 5).Select(index => new WeatherForecast + { + Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)), + TemperatureC = Random.Shared.Next(-20, 55), + Summary = Summaries[Random.Shared.Next(Summaries.Length)] + }) + .ToArray(); + } + } +} diff --git a/Data/MichelinDbContext.cs b/Data/MichelinDbContext.cs new file mode 100644 index 0000000..1c05c7f --- /dev/null +++ b/Data/MichelinDbContext.cs @@ -0,0 +1,22 @@ +using Microsoft.EntityFrameworkCore; +using WMS_GIRAF_Interface.Entities; + +namespace WMS_GIRAF_Interface.Data; + +public class MichelinDbContext : DbContext +{ + public MichelinDbContext(DbContextOptions options) + : base(options) + { + + } + + public DbSet DestinationId { get; set; } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + + + } + +} \ No newline at end of file diff --git a/Entities/IO_CONTROL.cs b/Entities/IO_CONTROL.cs new file mode 100644 index 0000000..fd00e00 --- /dev/null +++ b/Entities/IO_CONTROL.cs @@ -0,0 +1,74 @@ +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace WMS_GIRAF_Interface.Entities +{ + [Table("IO_CONTROL")] + public class IO_CONTROL + { + [Column("CONTROL_ID")] + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int? CONTROL_ID { get; set; } + [Column("RELATIVE_CONTROL_ID")] + public int? RELATIVE_CONTROL_ID { get; set; } + + [Column("MANAGE_ID")] + public int? MANAGE_ID { get; set; } + + [Column("STOCK_BARCODE")] + public string? STOCK_BARCODE { get; set; } + + [Column("PRE_CONTROL_STATUS")] + public string? PRE_CONTROL_STATUS { get; set; } + + [Column("CONTROL_TASK_TYPE")] + public int? CONTROL_TASK_TYPE { get; set; } + + [Column("CONTROL_TASK_LEVEL")] + public string? CONTROL_TASK_LEVEL { get; set; } + + [Column("START_WAREHOUSE_CODE")] + public string? START_WAREHOUSE_CODE { get; set; } + + [Column("END_WAREHOUSE_CODE")] + public string? END_WAREHOUSE_CODE { get; set; } + + [Column("START_DEVICE_CODE")] + public string START_DEVICE_CODE { get; set; } + + [Column("END_DEVICE_CODE")] + public string? END_DEVICE_CODE { get; set; } + + [Column("CONTROL_STATUS")] + public int CONTROL_STATUS { get; set; } + + [Column("ERROR_TEXT")] + public string? ERROR_TEXT { get; set; } + + [Column("CONTROL_BEGIN_TIME")] + public string CONTROL_BEGIN_TIME { get; set; } + + [Column("CONTROL_END_TIME")] + public string? CONTROL_END_TIME { get; set; } + + [Column("CONTROL_REMARK")] + public string? CONTROL_REMARK { get; set; } + + [Column("targetOutputDateInUtc")] + public string targetOutputDateInUtc { get; set; } + + [Column("keepRequestInMemoryEvenIfMechanicalIssue")] + public string? keepRequestInMemoryEvenIfMechanicalIssue { get; set; } + + [Column("keepRequestInMemoryEvenIfLackOfProductIssue")] + public string keepRequestInMemoryEvenIfLackOfProductIssue { get; set; } + + [Column("requestNumber")] + public string? requestNumber { get; set; } + + [Column("POPULATION")] + public string? POPULATION { get; set; } + + } +} \ No newline at end of file diff --git a/Entities/IO_CONTROL_ROUTE.cs b/Entities/IO_CONTROL_ROUTE.cs new file mode 100644 index 0000000..572a8f6 --- /dev/null +++ b/Entities/IO_CONTROL_ROUTE.cs @@ -0,0 +1,29 @@ +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace WMS_GIRAF_Interface.Entities; + + [Table("IO_CONTROL_ROUTE")] + public class IO_CONTROL_ROUTE + { + [Column("CONTROL_ROUTE_ID")] + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int CONTROL_ROUTE_ID { get; set; } + [Column("CONTROL_ROUTE_TYPE")] + public int CONTROL_ROUTE_TYPE { get; set; } + [Column("CONTROL_ROUTE_CODE")] + public string CONTROL_ROUTE_CODE { get; set; } + + [Column("CONTROL_ROUTE_NAME")] + public string CONTROL_ROUTE_NAME { get; set; } + [Column("START_DEVICE")] + public string START_DEVICE { get; set; } + [Column("END_DEVICE")] + public string END_DEVICE { get; set; } + [Column("CONTROL_ROUTE_STATUS")] + public int CONTROL_ROUTE_STATUS { get; set; } + + [Column("CONTROL_ROUTE_REMARK")] + public string CONTROL_ROUTE_REMARK { get; set; } + } diff --git a/Entities/IO_CONTROL_ROUTE_OUT.cs b/Entities/IO_CONTROL_ROUTE_OUT.cs new file mode 100644 index 0000000..d0a85fd --- /dev/null +++ b/Entities/IO_CONTROL_ROUTE_OUT.cs @@ -0,0 +1,29 @@ +using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations; + +namespace WMS_GIRAF_Interface.Entities; + +[Table("IO_CONTROL_ROUTE_OUT")] +public class IO_CONTROL_ROUTE_OUT +{ + [Column("CONTROL_ROUTE_ID")] + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int CONTROL_ROUTE_ID { get; set; } + [Column("CONTROL_ROUTE_TYPE")] + public int CONTROL_ROUTE_TYPE { get; set; } + [Column("CONTROL_ROUTE_CODE")] + public string CONTROL_ROUTE_CODE { get; set; } + + [Column("CONTROL_ROUTE_NAME")] + public string CONTROL_ROUTE_NAME { get; set; } + [Column("START_DEVICE")] + public string START_DEVICE { get; set; } + [Column("END_DEVICE")] + public string END_DEVICE { get; set; } + [Column("CONTROL_ROUTE_STATUS")] + public int CONTROL_ROUTE_STATUS { get; set; } + + [Column("CONTROL_ROUTE_REMARK")] + public string CONTROL_ROUTE_REMARK { get; set; } +} \ No newline at end of file diff --git a/Entities/destinationId.cs b/Entities/destinationId.cs new file mode 100644 index 0000000..4f1f0a2 --- /dev/null +++ b/Entities/destinationId.cs @@ -0,0 +1,20 @@ +using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations; + +namespace WMS_GIRAF_Interface.Entities; + +/// +/// 数据表:destinationId +/// +[Table("destinationId")] +public class destinationId +{ + + [Column("ID")] + public int? ID { get; set; } + [Column("AREA")] + public string? AREA { get; set; } + [Column("DEVICE_CODE")] + public string? DEVICE_CODE { get; set; } + +} \ No newline at end of file diff --git a/Models/InputStorageLinePathState.cs b/Models/InputStorageLinePathState.cs new file mode 100644 index 0000000..8cb0744 --- /dev/null +++ b/Models/InputStorageLinePathState.cs @@ -0,0 +1,13 @@ +namespace WMS_GIRAF_Interface.Models; + +public class InputStorageLinePathState +{ + + public class Rootobject + { + public string? PathState { get; set; } + public int? LineNumber { get; set; } + public string? SourceId { get; set; } + } + +} \ No newline at end of file diff --git a/Program.cs b/Program.cs new file mode 100644 index 0000000..48863a6 --- /dev/null +++ b/Program.cs @@ -0,0 +1,25 @@ +var builder = WebApplication.CreateBuilder(args); + +// Add services to the container. + +builder.Services.AddControllers(); +// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle +builder.Services.AddEndpointsApiExplorer(); +builder.Services.AddSwaggerGen(); + +var app = builder.Build(); + +// Configure the HTTP request pipeline. +if (app.Environment.IsDevelopment()) +{ + app.UseSwagger(); + app.UseSwaggerUI(); +} + +app.UseHttpsRedirection(); + +app.UseAuthorization(); + +app.MapControllers(); + +app.Run(); diff --git a/Properties/launchSettings.json b/Properties/launchSettings.json new file mode 100644 index 0000000..9308f29 --- /dev/null +++ b/Properties/launchSettings.json @@ -0,0 +1,41 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:5608", + "sslPort": 44380 + } + }, + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "http://localhost:5146", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "https://localhost:7087;http://localhost:5146", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/Repositories/Implement/destinationIdRepository.cs b/Repositories/Implement/destinationIdRepository.cs new file mode 100644 index 0000000..1b98168 --- /dev/null +++ b/Repositories/Implement/destinationIdRepository.cs @@ -0,0 +1,29 @@ +using WMS_GIRAF_Interface.Data; +using WMS_GIRAF_Interface.Entities; +using WMS_GIRAF_Interface.Repositories.Interface; + +namespace WMS_GIRAF_Interface.Repositories.Implement; + +public class destinationIdRepository : IdestinationIdRepository +{ + private readonly MichelinDbContext _context; + private readonly ILogger _logger; + public destinationIdRepository(MichelinDbContext context, ILogger logger) + { + _context = context; + _logger = logger; + } + + public destinationId? GetDestinationId(int? lineNumber) + { + if (lineNumber!=0) + { + throw new ArgumentException(nameof(GetDestinationId)); + } + + var destinationIdInfo = _context.DestinationId.FirstOrDefault(x => x.ID == lineNumber); + + return destinationIdInfo; + } + +} \ No newline at end of file diff --git a/Repositories/Interface/IdestinationIdRepository.cs b/Repositories/Interface/IdestinationIdRepository.cs new file mode 100644 index 0000000..0b440c2 --- /dev/null +++ b/Repositories/Interface/IdestinationIdRepository.cs @@ -0,0 +1,8 @@ +using WMS_GIRAF_Interface.Entities; + +namespace WMS_GIRAF_Interface.Repositories.Interface; + +public interface IdestinationIdRepository +{ + public destinationId? GetDestinationId(int? lineNumber); +} \ No newline at end of file diff --git a/SerilogConfig.cs b/SerilogConfig.cs new file mode 100644 index 0000000..5b627ad --- /dev/null +++ b/SerilogConfig.cs @@ -0,0 +1,80 @@ +using Serilog; +using System.Collections.ObjectModel; +using System.Net; +using Serilog.Sinks.MSSqlServer; + +namespace WMS_GIRAF_Interface +{ + + public static class SerilogConfig + { + public static void CreateLogger() + { + var filePath = Path.Combine(AppContext.BaseDirectory, "Logs/Serilog/log.txt"); +#if DEBUG + var logDB = @"Server=JIAN_PC;database=CAN_Lucid_ASRS;uid=sa;pwd=Siasun;TrustServerCertificate=true"; +#else + var logDB = @"Server=LUCID-ASRS-A01;database=CAN_Lucid_ASRS;uid=sa;pwd=Siasun123;TrustServerCertificate=true"; +#endif + var sinkOpts = new MSSqlServerSinkOptions(); + sinkOpts.TableName = "Logs_Serilog"; + sinkOpts.AutoCreateSqlTable = true; + sinkOpts.BatchPostingLimit = 1; + sinkOpts.BatchPeriod = TimeSpan.FromSeconds(1); + var columnOpts = new ColumnOptions(); + //columnOpts.Store.Remove(StandardColumn.Properties); + //columnOpts.Store.Add(StandardColumn.LogEvent); + //columnOpts.LogEvent.DataLength = 2048; + //columnOpts.PrimaryKey = columnOpts.TimeStamp; + //columnOpts.TimeStamp.NonClusteredIndex = true; + columnOpts.Store.Remove(StandardColumn.MessageTemplate); + columnOpts.Properties.ExcludeAdditionalProperties = true; + columnOpts.AdditionalColumns = new Collection + { + new SqlColumn{DataType = System.Data.SqlDbType.NVarChar, DataLength = 32, ColumnName = "IP"} + }; + + Log.Logger = new LoggerConfiguration() + .MinimumLevel.Information() + .WriteTo.Console( + outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] ({ThreadId}) {Message}{NewLine}{Exception}") + .WriteTo.File(filePath, + outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] ({ThreadId}) {Message:lj}{NewLine}{Exception}", + rollingInterval: RollingInterval.Day, + fileSizeLimitBytes: 1073741824).MinimumLevel.Information() //1GB + .Enrich.FromLogContext() + .Enrich.WithProperty("IP", GetIpAddress()) + .WriteTo.MSSqlServer( + connectionString: logDB, + sinkOptions: sinkOpts, + columnOptions: columnOpts + ).MinimumLevel.Warning().CreateLogger(); + } + + public static void RefreshLogger() + { + if (Log.Logger != null) + { + Log.CloseAndFlush(); + } + CreateLogger(); + } + + private static string GetIpAddress() + { + string ipAddress = "127.0.0.1"; + IPAddress[] ips = Dns.GetHostAddresses(Dns.GetHostName()); + foreach (IPAddress ip in ips) + { + if (ip.AddressFamily.ToString().ToLower().Equals("internetwork")) + { + ipAddress = ip.ToString(); + return ipAddress; + } + } + + return ipAddress; + } + } + +} diff --git a/WMS_GIRAF_Interface.csproj b/WMS_GIRAF_Interface.csproj new file mode 100644 index 0000000..b38c4c1 --- /dev/null +++ b/WMS_GIRAF_Interface.csproj @@ -0,0 +1,23 @@ + + + + net8.0 + enable + enable + + + + + + + + + + + + + + + + + diff --git a/WMS_GIRAF_Interface.http b/WMS_GIRAF_Interface.http new file mode 100644 index 0000000..6e10412 --- /dev/null +++ b/WMS_GIRAF_Interface.http @@ -0,0 +1,6 @@ +@WMS_GIRAF_Interface_HostAddress = http://localhost:5146 + +GET {{WMS_GIRAF_Interface_HostAddress}}/weatherforecast/ +Accept: application/json + +### diff --git a/WMS_GIRAF_Interface.sln b/WMS_GIRAF_Interface.sln new file mode 100644 index 0000000..2b639fd --- /dev/null +++ b/WMS_GIRAF_Interface.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.10.35013.160 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WMS_GIRAF_Interface", "WMS_GIRAF_Interface.csproj", "{6ADDA8F0-8263-47BA-84A7-F297E9D1F641}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6ADDA8F0-8263-47BA-84A7-F297E9D1F641}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6ADDA8F0-8263-47BA-84A7-F297E9D1F641}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6ADDA8F0-8263-47BA-84A7-F297E9D1F641}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6ADDA8F0-8263-47BA-84A7-F297E9D1F641}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {4773BD7F-7D17-49DC-90E4-DCCE75F54B78} + EndGlobalSection +EndGlobal diff --git a/WeatherForecast.cs b/WeatherForecast.cs new file mode 100644 index 0000000..5bd7753 --- /dev/null +++ b/WeatherForecast.cs @@ -0,0 +1,13 @@ +namespace WMS_GIRAF_Interface +{ + public class WeatherForecast + { + public DateOnly Date { get; set; } + + public int TemperatureC { get; set; } + + public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); + + public string? Summary { get; set; } + } +} diff --git a/appsettings.Development.json b/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/appsettings.json b/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +}