Browse Source

添加项目文件。

master
taoleite 2 months ago
parent
commit
978cc9f00c
  1. 16
      Controllers/IsAliveController.cs
  2. 45
      Controllers/SendInputStorageLinePathStateController.cs
  3. 33
      Controllers/WeatherForecastController.cs
  4. 22
      Data/MichelinDbContext.cs
  5. 74
      Entities/IO_CONTROL.cs
  6. 29
      Entities/IO_CONTROL_ROUTE.cs
  7. 29
      Entities/IO_CONTROL_ROUTE_OUT.cs
  8. 20
      Entities/destinationId.cs
  9. 13
      Models/InputStorageLinePathState.cs
  10. 25
      Program.cs
  11. 41
      Properties/launchSettings.json
  12. 29
      Repositories/Implement/destinationIdRepository.cs
  13. 8
      Repositories/Interface/IdestinationIdRepository.cs
  14. 80
      SerilogConfig.cs
  15. 23
      WMS_GIRAF_Interface.csproj
  16. 6
      WMS_GIRAF_Interface.http
  17. 25
      WMS_GIRAF_Interface.sln
  18. 13
      WeatherForecast.cs
  19. 8
      appsettings.Development.json
  20. 9
      appsettings.json

16
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;
}
}
}

45
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;
}
/// <summary>
/// 更新入库路径状态
/// </summary>
[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
}
}
}
}

33
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<WeatherForecastController> _logger;
public WeatherForecastController(ILogger<WeatherForecastController> logger)
{
_logger = logger;
}
[HttpGet(Name = "GetWeatherForecast")]
public IEnumerable<WeatherForecast> 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();
}
}
}

22
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<MichelinDbContext> options)
: base(options)
{
}
public DbSet<destinationId> DestinationId { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
}
}

74
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; }
}
}

29
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; }
}

29
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; }
}

20
Entities/destinationId.cs

@ -0,0 +1,20 @@
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
namespace WMS_GIRAF_Interface.Entities;
/// <summary>
/// 数据表:destinationId
/// </summary>
[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; }
}

13
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; }
}
}

25
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();

41
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"
}
}
}
}

29
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<destinationIdRepository> _logger;
public destinationIdRepository(MichelinDbContext context, ILogger<destinationIdRepository> 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;
}
}

8
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);
}

80
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<SqlColumn>
{
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;
}
}
}

23
WMS_GIRAF_Interface.csproj

@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.7" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.7" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.2" />
<PackageReference Include="Serilog.Sinks.MSSqlServer" Version="6.6.1" />
<PackageReference Include="Serilog.Sinks.Seq" Version="8.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
</ItemGroup>
<ItemGroup>
<Folder Include="TaskServices\" />
</ItemGroup>
</Project>

6
WMS_GIRAF_Interface.http

@ -0,0 +1,6 @@
@WMS_GIRAF_Interface_HostAddress = http://localhost:5146
GET {{WMS_GIRAF_Interface_HostAddress}}/weatherforecast/
Accept: application/json
###

25
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

13
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; }
}
}

8
appsettings.Development.json

@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

9
appsettings.json

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
Loading…
Cancel
Save